Completed
Push — master ( c847f3...1a4e84 )
by Dwain
05:11
created
includes/class-sensei-analysis-lesson-list-table.php 3 patches
Braces   +9 added lines, -11 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 Lesson List Table Class
@@ -204,31 +207,26 @@  discard block
 block discarded – undo
204 207
 			$status_class = 'graded';
205 208
 
206 209
 			$grade =  __( 'No Grade', 'woothemes-sensei' );
207
-		}
208
-		elseif( 'graded' == $item->comment_approved ) {
210
+		} elseif( 'graded' == $item->comment_approved ) {
209 211
 			$status = __( 'Graded', 'woothemes-sensei' ) ;
210 212
 			$status_class = 'graded';
211 213
 
212 214
 			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
213
-		}
214
-		elseif( 'passed' == $item->comment_approved ) {
215
+		} elseif( 'passed' == $item->comment_approved ) {
215 216
 			$status =  __( 'Passed', 'woothemes-sensei' );
216 217
 			$status_class = 'graded';
217 218
 
218 219
 			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
219
-		}
220
-		elseif( 'failed' == $item->comment_approved ) {
220
+		} elseif( 'failed' == $item->comment_approved ) {
221 221
 			$status = __( 'Failed', 'woothemes-sensei' );
222 222
 			$status_class = 'failed';
223 223
 
224 224
 			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
225
-		}
226
-		elseif( 'ungraded' == $item->comment_approved ) {
225
+		} elseif( 'ungraded' == $item->comment_approved ) {
227 226
 			$status =  __( 'Ungraded', 'woothemes-sensei' );
228 227
 			$status_class = 'ungraded';
229 228
 
230
-		}
231
-		else {
229
+		} else {
232 230
 			$status =  __( 'In Progress', 'woothemes-sensei' );
233 231
 			$user_end_date = '';
234 232
 		}
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 		}
231 231
 
232 232
 		// Output users data
233
-        $user_name = Sensei_Learner::get_full_name( $item->user_id );
233
+		$user_name = Sensei_Learner::get_full_name( $item->user_id );
234 234
 
235
-        if ( !$this->csv_output ) {
235
+		if ( !$this->csv_output ) {
236 236
 			$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) );
237 237
 
238 238
 			$user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>';
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 	 */
340 340
 	public function search_button( $text = '' ) {
341 341
 
342
-        $text =  __( 'Search Learners', 'woothemes-sensei' );
342
+		$text =  __( 'Search Learners', 'woothemes-sensei' );
343 343
 
344
-        return $text;
344
+		return $text;
345 345
 
346 346
 	}
347 347
 } // End Class
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 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
  * Admin Analysis Lesson Data Table in Sensei.
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
 	 * Constructor
19 19
 	 * @since  1.2.0
20 20
 	 */
21
-	public function __construct ( $lesson_id = 0 ) {
22
-		$this->lesson_id = intval( $lesson_id );
23
-		$this->course_id = intval( get_post_meta( $this->lesson_id, '_lesson_course', true ) );
21
+	public function __construct($lesson_id = 0) {
22
+		$this->lesson_id = intval($lesson_id);
23
+		$this->course_id = intval(get_post_meta($this->lesson_id, '_lesson_course', true));
24 24
 
25 25
 		// Load Parent token into constructor
26
-		parent::__construct( 'analysis_lesson' );
26
+		parent::__construct('analysis_lesson');
27 27
 
28 28
 		// Actions
29
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
30
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
29
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
30
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
31 31
 
32
-		add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) );
32
+		add_filter('sensei_list_table_search_button_text', array($this, 'search_button'));
33 33
 	} // End __construct()
34 34
 
35 35
 	/**
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	function get_columns() {
41 41
 		$columns = array(
42
-			'title' => __( 'Learner', 'woothemes-sensei' ),
43
-			'started' => __( 'Date Started', 'woothemes-sensei' ),
44
-			'completed' => __( 'Date Completed', 'woothemes-sensei' ),
45
-			'status' => __( 'Status', 'woothemes-sensei' ),
46
-			'grade' => __( 'Grade', 'woothemes-sensei' ),
42
+			'title' => __('Learner', 'woothemes-sensei'),
43
+			'started' => __('Date Started', 'woothemes-sensei'),
44
+			'completed' => __('Date Completed', 'woothemes-sensei'),
45
+			'status' => __('Status', 'woothemes-sensei'),
46
+			'grade' => __('Grade', 'woothemes-sensei'),
47 47
 		);
48
-		$columns = apply_filters( 'sensei_analysis_lesson_columns', $columns, $this );
48
+		$columns = apply_filters('sensei_analysis_lesson_columns', $columns, $this);
49 49
 		return $columns;
50 50
 	}
51 51
 
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	function get_sortable_columns() {
58 58
 		$columns = array(
59
-			'title' => array( 'title', false ),
60
-			'started' => array( 'started', false ),
61
-			'completed' => array( 'completed', false ),
62
-			'status' => array( 'status', false ),
63
-			'grade' => array( 'grade', false ),
59
+			'title' => array('title', false),
60
+			'started' => array('started', false),
61
+			'completed' => array('completed', false),
62
+			'status' => array('status', false),
63
+			'grade' => array('grade', false),
64 64
 		);
65
-		$columns = apply_filters( 'sensei_analysis_lesson_columns_sortable', $columns, $this );
65
+		$columns = apply_filters('sensei_analysis_lesson_columns_sortable', $columns, $this);
66 66
 		return $columns;
67 67
 	}
68 68
 
@@ -76,32 +76,32 @@  discard block
 block discarded – undo
76 76
 
77 77
 		// Handle orderby (needs work)
78 78
 		$orderby = '';
79
-		if ( !empty( $_GET['orderby'] ) ) {
80
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
81
-				$orderby = esc_html( $_GET['orderby'] );
79
+		if ( ! empty($_GET['orderby'])) {
80
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
81
+				$orderby = esc_html($_GET['orderby']);
82 82
 			} // End If Statement
83 83
 		}
84 84
 
85 85
 		// Handle order
86 86
 		$order = 'ASC';
87
-		if ( !empty( $_GET['order'] ) ) {
88
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
87
+		if ( ! empty($_GET['order'])) {
88
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
89 89
 		}
90 90
 
91 91
 		// Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids
92 92
 		$search = false;
93
-		if ( !empty( $_GET['s'] ) ) {
94
-			$search = esc_html( $_GET['s'] );
93
+		if ( ! empty($_GET['s'])) {
94
+			$search = esc_html($_GET['s']);
95 95
 		} // End If Statement
96 96
 		$this->search = $search;
97 97
 
98
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
99
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
98
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
99
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
100 100
 
101 101
 		$paged = $this->get_pagenum();
102 102
 		$offset = 0;
103
-		if ( !empty($paged) ) {
104
-			$offset = $per_page * ( $paged - 1 );
103
+		if ( ! empty($paged)) {
104
+			$offset = $per_page * ($paged - 1);
105 105
 		} // End If Statement
106 106
 
107 107
 		$args = array(
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
 			'orderby' => $orderby,
111 111
 			'order' => $order,
112 112
 		);
113
-		if ( $this->search ) {
113
+		if ($this->search) {
114 114
 			$args['search'] = $this->search;
115 115
 		} // End If Statement
116 116
 
117
-		$this->items = $this->get_lesson_statuses( $args );
117
+		$this->items = $this->get_lesson_statuses($args);
118 118
 
119 119
 		$total_items = $this->total_items;
120
-		$total_pages = ceil( $total_items / $per_page );
121
-		$this->set_pagination_args( array(
120
+		$total_pages = ceil($total_items / $per_page);
121
+		$this->set_pagination_args(array(
122 122
 			'total_items' => $total_items,
123 123
 			'total_pages' => $total_pages,
124 124
 			'per_page' => $per_page
125
-		) );
125
+		));
126 126
 	}
127 127
 
128 128
 	/**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @since  1.7.0
131 131
 	 * @return data
132 132
 	 */
133
-	public function generate_report( $report ) {
133
+	public function generate_report($report) {
134 134
 
135 135
 		$data = array();
136 136
 
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
 
139 139
 		// Handle orderby
140 140
 		$orderby = '';
141
-		if ( !empty( $_GET['orderby'] ) ) {
142
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
143
-				$orderby = esc_html( $_GET['orderby'] );
141
+		if ( ! empty($_GET['orderby'])) {
142
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
143
+				$orderby = esc_html($_GET['orderby']);
144 144
 			} // End If Statement
145 145
 		}
146 146
 
147 147
 		// Handle order
148 148
 		$order = 'ASC';
149
-		if ( !empty( $_GET['order'] ) ) {
150
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
149
+		if ( ! empty($_GET['order'])) {
150
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
151 151
 		}
152 152
 
153 153
 		// Handle search
154 154
 		$search = false;
155
-		if ( !empty( $_GET['s'] ) ) {
156
-			$search = esc_html( $_GET['s'] );
155
+		if ( ! empty($_GET['s'])) {
156
+			$search = esc_html($_GET['s']);
157 157
 		} // End If Statement
158 158
 		$this->search = $search;
159 159
 
@@ -161,23 +161,23 @@  discard block
 block discarded – undo
161 161
 			'orderby' => $orderby,
162 162
 			'order' => $order,
163 163
 		);
164
-		if ( $this->search ) {
164
+		if ($this->search) {
165 165
 			$args['search'] = $this->search;
166 166
 		} // End If Statement
167 167
 
168 168
 		// Start the csv with the column headings
169 169
 		$column_headers = array();
170 170
 		$columns = $this->get_columns();
171
-		foreach( $columns AS $key => $title ) {
171
+		foreach ($columns AS $key => $title) {
172 172
 			$column_headers[] = $title;
173 173
 		}
174 174
 		$data[] = $column_headers;
175 175
 
176
-		$this->items = $this->get_lesson_statuses( $args );
176
+		$this->items = $this->get_lesson_statuses($args);
177 177
 
178 178
 		// Process each row
179
-		foreach( $this->items AS $item) {
180
-			$data[] = $this->get_row_data( $item );
179
+		foreach ($this->items AS $item) {
180
+			$data[] = $this->get_row_data($item);
181 181
 		}
182 182
 
183 183
 		return $data;
@@ -189,64 +189,64 @@  discard block
 block discarded – undo
189 189
 	 * @since  1.7.0
190 190
 	 * @param object $item The current item
191 191
 	 */
192
-	protected function get_row_data( $item ) {
192
+	protected function get_row_data($item) {
193 193
 
194
-		$user_start_date = get_comment_meta( $item->comment_ID, 'start', true );
194
+		$user_start_date = get_comment_meta($item->comment_ID, 'start', true);
195 195
 		$user_end_date = $item->comment_date;
196 196
 		$status_class = $grade = '';
197 197
 
198
-		if( 'complete' == $item->comment_approved ) {
199
-			$status =  __( 'Completed', 'woothemes-sensei' );
198
+		if ('complete' == $item->comment_approved) {
199
+			$status = __('Completed', 'woothemes-sensei');
200 200
 			$status_class = 'graded';
201 201
 
202
-			$grade =  __( 'No Grade', 'woothemes-sensei' );
202
+			$grade = __('No Grade', 'woothemes-sensei');
203 203
 		}
204
-		elseif( 'graded' == $item->comment_approved ) {
205
-			$status = __( 'Graded', 'woothemes-sensei' ) ;
204
+		elseif ('graded' == $item->comment_approved) {
205
+			$status = __('Graded', 'woothemes-sensei');
206 206
 			$status_class = 'graded';
207 207
 
208
-			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
208
+			$grade = get_comment_meta($item->comment_ID, 'grade', true);
209 209
 		}
210
-		elseif( 'passed' == $item->comment_approved ) {
211
-			$status =  __( 'Passed', 'woothemes-sensei' );
210
+		elseif ('passed' == $item->comment_approved) {
211
+			$status = __('Passed', 'woothemes-sensei');
212 212
 			$status_class = 'graded';
213 213
 
214
-			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
214
+			$grade = get_comment_meta($item->comment_ID, 'grade', true);
215 215
 		}
216
-		elseif( 'failed' == $item->comment_approved ) {
217
-			$status = __( 'Failed', 'woothemes-sensei' );
216
+		elseif ('failed' == $item->comment_approved) {
217
+			$status = __('Failed', 'woothemes-sensei');
218 218
 			$status_class = 'failed';
219 219
 
220
-			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
220
+			$grade = get_comment_meta($item->comment_ID, 'grade', true);
221 221
 		}
222
-		elseif( 'ungraded' == $item->comment_approved ) {
223
-			$status =  __( 'Ungraded', 'woothemes-sensei' );
222
+		elseif ('ungraded' == $item->comment_approved) {
223
+			$status = __('Ungraded', 'woothemes-sensei');
224 224
 			$status_class = 'ungraded';
225 225
 
226 226
 		}
227 227
 		else {
228
-			$status =  __( 'In Progress', 'woothemes-sensei' );
228
+			$status = __('In Progress', 'woothemes-sensei');
229 229
 			$user_end_date = '';
230 230
 		}
231 231
 
232 232
 		// Output users data
233
-        $user_name = Sensei_Learner::get_full_name( $item->user_id );
233
+        $user_name = Sensei_Learner::get_full_name($item->user_id);
234 234
 
235
-        if ( !$this->csv_output ) {
236
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) );
235
+        if ( ! $this->csv_output) {
236
+			$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id), admin_url('admin.php'));
237 237
 
238
-			$user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>';
239
-			$status = sprintf( '<span class="%s">%s</span>', $item->comment_approved, $status );
240
-			if ( is_numeric($grade) ) {
238
+			$user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$user_name.'</a></strong>';
239
+			$status = sprintf('<span class="%s">%s</span>', $item->comment_approved, $status);
240
+			if (is_numeric($grade)) {
241 241
 				$grade .= '%';
242 242
 			}
243 243
 		} // End If Statement
244
-		$column_data = apply_filters( 'sensei_analysis_lesson_column_data', array( 'title' => $user_name,
244
+		$column_data = apply_filters('sensei_analysis_lesson_column_data', array('title' => $user_name,
245 245
 										'started' => $user_start_date,
246 246
 										'completed' => $user_end_date,
247 247
 										'status' => $status,
248 248
 										'grade' => $grade,
249
-									), $item, $this );
249
+									), $item, $this);
250 250
 
251 251
 		return $column_data;
252 252
 	}
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 * @since  1.7.0
257 257
 	 * @return array statuses
258 258
 	 */
259
-	private function get_lesson_statuses( $args ) {
259
+	private function get_lesson_statuses($args) {
260 260
 
261 261
 		$activity_args = array( 
262 262
 				'post_id' => $this->lesson_id,
@@ -269,34 +269,34 @@  discard block
 block discarded – undo
269 269
 			);
270 270
 
271 271
 		// Searching users on statuses requires sub-selecting the statuses by user_ids
272
-		if ( $this->search ) {
272
+		if ($this->search) {
273 273
 			$user_args = array(
274
-				'search' => '*' . $this->search . '*',
274
+				'search' => '*'.$this->search.'*',
275 275
 				'fields' => 'ID',
276 276
 			);
277 277
 			// Filter for extending
278
-			$user_args = apply_filters( 'sensei_analysis_lesson_search_users', $user_args );
279
-			if ( !empty( $user_args ) ) {
280
-				$learners_search = new WP_User_Query( $user_args );
278
+			$user_args = apply_filters('sensei_analysis_lesson_search_users', $user_args);
279
+			if ( ! empty($user_args)) {
280
+				$learners_search = new WP_User_Query($user_args);
281 281
 				// Store for reuse on counts
282 282
 				$activity_args['user_id'] = (array) $learners_search->get_results();
283 283
 			}
284 284
 		} // End If Statement
285 285
 
286
-		$activity_args = apply_filters( 'sensei_analysis_lesson_filter_statuses', $activity_args );
286
+		$activity_args = apply_filters('sensei_analysis_lesson_filter_statuses', $activity_args);
287 287
 
288 288
 		// WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice
289
-		$this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
289
+		$this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0)));
290 290
 
291 291
 		// Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views?
292
-		if ( $this->total_items < $activity_args['offset'] ) {
293
-			$new_paged = floor( $total_statuses / $activity_args['number'] );
292
+		if ($this->total_items < $activity_args['offset']) {
293
+			$new_paged = floor($total_statuses / $activity_args['number']);
294 294
 			$activity_args['offset'] = $new_paged * $activity_args['number'];
295 295
 		}
296
-		$statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true );
296
+		$statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true);
297 297
 		// Need to always return an array, even with only 1 item
298
-		if ( !is_array($statuses) ) {
299
-			$statuses = array( $statuses );
298
+		if ( ! is_array($statuses)) {
299
+			$statuses = array($statuses);
300 300
 		}
301 301
 		return $statuses;
302 302
 	} // End get_lesson_statuses()
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 * @return void
309 309
 	 */
310 310
 	public function no_items() {
311
-		 _e( 'No learners found.', 'woothemes-sensei' );
311
+		 _e('No learners found.', 'woothemes-sensei');
312 312
 	} // End no_items()
313 313
 
314 314
 	/**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 * @return void
318 318
 	 */
319 319
 	public function data_table_header() {
320
-		echo '<strong>' . __( 'Learners taking this Lesson', 'woothemes-sensei' ) . '</strong>';
320
+		echo '<strong>'.__('Learners taking this Lesson', 'woothemes-sensei').'</strong>';
321 321
 	} // End data_table_header()
322 322
 
323 323
 	/**
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
 	 * @return void
327 327
 	 */
328 328
 	public function data_table_footer() {
329
-		$lesson = get_post( $this->lesson_id );
330
-		$report = sanitize_title( $lesson->post_title ) . '-learners-overview';
331
-		$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $this->lesson_id, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) );
332
-		echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>';
329
+		$lesson = get_post($this->lesson_id);
330
+		$report = sanitize_title($lesson->post_title).'-learners-overview';
331
+		$url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $this->lesson_id, 'sensei_report_download' => $report), admin_url('admin.php'));
332
+		echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>';
333 333
 	} // End data_table_footer()
334 334
 
335 335
 	/**
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
 	 * @since  1.7.0
338 338
 	 * @return string $text
339 339
 	 */
340
-	public function search_button( $text = '' ) {
340
+	public function search_button($text = '') {
341 341
 
342
-        $text =  __( 'Search Learners', 'woothemes-sensei' );
342
+        $text = __('Search Learners', 'woothemes-sensei');
343 343
 
344 344
         return $text;
345 345
 
Please login to merge, or discard this patch.
includes/class-sensei-templates.php 3 patches
Braces   +21 added lines, -9 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; // security check, don't load file outside WP
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// security check, don't load file outside WP
3 6
 /**
4 7
  * Sensei Template Class
5 8
  *
@@ -69,8 +72,9 @@  discard block
 block discarded – undo
69 72
      */
70 73
     public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
71 74
 
72
-        if ( $args && is_array($args) )
73
-            extract( $args );
75
+        if ( $args && is_array($args) ) {
76
+                    extract( $args );
77
+        }
74 78
 
75 79
         $located = self::locate_template( $template_name, $template_path, $default_path );
76 80
 
@@ -99,8 +103,12 @@  discard block
 block discarded – undo
99 103
      */
100 104
     public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
101 105
 
102
-        if ( ! $template_path ) $template_path = Sensei()->template_url;
103
-        if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
106
+        if ( ! $template_path ) {
107
+        	$template_path = Sensei()->template_url;
108
+        }
109
+        if ( ! $default_path ) {
110
+        	$default_path = Sensei()->plugin_path() . '/templates/';
111
+        }
104 112
 
105 113
         // Look within passed path within the theme - this is priority
106 114
         $template = locate_template(
@@ -261,7 +269,7 @@  discard block
 block discarded – undo
261 269
             $find[] = $file;
262 270
             $find[] = Sensei()->template_url . $file;
263 271
 
264
-        }elseif( is_author()
272
+        } elseif( is_author()
265 273
                  && Sensei_Teacher::is_a_teacher( get_query_var('author') )
266 274
                  && ! user_can( get_query_var('author'), 'manage_options' ) ){
267 275
 
@@ -274,7 +282,9 @@  discard block
 block discarded – undo
274 282
         if ( $file ) {
275 283
 
276 284
             $template = locate_template( $find );
277
-            if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
285
+            if ( ! $template ) {
286
+            	$template = Sensei()->plugin_path() . '/templates/' . $file;
287
+            }
278 288
 
279 289
         } // End If Statement
280 290
 
@@ -305,7 +315,9 @@  discard block
 block discarded – undo
305 315
         $find[] = Sensei()->template_url . $file;
306 316
 
307 317
         $template = locate_template( $find );
308
-        if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
318
+        if ( ! $template ) {
319
+        	$template = Sensei()->plugin_path() . '/templates/' . $file;
320
+        }
309 321
 
310 322
         return $template;
311 323
 
@@ -335,7 +347,7 @@  discard block
 block discarded – undo
335 347
                 include( $found_template );
336 348
                 get_sensei_footer();
337 349
 
338
-            }else{
350
+            } else{
339 351
 
340 352
                 include( $found_template );
341 353
 
Please login to merge, or discard this patch.
Indentation   +515 added lines, -515 removed lines patch added patch discarded remove patch
@@ -12,684 +12,684 @@
 block discarded – undo
12 12
  */
13 13
 class Sensei_Templates {
14 14
 
15
-    /**
16
-     *  Load the template files from within sensei/templates/ or the the theme if overrided within the theme.
17
-     *
18
-     * @since 1.9.0
19
-     * @param string $slug
20
-     * @param string $name default: ''
21
-     *
22
-     * @return void
23
-     */
24
-    public static function get_part(  $slug, $name = ''  ){
15
+	/**
16
+	 *  Load the template files from within sensei/templates/ or the the theme if overrided within the theme.
17
+	 *
18
+	 * @since 1.9.0
19
+	 * @param string $slug
20
+	 * @param string $name default: ''
21
+	 *
22
+	 * @return void
23
+	 */
24
+	public static function get_part(  $slug, $name = ''  ){
25 25
 
26
-        $template = '';
27
-        $plugin_template_url = Sensei()->template_url;
28
-        $plugin_template_path = Sensei()->plugin_path() . "/templates/";
26
+		$template = '';
27
+		$plugin_template_url = Sensei()->template_url;
28
+		$plugin_template_path = Sensei()->plugin_path() . "/templates/";
29 29
 
30
-        // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php
31
-        if ( $name ){
30
+		// Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php
31
+		if ( $name ){
32 32
 
33
-            $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) );
33
+			$template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) );
34 34
 
35
-        }
35
+		}
36 36
 
37
-        // Get default slug-name.php
38
-        if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){
37
+		// Get default slug-name.php
38
+		if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){
39 39
 
40
-            $template = $plugin_template_path . "{$slug}-{$name}.php";
40
+			$template = $plugin_template_path . "{$slug}-{$name}.php";
41 41
 
42
-        }
42
+		}
43 43
 
44 44
 
45
-        // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php
46
-        if ( !$template ){
45
+		// If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php
46
+		if ( !$template ){
47 47
 
48
-            $template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) );
48
+			$template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) );
49 49
 
50
-        }
50
+		}
51 51
 
52 52
 
53
-        if ( $template ){
53
+		if ( $template ){
54 54
 
55
-            load_template( $template, false );
55
+			load_template( $template, false );
56 56
 
57
-        }
57
+		}
58 58
 
59
-    } // end get part
59
+	} // end get part
60 60
 
61
-    /**
62
-     * Get the template.
63
-     *
64
-     * @since 1.9.0
65
-     *
66
-     * @param $template_name
67
-     * @param array $args
68
-     * @param string $template_path
69
-     * @param string $default_path
70
-     */
71
-    public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
61
+	/**
62
+	 * Get the template.
63
+	 *
64
+	 * @since 1.9.0
65
+	 *
66
+	 * @param $template_name
67
+	 * @param array $args
68
+	 * @param string $template_path
69
+	 * @param string $default_path
70
+	 */
71
+	public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
72 72
 
73
-        if ( $args && is_array($args) )
74
-            extract( $args );
73
+		if ( $args && is_array($args) )
74
+			extract( $args );
75 75
 
76
-        $located = self::locate_template( $template_name, $template_path, $default_path );
76
+		$located = self::locate_template( $template_name, $template_path, $default_path );
77 77
 
78
-        if( ! empty( $located ) ){
78
+		if( ! empty( $located ) ){
79 79
 
80
-            do_action( 'sensei_before_template_part', $template_name, $template_path, $located );
80
+			do_action( 'sensei_before_template_part', $template_name, $template_path, $located );
81 81
 
82
-            include( $located );
82
+			include( $located );
83 83
 
84
-            do_action( 'sensei_after_template_part', $template_name, $template_path, $located );
84
+			do_action( 'sensei_after_template_part', $template_name, $template_path, $located );
85 85
 
86
-        }
86
+		}
87 87
 
88
-    } // end get template
88
+	} // end get template
89 89
 
90
-    /**
91
-     * Check if the template file exists. A wrapper for WP locate_template.
92
-     *
93
-     * @since 1.9.0
94
-     *
95
-     * @param $template_name
96
-     * @param string $template_path
97
-     * @param string $default_path
98
-     *
99
-     * @return mixed|void
100
-     */
101
-    public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
90
+	/**
91
+	 * Check if the template file exists. A wrapper for WP locate_template.
92
+	 *
93
+	 * @since 1.9.0
94
+	 *
95
+	 * @param $template_name
96
+	 * @param string $template_path
97
+	 * @param string $default_path
98
+	 *
99
+	 * @return mixed|void
100
+	 */
101
+	public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
102 102
 
103
-        if ( ! $template_path ) $template_path = Sensei()->template_url;
104
-        if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
103
+		if ( ! $template_path ) $template_path = Sensei()->template_url;
104
+		if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
105 105
 
106
-        // Look within passed path within the theme - this is priority
107
-        $template = locate_template(
108
-            array(
109
-                $template_path . $template_name,
110
-                $template_name
111
-            )
112
-        );
106
+		// Look within passed path within the theme - this is priority
107
+		$template = locate_template(
108
+			array(
109
+				$template_path . $template_name,
110
+				$template_name
111
+			)
112
+		);
113 113
 
114
-        // Get default template
115
-        if ( ! $template ){
114
+		// Get default template
115
+		if ( ! $template ){
116 116
 
117
-            $template = $default_path . $template_name;
117
+			$template = $default_path . $template_name;
118 118
 
119
-        }
120
-        // return nothing for file that do not exist
121
-        if( !file_exists( $template ) ){
122
-            $template = '';
123
-        }
119
+		}
120
+		// return nothing for file that do not exist
121
+		if( !file_exists( $template ) ){
122
+			$template = '';
123
+		}
124 124
 
125
-        // Return what we found
126
-        return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path );
125
+		// Return what we found
126
+		return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path );
127 127
 
128
-    } // end locate
128
+	} // end locate
129 129
 
130
-    /**
131
-     * Determine which Sensei template to load based on the
132
-     * current page context.
133
-     *
134
-     * @since 1.0
135
-     *
136
-     * @param string $template
137
-     * @return string $template
138
-     */
139
-    public static function template_loader ( $template = '' ) {
130
+	/**
131
+	 * Determine which Sensei template to load based on the
132
+	 * current page context.
133
+	 *
134
+	 * @since 1.0
135
+	 *
136
+	 * @param string $template
137
+	 * @return string $template
138
+	 */
139
+	public static function template_loader ( $template = '' ) {
140 140
 
141
-        global $wp_query, $email_template;
141
+		global $wp_query, $email_template;
142 142
 
143
-        $find = array( 'woothemes-sensei.php' );
144
-        $file = '';
143
+		$find = array( 'woothemes-sensei.php' );
144
+		$file = '';
145 145
 
146
-        if ( isset( $email_template ) && $email_template ) {
146
+		if ( isset( $email_template ) && $email_template ) {
147 147
 
148
-            $file 	= 'emails/' . $email_template;
149
-            $find[] = $file;
150
-            $find[] = Sensei()->template_url . $file;
148
+			$file 	= 'emails/' . $email_template;
149
+			$find[] = $file;
150
+			$find[] = Sensei()->template_url . $file;
151 151
 
152
-        } elseif ( is_single() && get_post_type() == 'course' ) {
152
+		} elseif ( is_single() && get_post_type() == 'course' ) {
153 153
 
154
-            if ( Sensei()->check_user_permissions( 'course-single' ) ) {
154
+			if ( Sensei()->check_user_permissions( 'course-single' ) ) {
155 155
 
156
-                // possible backward compatible template include if theme overrides content-single-course.php
157
-                // this template was removed in 1.9.0 and code all moved into the main single-course.php file
158
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true );
156
+				// possible backward compatible template include if theme overrides content-single-course.php
157
+				// this template was removed in 1.9.0 and code all moved into the main single-course.php file
158
+				self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true );
159 159
 
160
-                $file 	= 'single-course.php';
161
-                $find[] = $file;
162
-                $find[] = Sensei()->template_url . $file;
160
+				$file 	= 'single-course.php';
161
+				$find[] = $file;
162
+				$find[] = Sensei()->template_url . $file;
163 163
 
164
-            } else {
164
+			} else {
165 165
 
166
-                // No Permissions Page
167
-                return self::get_no_permission_template();
166
+				// No Permissions Page
167
+				return self::get_no_permission_template();
168 168
 
169
-            } // End If Statement
169
+			} // End If Statement
170 170
 
171
-        } elseif ( is_single() && get_post_type() == 'lesson' ) {
171
+		} elseif ( is_single() && get_post_type() == 'lesson' ) {
172 172
 
173
-            if ( Sensei()->check_user_permissions( 'lesson-single' ) ) {
173
+			if ( Sensei()->check_user_permissions( 'lesson-single' ) ) {
174 174
 
175
-                // possible backward compatible template include if theme overrides content-single-lesson.php
176
-                // this template was removed in 1.9.0 and code all moved into the main single-lesson.php file
177
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true );
175
+				// possible backward compatible template include if theme overrides content-single-lesson.php
176
+				// this template was removed in 1.9.0 and code all moved into the main single-lesson.php file
177
+				self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true );
178 178
 
179
-                $file 	= 'single-lesson.php';
180
-                $find[] = $file;
181
-                $find[] = Sensei()->template_url . $file;
179
+				$file 	= 'single-lesson.php';
180
+				$find[] = $file;
181
+				$find[] = Sensei()->template_url . $file;
182 182
 
183
-            } else {
183
+			} else {
184 184
 
185
-                // No Permissions Page
186
-                return self::get_no_permission_template();
185
+				// No Permissions Page
186
+				return self::get_no_permission_template();
187 187
 
188
-            } // End If Statement
188
+			} // End If Statement
189 189
 
190
-        } elseif ( is_single() && get_post_type() == 'quiz' ) {
190
+		} elseif ( is_single() && get_post_type() == 'quiz' ) {
191 191
 
192
-            if ( Sensei()->check_user_permissions( 'quiz-single' ) ) {
192
+			if ( Sensei()->check_user_permissions( 'quiz-single' ) ) {
193 193
 
194
-                // possible backward compatible template include if theme overrides content-single-quiz.php
195
-                // this template was removed in 1.9.0 and code all moved into the main single-quiz.php file
196
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true);
194
+				// possible backward compatible template include if theme overrides content-single-quiz.php
195
+				// this template was removed in 1.9.0 and code all moved into the main single-quiz.php file
196
+				self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true);
197 197
 
198
-                $file 	= 'single-quiz.php';
199
-                $find[] = $file;
200
-                $find[] = Sensei()->template_url . $file;
198
+				$file 	= 'single-quiz.php';
199
+				$find[] = $file;
200
+				$find[] = Sensei()->template_url . $file;
201 201
 
202
-            } else {
202
+			} else {
203 203
 
204
-                // No Permissions Page
205
-                return self::get_no_permission_template();
204
+				// No Permissions Page
205
+				return self::get_no_permission_template();
206 206
 
207
-            } // End If Statement
207
+			} // End If Statement
208 208
 
209
-        } elseif ( is_single() && get_post_type() == 'sensei_message' ) {
209
+		} elseif ( is_single() && get_post_type() == 'sensei_message' ) {
210 210
 
211
-            // possible backward compatible template include if theme overrides content-single-message.php
212
-            // this template was removed in 1.9.0 and code all moved into the main single-message.php file
213
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true );
211
+			// possible backward compatible template include if theme overrides content-single-message.php
212
+			// this template was removed in 1.9.0 and code all moved into the main single-message.php file
213
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true );
214 214
 
215
-            $file 	= 'single-message.php';
216
-            $find[] = $file;
217
-            $find[] = Sensei()->template_url . $file;
215
+			$file 	= 'single-message.php';
216
+			$find[] = $file;
217
+			$find[] = Sensei()->template_url . $file;
218 218
 
219
-        } elseif ( is_post_type_archive( 'course' )
220
-                    || is_page( Sensei()->get_page_id( 'courses' ) )
221
-                    || is_tax( 'course-category' )) {
219
+		} elseif ( is_post_type_archive( 'course' )
220
+					|| is_page( Sensei()->get_page_id( 'courses' ) )
221
+					|| is_tax( 'course-category' )) {
222 222
 
223
-            // possible backward compatible template include if theme overrides 'taxonomy-course-category'
224
-            // this template was removed in 1.9.0 and replaced by archive-course.php
225
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php');
223
+			// possible backward compatible template include if theme overrides 'taxonomy-course-category'
224
+			// this template was removed in 1.9.0 and replaced by archive-course.php
225
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php');
226 226
 
227
-            $file 	= 'archive-course.php';
228
-            $find[] = $file;
229
-            $find[] = Sensei()->template_url . $file;
227
+			$file 	= 'archive-course.php';
228
+			$find[] = $file;
229
+			$find[] = Sensei()->template_url . $file;
230 230
 
231
-        } elseif ( is_post_type_archive( 'sensei_message' ) ) {
231
+		} elseif ( is_post_type_archive( 'sensei_message' ) ) {
232 232
 
233
-            $file 	= 'archive-message.php';
234
-            $find[] = $file;
235
-            $find[] = Sensei()->template_url . $file;
233
+			$file 	= 'archive-message.php';
234
+			$find[] = $file;
235
+			$find[] = Sensei()->template_url . $file;
236 236
 
237
-        } elseif( is_tax( 'lesson-tag' ) ) {
237
+		} elseif( is_tax( 'lesson-tag' ) ) {
238 238
 
239
-            // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php'
240
-            // this template was removed in 1.9.0 and replaced by archive-lesson.php
241
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' );
239
+			// possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php'
240
+			// this template was removed in 1.9.0 and replaced by archive-lesson.php
241
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' );
242 242
 
243
-            $file 	= 'archive-lesson.php';
244
-            $find[] = $file;
245
-            $find[] = Sensei()->template_url . $file;
243
+			$file 	= 'archive-lesson.php';
244
+			$find[] = $file;
245
+			$find[] = Sensei()->template_url . $file;
246 246
 
247
-        } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) {
247
+		} elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) {
248 248
 
249
-            // Override for sites with static home page
250
-            $wp_query->is_home = false;
249
+			// Override for sites with static home page
250
+			$wp_query->is_home = false;
251 251
 
252
-            $file 	= 'learner-profile.php';
253
-            $find[] = $file;
254
-            $find[] = Sensei()->template_url . $file;
252
+			$file 	= 'learner-profile.php';
253
+			$find[] = $file;
254
+			$find[] = Sensei()->template_url . $file;
255 255
 
256
-        } elseif ( isset( $wp_query->query_vars['course_results'] ) ) {
256
+		} elseif ( isset( $wp_query->query_vars['course_results'] ) ) {
257 257
 
258
-            // Override for sites with static home page
259
-            $wp_query->is_home = false;
258
+			// Override for sites with static home page
259
+			$wp_query->is_home = false;
260 260
 
261
-            $file = 'course-results.php';
262
-            $find[] = $file;
263
-            $find[] = Sensei()->template_url . $file;
261
+			$file = 'course-results.php';
262
+			$find[] = $file;
263
+			$find[] = Sensei()->template_url . $file;
264 264
 
265
-        }elseif( is_author()
266
-                 && Sensei_Teacher::is_a_teacher( get_query_var('author') )
267
-                 && ! user_can( get_query_var('author'), 'manage_options' ) ){
265
+		}elseif( is_author()
266
+				 && Sensei_Teacher::is_a_teacher( get_query_var('author') )
267
+				 && ! user_can( get_query_var('author'), 'manage_options' ) ){
268 268
 
269
-            $file = 'teacher-archive.php';
270
-            $find[] = $file;
271
-            $find[] = Sensei()->template_url . $file;
269
+			$file = 'teacher-archive.php';
270
+			$find[] = $file;
271
+			$find[] = Sensei()->template_url . $file;
272 272
 
273
-        } // Load the template file
273
+		} // Load the template file
274 274
 
275
-        if ( $file ) {
275
+		if ( $file ) {
276 276
 
277
-            $template = locate_template( $find );
278
-            if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
277
+			$template = locate_template( $find );
278
+			if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
279 279
 
280
-        } // End If Statement
280
+		} // End If Statement
281 281
 
282
-        return $template;
282
+		return $template;
283 283
 
284
-    } // End template_loader()
284
+	} // End template_loader()
285 285
 
286
-    /**
287
-     * This function loads the no-permissions template for users with no access
288
-     * if a Sensei template was loaded.
289
-     *
290
-     * This function doesn't determine the permissions. Permissions must be determined
291
-     * before loading this function as it only gets the template.
292
-     *
293
-     * This function also checks the user theme for overrides to ensure the right template
294
-     * file is returned.
295
-     *
296
-     * @since 1.9.0
297
-     */
298
-    public static function get_no_permission_template( ){
286
+	/**
287
+	 * This function loads the no-permissions template for users with no access
288
+	 * if a Sensei template was loaded.
289
+	 *
290
+	 * This function doesn't determine the permissions. Permissions must be determined
291
+	 * before loading this function as it only gets the template.
292
+	 *
293
+	 * This function also checks the user theme for overrides to ensure the right template
294
+	 * file is returned.
295
+	 *
296
+	 * @since 1.9.0
297
+	 */
298
+	public static function get_no_permission_template( ){
299 299
 
300
-        // possible backward compatible template loading
301
-        // this template was removed in 1.9.0 and code all moved into the no-permissions.php file
302
-        self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true );
300
+		// possible backward compatible template loading
301
+		// this template was removed in 1.9.0 and code all moved into the no-permissions.php file
302
+		self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true );
303 303
 
304
-        $file 	= 'no-permissions.php';
305
-        $find[] = $file;
306
-        $find[] = Sensei()->template_url . $file;
304
+		$file 	= 'no-permissions.php';
305
+		$find[] = $file;
306
+		$find[] = Sensei()->template_url . $file;
307 307
 
308
-        $template = locate_template( $find );
309
-        if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
308
+		$template = locate_template( $find );
309
+		if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
310 310
 
311
-	    // set a global constant so that we know that we're in this template
312
-	    define('SENSEI_NO_PERMISSION', true );
311
+		// set a global constant so that we know that we're in this template
312
+		define('SENSEI_NO_PERMISSION', true );
313 313
 
314
-        return $template;
314
+		return $template;
315 315
 
316
-    }
316
+	}
317 317
 
318
-    /**
319
-     * This function is specifically created for loading template files from the theme.
320
-     *
321
-     * This function checks if the user has overwritten the templates like in their theme. If they have it in their theme it will load the header and the footer
322
-     * around the singular content file from their theme and exit.
323
-     *
324
-     * If none is found this function will do nothing. If a template is found this funciton
325
-     * will exit execution of the script an not continue.
326
-     *
327
-     * @since 1.9.0
328
-     * @param string $template
329
-     * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true
330
-     */
331
-    public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){
318
+	/**
319
+	 * This function is specifically created for loading template files from the theme.
320
+	 *
321
+	 * This function checks if the user has overwritten the templates like in their theme. If they have it in their theme it will load the header and the footer
322
+	 * around the singular content file from their theme and exit.
323
+	 *
324
+	 * If none is found this function will do nothing. If a template is found this funciton
325
+	 * will exit execution of the script an not continue.
326
+	 *
327
+	 * @since 1.9.0
328
+	 * @param string $template
329
+	 * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true
330
+	 */
331
+	public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){
332 332
 
333
-        $found_template = locate_template( array( $template ) );
334
-        if( $found_template ){
333
+		$found_template = locate_template( array( $template ) );
334
+		if( $found_template ){
335 335
 
336
-            if( $load_header_footer ){
336
+			if( $load_header_footer ){
337 337
 
338
-                get_sensei_header();
339
-                include( $found_template );
340
-                get_sensei_footer();
341
-
342
-            }else{
343
-
344
-                include( $found_template );
345
-
346
-            }
347
-
348
-            exit;
349
-
350
-        }
338
+				get_sensei_header();
339
+				include( $found_template );
340
+				get_sensei_footer();
341
+
342
+			}else{
343
+
344
+				include( $found_template );
345
+
346
+			}
347
+
348
+			exit;
349
+
350
+		}
351 351
 
352
-    }
352
+	}
353 353
 
354 354
 
355
-    /**
356
-     * Hooks the deprecated archive content hook into the hook again just in
357
-     * case other developers have used it.
358
-     *
359
-     * @deprecated since 1.9.0
360
-     */
361
-    public static function deprecated_archive_course_content_hook(){
362
-
363
-        sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' );
355
+	/**
356
+	 * Hooks the deprecated archive content hook into the hook again just in
357
+	 * case other developers have used it.
358
+	 *
359
+	 * @deprecated since 1.9.0
360
+	 */
361
+	public static function deprecated_archive_course_content_hook(){
362
+
363
+		sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' );
364 364
 
365
-    }// end deprecated_archive_hook
365
+	}// end deprecated_archive_hook
366 366
 
367
-    /**
368
-     * A generic function for echoing the post title
369
-     *
370
-     * @since 1.9.0
371
-     * @param  WP_Post $post
372
-     */
373
-    public static function the_title( $post ){
374
-
375
-        // ID passed in
376
-        if( is_numeric( $post ) ){
377
-            $post = get_post( $post );
378
-        }
379
-
380
-        /**
381
-         * Filter the template html tag for the title
382
-         *
383
-         * @since 1.9.0
384
-         *
385
-         * @param $title_html_tag default is 'h3'
386
-         */
387
-        $title_html_tag = apply_filters('sensei_the_title_html_tag','h3');
388
-
389
-        /**
390
-         * Filter the title classes
391
-         *
392
-         * @since 1.9.0
393
-         * @param string $title_classes defaults to $post_type-title
394
-         */
395
-        $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' );
367
+	/**
368
+	 * A generic function for echoing the post title
369
+	 *
370
+	 * @since 1.9.0
371
+	 * @param  WP_Post $post
372
+	 */
373
+	public static function the_title( $post ){
374
+
375
+		// ID passed in
376
+		if( is_numeric( $post ) ){
377
+			$post = get_post( $post );
378
+		}
379
+
380
+		/**
381
+		 * Filter the template html tag for the title
382
+		 *
383
+		 * @since 1.9.0
384
+		 *
385
+		 * @param $title_html_tag default is 'h3'
386
+		 */
387
+		$title_html_tag = apply_filters('sensei_the_title_html_tag','h3');
388
+
389
+		/**
390
+		 * Filter the title classes
391
+		 *
392
+		 * @since 1.9.0
393
+		 * @param string $title_classes defaults to $post_type-title
394
+		 */
395
+		$title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' );
396 396
 
397
-        $html= '';
398
-        $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >';
399
-        $html .= '<a href="' . get_permalink( $post->ID ) . '" >';
400
-        $html .= $post->post_title ;
401
-        $html .= '</a>';
402
-        $html .= '</'. $title_html_tag. '>';
403
-        echo $html;
404
-
405
-    }// end the title
406
-
407
-    /**
408
-     * This function adds the hooks inside and above the single course content for
409
-     * backwards compatibility sake.
410
-     *
411
-     * @since 1.9.0
412
-     * @deprecated 1.9.0
413
-     */
414
-    public static function deprecated_single_course_inside_before_hooks(){
415
-
416
-        sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
417
-        sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' );
418
-        sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' );
419
-
420
-    }// end deprecated_single_course_inside_before_hooks
421
-
422
-    /**
423
-     * This function adds the hooks to sensei_course_single_lessons for
424
-     * backwards compatibility sake.  and provides developers with an alternative.
425
-     *
426
-     * @since 1.9.0
427
-     * @deprecated 1.9.0
428
-     */
429
-    public static function deprecate_sensei_course_single_lessons_hook(){
397
+		$html= '';
398
+		$html .= '<'. $title_html_tag .' class="'. $title_classes .'" >';
399
+		$html .= '<a href="' . get_permalink( $post->ID ) . '" >';
400
+		$html .= $post->post_title ;
401
+		$html .= '</a>';
402
+		$html .= '</'. $title_html_tag. '>';
403
+		echo $html;
404
+
405
+	}// end the title
406
+
407
+	/**
408
+	 * This function adds the hooks inside and above the single course content for
409
+	 * backwards compatibility sake.
410
+	 *
411
+	 * @since 1.9.0
412
+	 * @deprecated 1.9.0
413
+	 */
414
+	public static function deprecated_single_course_inside_before_hooks(){
415
+
416
+		sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
417
+		sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' );
418
+		sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' );
419
+
420
+	}// end deprecated_single_course_inside_before_hooks
421
+
422
+	/**
423
+	 * This function adds the hooks to sensei_course_single_lessons for
424
+	 * backwards compatibility sake.  and provides developers with an alternative.
425
+	 *
426
+	 * @since 1.9.0
427
+	 * @deprecated 1.9.0
428
+	 */
429
+	public static function deprecate_sensei_course_single_lessons_hook(){
430 430
 
431
-        sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after');
431
+		sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after');
432 432
 
433
-    }// deprecate_sensei_course_single_lessons_hook
433
+	}// deprecate_sensei_course_single_lessons_hook
434 434
 
435
-    /**
436
-     * Deprecated all deprecated_single_main_content_hook hooked actions.
437
-     *
438
-     * The content must be dealt with inside the respective templates.
439
-     *
440
-     * @since 1.9.0
441
-     * @deprecated 1.9.0
442
-     */
443
-    public static function deprecated_single_main_content_hook(){
435
+	/**
436
+	 * Deprecated all deprecated_single_main_content_hook hooked actions.
437
+	 *
438
+	 * The content must be dealt with inside the respective templates.
439
+	 *
440
+	 * @since 1.9.0
441
+	 * @deprecated 1.9.0
442
+	 */
443
+	public static function deprecated_single_main_content_hook(){
444 444
 
445
-            if( is_singular( 'course' ) ) {
445
+			if( is_singular( 'course' ) ) {
446 446
 
447
-                sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after');
448
-
449
-            } elseif( is_singular( 'message' ) ){
450
-
451
-                sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after');
452
-            }
453
-
454
-    }// end deprecated_single_course_single_main_content_hook
455
-
456
-    /**
457
-     * Deprecate the  old sensei modules
458
-     * @since 1.9.0
459
-     * @deprecated since 1.9.0
460
-     */
461
-    public static function deprecate_module_before_hook(){
447
+				sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after');
448
+
449
+			} elseif( is_singular( 'message' ) ){
450
+
451
+				sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after');
452
+			}
453
+
454
+	}// end deprecated_single_course_single_main_content_hook
455
+
456
+	/**
457
+	 * Deprecate the  old sensei modules
458
+	 * @since 1.9.0
459
+	 * @deprecated since 1.9.0
460
+	 */
461
+	public static function deprecate_module_before_hook(){
462 462
 
463
-        sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' );
463
+		sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' );
464 464
 
465
-    }
466
-
467
-    /**
468
-     * Deprecate the  old sensei modules after hooks
469
-     * @since 1.9.0
470
-     * @deprecated since 1.9.0
471
-     */
472
-    public static function deprecate_module_after_hook(){
465
+	}
466
+
467
+	/**
468
+	 * Deprecate the  old sensei modules after hooks
469
+	 * @since 1.9.0
470
+	 * @deprecated since 1.9.0
471
+	 */
472
+	public static function deprecate_module_after_hook(){
473 473
 
474
-        sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' );
474
+		sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' );
475 475
 
476
-    }
476
+	}
477 477
 
478
-    /**
479
-     * Deprecate the single message hooks for post types.
480
-     *
481
-     * @since 1.9.0
482
-     * @deprecated since 1.9.0
483
-     */
484
-    public static function deprecate_all_post_type_single_title_hooks(){
478
+	/**
479
+	 * Deprecate the single message hooks for post types.
480
+	 *
481
+	 * @since 1.9.0
482
+	 * @deprecated since 1.9.0
483
+	 */
484
+	public static function deprecate_all_post_type_single_title_hooks(){
485 485
 
486
-        if( is_singular( 'sensei_message' ) ){
486
+		if( is_singular( 'sensei_message' ) ){
487 487
 
488
-            sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' );
488
+			sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' );
489 489
 
490
-        }
490
+		}
491 491
 
492
-    }
492
+	}
493 493
 
494
-    /**
495
-     * course_single_meta function.
496
-     *
497
-     * @access public
498
-     * @return void
499
-     * @deprecated since 1.9.0
500
-     */
501
-    public static function deprecate_course_single_meta_hooks() {
494
+	/**
495
+	 * course_single_meta function.
496
+	 *
497
+	 * @access public
498
+	 * @return void
499
+	 * @deprecated since 1.9.0
500
+	 */
501
+	public static function deprecate_course_single_meta_hooks() {
502 502
 
503
-        // deprecate all these hooks
504
-        sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' );
505
-        sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' );
506
-        sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' );
507
-        sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' );
503
+		// deprecate all these hooks
504
+		sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' );
505
+		sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' );
506
+		sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' );
507
+		sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' );
508 508
 
509
-    } // End deprecate_course_single_meta_hooks
509
+	} // End deprecate_course_single_meta_hooks
510 510
 
511
-    /**
512
-     * Run the deprecated hooks on the single lesson page
513
-     * @deprecated since 1.9.0
514
-     */
515
-    public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() {
511
+	/**
512
+	 * Run the deprecated hooks on the single lesson page
513
+	 * @deprecated since 1.9.0
514
+	 */
515
+	public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() {
516 516
 
517
-        if( is_singular( 'lesson' ) ){
517
+		if( is_singular( 'lesson' ) ){
518 518
 
519
-            sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content',  get_the_ID() );
520
-            sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content',  get_the_ID() );
519
+			sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content',  get_the_ID() );
520
+			sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content',  get_the_ID() );
521 521
 
522
-        }
522
+		}
523 523
 
524
-    }// end sensei_deprecate_single_lesson_breadcrumbs_and_comments_hooks
524
+	}// end sensei_deprecate_single_lesson_breadcrumbs_and_comments_hooks
525 525
 
526
-    /**
527
-     * Deprecate the hook sensei_lesson_course_signup.
528
-     *
529
-     * The hook content will be linked directly on the recommended
530
-     * sensei_single_lesson_content_inside_after
531
-     *
532
-     * @deprecated since 1.9.0
533
-     */
534
-    public static function deprecate_sensei_lesson_course_signup_hook(){
526
+	/**
527
+	 * Deprecate the hook sensei_lesson_course_signup.
528
+	 *
529
+	 * The hook content will be linked directly on the recommended
530
+	 * sensei_single_lesson_content_inside_after
531
+	 *
532
+	 * @deprecated since 1.9.0
533
+	 */
534
+	public static function deprecate_sensei_lesson_course_signup_hook(){
535 535
 
536
-        $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true );
537
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
536
+		$lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true );
537
+		$user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
538 538
 
539
-        if(  !$user_taking_course ) {
539
+		if(  !$user_taking_course ) {
540 540
 
541
-            sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id );
541
+			sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id );
542 542
 
543
-        }
544
-    }// end deprecate_sensei_lesson_course_signup_hook
543
+		}
544
+	}// end deprecate_sensei_lesson_course_signup_hook
545 545
 
546
-    /**
547
-     * Running the deprecated hook: sensei_lesson_single_meta
548
-     *
549
-     * @since 1.9.0
550
-     * @deprecated since 1.9.0
551
-     */
552
-    public static function deprecate_sensei_lesson_single_meta_hook(){
546
+	/**
547
+	 * Running the deprecated hook: sensei_lesson_single_meta
548
+	 *
549
+	 * @since 1.9.0
550
+	 * @deprecated since 1.9.0
551
+	 */
552
+	public static function deprecate_sensei_lesson_single_meta_hook(){
553 553
 
554
-        if ( sensei_can_user_view_lesson()  ) {
554
+		if ( sensei_can_user_view_lesson()  ) {
555 555
 
556
-            sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' );
556
+			sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' );
557 557
 
558 558
 
559
-        }
559
+		}
560 560
 
561
-    }// end deprecate_sensei_lesson_single_meta_hook
561
+	}// end deprecate_sensei_lesson_single_meta_hook
562 562
 
563
-    /**
564
-     * Deprecate the sensei lesson single title hook
565
-     * @deprecated since 1.9.0
566
-     */
567
-    public static function deprecate_sensei_lesson_single_title(){
563
+	/**
564
+	 * Deprecate the sensei lesson single title hook
565
+	 * @deprecated since 1.9.0
566
+	 */
567
+	public static function deprecate_sensei_lesson_single_title(){
568 568
 
569
-        sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
569
+		sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
570 570
 
571
-    }// end deprecate_sensei_lesson_single_title
571
+	}// end deprecate_sensei_lesson_single_title
572 572
 
573
-    /**
574
-     * hook in the deperecated single main content to the lesson
575
-     * @deprecated since 1.9.0
576
-     */
577
-    public  static function deprecate_lesson_single_main_content_hook(){
573
+	/**
574
+	 * hook in the deperecated single main content to the lesson
575
+	 * @deprecated since 1.9.0
576
+	 */
577
+	public  static function deprecate_lesson_single_main_content_hook(){
578 578
 
579
-        sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' );
579
+		sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' );
580 580
 
581
-    }// end sensei_deprecate_lesson_single_main_content_hook
581
+	}// end sensei_deprecate_lesson_single_main_content_hook
582 582
 
583
-    /**
584
-     * hook in the deperecated single main content to the lesson
585
-     * @deprecated since 1.9.0
586
-     */
587
-    public  static function deprecate_lesson_image_hook(){
583
+	/**
584
+	 * hook in the deperecated single main content to the lesson
585
+	 * @deprecated since 1.9.0
586
+	 */
587
+	public  static function deprecate_lesson_image_hook(){
588 588
 
589
-        sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
589
+		sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
590 590
 
591
-    }// end sensei_deprecate_lesson_single_main_content_hook
591
+	}// end sensei_deprecate_lesson_single_main_content_hook
592 592
 
593
-    /**
594
-     * hook in the deprecated sensei_login_form hook for backwards
595
-     * compatibility
596
-     *
597
-     * @since 1.9.0
598
-     * @deprecated since 1.9.0
599
-     */
600
-    public static function deprecate_sensei_login_form_hook(){
593
+	/**
594
+	 * hook in the deprecated sensei_login_form hook for backwards
595
+	 * compatibility
596
+	 *
597
+	 * @since 1.9.0
598
+	 * @deprecated since 1.9.0
599
+	 */
600
+	public static function deprecate_sensei_login_form_hook(){
601 601
 
602
-        sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' );
602
+		sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' );
603 603
 
604
-    } // end deprecate_sensei_login_form_hook
604
+	} // end deprecate_sensei_login_form_hook
605 605
 
606
-    /**
607
-     * Fire the sensei_complete_course action.
608
-     *
609
-     * This is just a backwards compatible function to add the action
610
-     * to a template. This should not be used as the function from this
611
-     * hook will be added directly to my-courses page via one of the hooks there.
612
-     *
613
-     * @since 1.9.0
614
-     */
615
-    public static function  fire_sensei_complete_course_hook(){
606
+	/**
607
+	 * Fire the sensei_complete_course action.
608
+	 *
609
+	 * This is just a backwards compatible function to add the action
610
+	 * to a template. This should not be used as the function from this
611
+	 * hook will be added directly to my-courses page via one of the hooks there.
612
+	 *
613
+	 * @since 1.9.0
614
+	 */
615
+	public static function  fire_sensei_complete_course_hook(){
616 616
 
617
-        do_action( 'sensei_complete_course' );
617
+		do_action( 'sensei_complete_course' );
618 618
 
619
-    } //fire_sensei_complete_course_hook
619
+	} //fire_sensei_complete_course_hook
620 620
 
621
-    /**
622
-     * Fire the frontend message hook
623
-     *
624
-     * @since 1.9.0
625
-     */
626
-    public static function  fire_frontend_messages_hook(){
621
+	/**
622
+	 * Fire the frontend message hook
623
+	 *
624
+	 * @since 1.9.0
625
+	 */
626
+	public static function  fire_frontend_messages_hook(){
627 627
 
628
-        do_action( 'sensei_frontend_messages' );
628
+		do_action( 'sensei_frontend_messages' );
629 629
 
630
-    }// end sensei_complete_course_action
630
+	}// end sensei_complete_course_action
631 631
 
632
-    /**
633
-     * deprecate the sensei_before_user_course_content hook in favor
634
-     * of sensei_my_courses_content_inside_before.
635
-     *
636
-     * @deprected since 1.9.0
637
-     */
638
-    public static function  deprecate_sensei_before_user_course_content_hook(){
632
+	/**
633
+	 * deprecate the sensei_before_user_course_content hook in favor
634
+	 * of sensei_my_courses_content_inside_before.
635
+	 *
636
+	 * @deprected since 1.9.0
637
+	 */
638
+	public static function  deprecate_sensei_before_user_course_content_hook(){
639 639
 
640
-        sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() );
640
+		sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() );
641 641
 
642
-    }// deprecate_sensei_before_user_course_content_hook
642
+	}// deprecate_sensei_before_user_course_content_hook
643 643
 
644
-    /**
645
-     * deprecate the sensei_before_user_course_content hook in favor
646
-     * of sensei_my_courses_content_inside_after hook.
647
-     *
648
-     * @deprected since 1.9.0
649
-     */
650
-    public static function  deprecate_sensei_after_user_course_content_hook(){
644
+	/**
645
+	 * deprecate the sensei_before_user_course_content hook in favor
646
+	 * of sensei_my_courses_content_inside_after hook.
647
+	 *
648
+	 * @deprected since 1.9.0
649
+	 */
650
+	public static function  deprecate_sensei_after_user_course_content_hook(){
651 651
 
652
-        sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() );
652
+		sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() );
653 653
 
654
-    }// deprecate_sensei_after_user_course_content_hook
654
+	}// deprecate_sensei_after_user_course_content_hook
655 655
 
656
-    /**
657
-     * Deprecate the 2 main hooks on the archive message template
658
-     *
659
-     * @deprecated since 1.9.0
660
-     * @since 1.9.0
661
-     */
662
-    public static function deprecated_archive_message_hooks (){
663
-
664
-        sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' );
665
-        sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' );
656
+	/**
657
+	 * Deprecate the 2 main hooks on the archive message template
658
+	 *
659
+	 * @deprecated since 1.9.0
660
+	 * @since 1.9.0
661
+	 */
662
+	public static function deprecated_archive_message_hooks (){
663
+
664
+		sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' );
665
+		sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' );
666 666
 
667
-    }
667
+	}
668 668
 
669
-    /**
670
-     * Run the sensei_complete_quiz for those still hooking
671
-     * into but deprecated it.
672
-     *
673
-     * @deprecated since 1.9.0
674
-     */
675
-    public static function deprecate_sensei_complete_quiz_action(){
669
+	/**
670
+	 * Run the sensei_complete_quiz for those still hooking
671
+	 * into but deprecated it.
672
+	 *
673
+	 * @deprecated since 1.9.0
674
+	 */
675
+	public static function deprecate_sensei_complete_quiz_action(){
676 676
 
677
-        sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' );
677
+		sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' );
678 678
 
679
-    }
679
+	}
680 680
 
681
-    /**
682
-     * Run the sensei_quiz_question_type action for those still hooing into it, but depreate
683
-     * it to provide user with a better alternative.
684
-     *
685
-     * @deprecated since 1.9.0
686
-     */
687
-    public static function deprecate_sensei_quiz_question_type_action(){
681
+	/**
682
+	 * Run the sensei_quiz_question_type action for those still hooing into it, but depreate
683
+	 * it to provide user with a better alternative.
684
+	 *
685
+	 * @deprecated since 1.9.0
686
+	 */
687
+	public static function deprecate_sensei_quiz_question_type_action(){
688 688
 
689
-        // Question Type
690
-        global $sensei_question_loop;
691
-        $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID);
692
-        sensei_do_deprecated_action('sensei_quiz_question_type', '1.9.0', 'sensei_quiz_question_inside_after', $question_type);
693
-
694
-    }
689
+		// Question Type
690
+		global $sensei_question_loop;
691
+		$question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID);
692
+		sensei_do_deprecated_action('sensei_quiz_question_type', '1.9.0', 'sensei_quiz_question_inside_after', $question_type);
693
+
694
+	}
695 695
 }//end class
Please login to merge, or discard this patch.
Spacing   +155 added lines, -155 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP
2
+if ( ! defined('ABSPATH')) exit; // security check, don't load file outside WP
3 3
 /**
4 4
  * Sensei Template Class
5 5
  *
@@ -21,38 +21,38 @@  discard block
 block discarded – undo
21 21
      *
22 22
      * @return void
23 23
      */
24
-    public static function get_part(  $slug, $name = ''  ){
24
+    public static function get_part($slug, $name = '') {
25 25
 
26 26
         $template = '';
27 27
         $plugin_template_url = Sensei()->template_url;
28
-        $plugin_template_path = Sensei()->plugin_path() . "/templates/";
28
+        $plugin_template_path = Sensei()->plugin_path()."/templates/";
29 29
 
30 30
         // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php
31
-        if ( $name ){
31
+        if ($name) {
32 32
 
33
-            $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) );
33
+            $template = locate_template(array("{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php"));
34 34
 
35 35
         }
36 36
 
37 37
         // Get default slug-name.php
38
-        if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){
38
+        if ( ! $template && $name && file_exists($plugin_template_path."{$slug}-{$name}.php")) {
39 39
 
40
-            $template = $plugin_template_path . "{$slug}-{$name}.php";
40
+            $template = $plugin_template_path."{$slug}-{$name}.php";
41 41
 
42 42
         }
43 43
 
44 44
 
45 45
         // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php
46
-        if ( !$template ){
46
+        if ( ! $template) {
47 47
 
48
-            $template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) );
48
+            $template = locate_template(array("{$slug}.php", "{$plugin_template_url}{$slug}.php"));
49 49
 
50 50
         }
51 51
 
52 52
 
53
-        if ( $template ){
53
+        if ($template) {
54 54
 
55
-            load_template( $template, false );
55
+            load_template($template, false);
56 56
 
57 57
         }
58 58
 
@@ -68,20 +68,20 @@  discard block
 block discarded – undo
68 68
      * @param string $template_path
69 69
      * @param string $default_path
70 70
      */
71
-    public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
71
+    public static function get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
72 72
 
73
-        if ( $args && is_array($args) )
74
-            extract( $args );
73
+        if ($args && is_array($args))
74
+            extract($args);
75 75
 
76
-        $located = self::locate_template( $template_name, $template_path, $default_path );
76
+        $located = self::locate_template($template_name, $template_path, $default_path);
77 77
 
78
-        if( ! empty( $located ) ){
78
+        if ( ! empty($located)) {
79 79
 
80
-            do_action( 'sensei_before_template_part', $template_name, $template_path, $located );
80
+            do_action('sensei_before_template_part', $template_name, $template_path, $located);
81 81
 
82
-            include( $located );
82
+            include($located);
83 83
 
84
-            do_action( 'sensei_after_template_part', $template_name, $template_path, $located );
84
+            do_action('sensei_after_template_part', $template_name, $template_path, $located);
85 85
 
86 86
         }
87 87
 
@@ -98,32 +98,32 @@  discard block
 block discarded – undo
98 98
      *
99 99
      * @return mixed|void
100 100
      */
101
-    public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
101
+    public static function locate_template($template_name, $template_path = '', $default_path = '') {
102 102
 
103
-        if ( ! $template_path ) $template_path = Sensei()->template_url;
104
-        if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
103
+        if ( ! $template_path) $template_path = Sensei()->template_url;
104
+        if ( ! $default_path) $default_path = Sensei()->plugin_path().'/templates/';
105 105
 
106 106
         // Look within passed path within the theme - this is priority
107 107
         $template = locate_template(
108 108
             array(
109
-                $template_path . $template_name,
109
+                $template_path.$template_name,
110 110
                 $template_name
111 111
             )
112 112
         );
113 113
 
114 114
         // Get default template
115
-        if ( ! $template ){
115
+        if ( ! $template) {
116 116
 
117
-            $template = $default_path . $template_name;
117
+            $template = $default_path.$template_name;
118 118
 
119 119
         }
120 120
         // return nothing for file that do not exist
121
-        if( !file_exists( $template ) ){
121
+        if ( ! file_exists($template)) {
122 122
             $template = '';
123 123
         }
124 124
 
125 125
         // Return what we found
126
-        return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path );
126
+        return apply_filters('sensei_locate_template', $template, $template_name, $template_path);
127 127
 
128 128
     } // end locate
129 129
 
@@ -136,30 +136,30 @@  discard block
 block discarded – undo
136 136
      * @param string $template
137 137
      * @return string $template
138 138
      */
139
-    public static function template_loader ( $template = '' ) {
139
+    public static function template_loader($template = '') {
140 140
 
141 141
         global $wp_query, $email_template;
142 142
 
143
-        $find = array( 'woothemes-sensei.php' );
143
+        $find = array('woothemes-sensei.php');
144 144
         $file = '';
145 145
 
146
-        if ( isset( $email_template ) && $email_template ) {
146
+        if (isset($email_template) && $email_template) {
147 147
 
148
-            $file 	= 'emails/' . $email_template;
148
+            $file = 'emails/'.$email_template;
149 149
             $find[] = $file;
150
-            $find[] = Sensei()->template_url . $file;
150
+            $find[] = Sensei()->template_url.$file;
151 151
 
152
-        } elseif ( is_single() && get_post_type() == 'course' ) {
152
+        } elseif (is_single() && get_post_type() == 'course') {
153 153
 
154
-            if ( Sensei()->check_user_permissions( 'course-single' ) ) {
154
+            if (Sensei()->check_user_permissions('course-single')) {
155 155
 
156 156
                 // possible backward compatible template include if theme overrides content-single-course.php
157 157
                 // this template was removed in 1.9.0 and code all moved into the main single-course.php file
158
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true );
158
+                self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-course.php', true);
159 159
 
160
-                $file 	= 'single-course.php';
160
+                $file = 'single-course.php';
161 161
                 $find[] = $file;
162
-                $find[] = Sensei()->template_url . $file;
162
+                $find[] = Sensei()->template_url.$file;
163 163
 
164 164
             } else {
165 165
 
@@ -168,17 +168,17 @@  discard block
 block discarded – undo
168 168
 
169 169
             } // End If Statement
170 170
 
171
-        } elseif ( is_single() && get_post_type() == 'lesson' ) {
171
+        } elseif (is_single() && get_post_type() == 'lesson') {
172 172
 
173
-            if ( Sensei()->check_user_permissions( 'lesson-single' ) ) {
173
+            if (Sensei()->check_user_permissions('lesson-single')) {
174 174
 
175 175
                 // possible backward compatible template include if theme overrides content-single-lesson.php
176 176
                 // this template was removed in 1.9.0 and code all moved into the main single-lesson.php file
177
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true );
177
+                self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-lesson.php', true);
178 178
 
179
-                $file 	= 'single-lesson.php';
179
+                $file = 'single-lesson.php';
180 180
                 $find[] = $file;
181
-                $find[] = Sensei()->template_url . $file;
181
+                $find[] = Sensei()->template_url.$file;
182 182
 
183 183
             } else {
184 184
 
@@ -187,17 +187,17 @@  discard block
 block discarded – undo
187 187
 
188 188
             } // End If Statement
189 189
 
190
-        } elseif ( is_single() && get_post_type() == 'quiz' ) {
190
+        } elseif (is_single() && get_post_type() == 'quiz') {
191 191
 
192
-            if ( Sensei()->check_user_permissions( 'quiz-single' ) ) {
192
+            if (Sensei()->check_user_permissions('quiz-single')) {
193 193
 
194 194
                 // possible backward compatible template include if theme overrides content-single-quiz.php
195 195
                 // this template was removed in 1.9.0 and code all moved into the main single-quiz.php file
196
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true);
196
+                self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-quiz.php', true);
197 197
 
198
-                $file 	= 'single-quiz.php';
198
+                $file = 'single-quiz.php';
199 199
                 $find[] = $file;
200
-                $find[] = Sensei()->template_url . $file;
200
+                $find[] = Sensei()->template_url.$file;
201 201
 
202 202
             } else {
203 203
 
@@ -206,76 +206,76 @@  discard block
 block discarded – undo
206 206
 
207 207
             } // End If Statement
208 208
 
209
-        } elseif ( is_single() && get_post_type() == 'sensei_message' ) {
209
+        } elseif (is_single() && get_post_type() == 'sensei_message') {
210 210
 
211 211
             // possible backward compatible template include if theme overrides content-single-message.php
212 212
             // this template was removed in 1.9.0 and code all moved into the main single-message.php file
213
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true );
213
+            self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-message.php', true);
214 214
 
215
-            $file 	= 'single-message.php';
215
+            $file = 'single-message.php';
216 216
             $find[] = $file;
217
-            $find[] = Sensei()->template_url . $file;
217
+            $find[] = Sensei()->template_url.$file;
218 218
 
219
-        } elseif ( is_post_type_archive( 'course' )
220
-                    || is_page( Sensei()->get_page_id( 'courses' ) )
221
-                    || is_tax( 'course-category' )) {
219
+        } elseif (is_post_type_archive('course')
220
+                    || is_page(Sensei()->get_page_id('courses'))
221
+                    || is_tax('course-category')) {
222 222
 
223 223
             // possible backward compatible template include if theme overrides 'taxonomy-course-category'
224 224
             // this template was removed in 1.9.0 and replaced by archive-course.php
225
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php');
225
+            self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-course-category.php');
226 226
 
227
-            $file 	= 'archive-course.php';
227
+            $file = 'archive-course.php';
228 228
             $find[] = $file;
229
-            $find[] = Sensei()->template_url . $file;
229
+            $find[] = Sensei()->template_url.$file;
230 230
 
231
-        } elseif ( is_post_type_archive( 'sensei_message' ) ) {
231
+        } elseif (is_post_type_archive('sensei_message')) {
232 232
 
233
-            $file 	= 'archive-message.php';
233
+            $file = 'archive-message.php';
234 234
             $find[] = $file;
235
-            $find[] = Sensei()->template_url . $file;
235
+            $find[] = Sensei()->template_url.$file;
236 236
 
237
-        } elseif( is_tax( 'lesson-tag' ) ) {
237
+        } elseif (is_tax('lesson-tag')) {
238 238
 
239 239
             // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php'
240 240
             // this template was removed in 1.9.0 and replaced by archive-lesson.php
241
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' );
241
+            self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-lesson-tag.php');
242 242
 
243
-            $file 	= 'archive-lesson.php';
243
+            $file = 'archive-lesson.php';
244 244
             $find[] = $file;
245
-            $find[] = Sensei()->template_url . $file;
245
+            $find[] = Sensei()->template_url.$file;
246 246
 
247
-        } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) {
247
+        } elseif (isset($wp_query->query_vars['learner_profile'])) {
248 248
 
249 249
             // Override for sites with static home page
250 250
             $wp_query->is_home = false;
251 251
 
252
-            $file 	= 'learner-profile.php';
252
+            $file = 'learner-profile.php';
253 253
             $find[] = $file;
254
-            $find[] = Sensei()->template_url . $file;
254
+            $find[] = Sensei()->template_url.$file;
255 255
 
256
-        } elseif ( isset( $wp_query->query_vars['course_results'] ) ) {
256
+        } elseif (isset($wp_query->query_vars['course_results'])) {
257 257
 
258 258
             // Override for sites with static home page
259 259
             $wp_query->is_home = false;
260 260
 
261 261
             $file = 'course-results.php';
262 262
             $find[] = $file;
263
-            $find[] = Sensei()->template_url . $file;
263
+            $find[] = Sensei()->template_url.$file;
264 264
 
265
-        }elseif( is_author()
266
-                 && Sensei_Teacher::is_a_teacher( get_query_var('author') )
267
-                 && ! user_can( get_query_var('author'), 'manage_options' ) ){
265
+        }elseif (is_author()
266
+                 && Sensei_Teacher::is_a_teacher(get_query_var('author'))
267
+                 && ! user_can(get_query_var('author'), 'manage_options')) {
268 268
 
269 269
             $file = 'teacher-archive.php';
270 270
             $find[] = $file;
271
-            $find[] = Sensei()->template_url . $file;
271
+            $find[] = Sensei()->template_url.$file;
272 272
 
273 273
         } // Load the template file
274 274
 
275
-        if ( $file ) {
275
+        if ($file) {
276 276
 
277
-            $template = locate_template( $find );
278
-            if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
277
+            $template = locate_template($find);
278
+            if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file;
279 279
 
280 280
         } // End If Statement
281 281
 
@@ -295,21 +295,21 @@  discard block
 block discarded – undo
295 295
      *
296 296
      * @since 1.9.0
297 297
      */
298
-    public static function get_no_permission_template( ){
298
+    public static function get_no_permission_template( ) {
299 299
 
300 300
         // possible backward compatible template loading
301 301
         // this template was removed in 1.9.0 and code all moved into the no-permissions.php file
302
-        self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true );
302
+        self::locate_and_load_template_overrides(Sensei()->template_url.'content-no-permissions.php', true);
303 303
 
304
-        $file 	= 'no-permissions.php';
304
+        $file = 'no-permissions.php';
305 305
         $find[] = $file;
306
-        $find[] = Sensei()->template_url . $file;
306
+        $find[] = Sensei()->template_url.$file;
307 307
 
308
-        $template = locate_template( $find );
309
-        if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
308
+        $template = locate_template($find);
309
+        if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file;
310 310
 
311 311
 	    // set a global constant so that we know that we're in this template
312
-	    define('SENSEI_NO_PERMISSION', true );
312
+	    define('SENSEI_NO_PERMISSION', true);
313 313
 
314 314
         return $template;
315 315
 
@@ -328,20 +328,20 @@  discard block
 block discarded – undo
328 328
      * @param string $template
329 329
      * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true
330 330
      */
331
-    public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){
331
+    public static function locate_and_load_template_overrides($template = '', $load_header_footer = false) {
332 332
 
333
-        $found_template = locate_template( array( $template ) );
334
-        if( $found_template ){
333
+        $found_template = locate_template(array($template));
334
+        if ($found_template) {
335 335
 
336
-            if( $load_header_footer ){
336
+            if ($load_header_footer) {
337 337
 
338 338
                 get_sensei_header();
339
-                include( $found_template );
339
+                include($found_template);
340 340
                 get_sensei_footer();
341 341
 
342
-            }else{
342
+            } else {
343 343
 
344
-                include( $found_template );
344
+                include($found_template);
345 345
 
346 346
             }
347 347
 
@@ -358,9 +358,9 @@  discard block
 block discarded – undo
358 358
      *
359 359
      * @deprecated since 1.9.0
360 360
      */
361
-    public static function deprecated_archive_course_content_hook(){
361
+    public static function deprecated_archive_course_content_hook() {
362 362
 
363
-        sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' );
363
+        sensei_do_deprecated_action('sensei_course_archive_main_content', '1.9.0', 'sensei_loop_course_before');
364 364
 
365 365
     }// end deprecated_archive_hook
366 366
 
@@ -370,11 +370,11 @@  discard block
 block discarded – undo
370 370
      * @since 1.9.0
371 371
      * @param  WP_Post $post
372 372
      */
373
-    public static function the_title( $post ){
373
+    public static function the_title($post) {
374 374
 
375 375
         // ID passed in
376
-        if( is_numeric( $post ) ){
377
-            $post = get_post( $post );
376
+        if (is_numeric($post)) {
377
+            $post = get_post($post);
378 378
         }
379 379
 
380 380
         /**
@@ -384,7 +384,7 @@  discard block
 block discarded – undo
384 384
          *
385 385
          * @param $title_html_tag default is 'h3'
386 386
          */
387
-        $title_html_tag = apply_filters('sensei_the_title_html_tag','h3');
387
+        $title_html_tag = apply_filters('sensei_the_title_html_tag', 'h3');
388 388
 
389 389
         /**
390 390
          * Filter the title classes
@@ -392,14 +392,14 @@  discard block
 block discarded – undo
392 392
          * @since 1.9.0
393 393
          * @param string $title_classes defaults to $post_type-title
394 394
          */
395
-        $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' );
395
+        $title_classes = apply_filters('sensei_the_title_classes', $post->post_type.'-title');
396 396
 
397
-        $html= '';
398
-        $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >';
399
-        $html .= '<a href="' . get_permalink( $post->ID ) . '" >';
400
-        $html .= $post->post_title ;
397
+        $html = '';
398
+        $html .= '<'.$title_html_tag.' class="'.$title_classes.'" >';
399
+        $html .= '<a href="'.get_permalink($post->ID).'" >';
400
+        $html .= $post->post_title;
401 401
         $html .= '</a>';
402
-        $html .= '</'. $title_html_tag. '>';
402
+        $html .= '</'.$title_html_tag.'>';
403 403
         echo $html;
404 404
 
405 405
     }// end the title
@@ -411,11 +411,11 @@  discard block
 block discarded – undo
411 411
      * @since 1.9.0
412 412
      * @deprecated 1.9.0
413 413
      */
414
-    public static function deprecated_single_course_inside_before_hooks(){
414
+    public static function deprecated_single_course_inside_before_hooks() {
415 415
 
416
-        sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
417
-        sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' );
418
-        sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' );
416
+        sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', array(get_the_ID()));
417
+        sensei_do_deprecated_action('sensei_course_single_title', '1.9.0', 'sensei_single_course_content_inside_before');
418
+        sensei_do_deprecated_action('sensei_course_single_meta', '1.9.0', 'sensei_single_course_content_inside_before');
419 419
 
420 420
     }// end deprecated_single_course_inside_before_hooks
421 421
 
@@ -426,9 +426,9 @@  discard block
 block discarded – undo
426 426
      * @since 1.9.0
427 427
      * @deprecated 1.9.0
428 428
      */
429
-    public static function deprecate_sensei_course_single_lessons_hook(){
429
+    public static function deprecate_sensei_course_single_lessons_hook() {
430 430
 
431
-        sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after');
431
+        sensei_do_deprecated_action('sensei_course_single_lessons', '1.9.0', 'sensei_single_course_content_inside_after');
432 432
 
433 433
     }// deprecate_sensei_course_single_lessons_hook
434 434
 
@@ -440,13 +440,13 @@  discard block
 block discarded – undo
440 440
      * @since 1.9.0
441 441
      * @deprecated 1.9.0
442 442
      */
443
-    public static function deprecated_single_main_content_hook(){
443
+    public static function deprecated_single_main_content_hook() {
444 444
 
445
-            if( is_singular( 'course' ) ) {
445
+            if (is_singular('course')) {
446 446
 
447 447
                 sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after');
448 448
 
449
-            } elseif( is_singular( 'message' ) ){
449
+            } elseif (is_singular('message')) {
450 450
 
451 451
                 sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after');
452 452
             }
@@ -458,9 +458,9 @@  discard block
 block discarded – undo
458 458
      * @since 1.9.0
459 459
      * @deprecated since 1.9.0
460 460
      */
461
-    public static function deprecate_module_before_hook(){
461
+    public static function deprecate_module_before_hook() {
462 462
 
463
-        sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' );
463
+        sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0', 'sensei_single_course_modules_after');
464 464
 
465 465
     }
466 466
 
@@ -469,9 +469,9 @@  discard block
 block discarded – undo
469 469
      * @since 1.9.0
470 470
      * @deprecated since 1.9.0
471 471
      */
472
-    public static function deprecate_module_after_hook(){
472
+    public static function deprecate_module_after_hook() {
473 473
 
474
-        sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' );
474
+        sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0', 'sensei_single_course_modules_after');
475 475
 
476 476
     }
477 477
 
@@ -481,11 +481,11 @@  discard block
 block discarded – undo
481 481
      * @since 1.9.0
482 482
      * @deprecated since 1.9.0
483 483
      */
484
-    public static function deprecate_all_post_type_single_title_hooks(){
484
+    public static function deprecate_all_post_type_single_title_hooks() {
485 485
 
486
-        if( is_singular( 'sensei_message' ) ){
486
+        if (is_singular('sensei_message')) {
487 487
 
488
-            sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' );
488
+            sensei_do_deprecated_action('sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before');
489 489
 
490 490
         }
491 491
 
@@ -501,10 +501,10 @@  discard block
 block discarded – undo
501 501
     public static function deprecate_course_single_meta_hooks() {
502 502
 
503 503
         // deprecate all these hooks
504
-        sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' );
505
-        sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' );
506
-        sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' );
507
-        sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' );
504
+        sensei_do_deprecated_action('sensei_course_start', '1.9.0', 'sensei_single_course_content_inside_before');
505
+        sensei_do_deprecated_action('sensei_woocommerce_in_cart_message', '1.9.0', 'sensei_single_course_content_inside_before');
506
+        sensei_do_deprecated_action('sensei_course_meta', '1.9.0', 'sensei_single_course_content_inside_before');
507
+        sensei_do_deprecated_action('sensei_course_meta_video', '1.9.0', 'sensei_single_course_content_inside_before');
508 508
 
509 509
     } // End deprecate_course_single_meta_hooks
510 510
 
@@ -514,10 +514,10 @@  discard block
 block discarded – undo
514 514
      */
515 515
     public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() {
516 516
 
517
-        if( is_singular( 'lesson' ) ){
517
+        if (is_singular('lesson')) {
518 518
 
519
-            sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content',  get_the_ID() );
520
-            sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content',  get_the_ID() );
519
+            sensei_do_deprecated_action('sensei_breadcrumb', '1.9.0', 'sensei_after_main_content', get_the_ID());
520
+            sensei_do_deprecated_action('sensei_comments', '1.9.0', 'sensei_after_main_content', get_the_ID());
521 521
 
522 522
         }
523 523
 
@@ -531,14 +531,14 @@  discard block
 block discarded – undo
531 531
      *
532 532
      * @deprecated since 1.9.0
533 533
      */
534
-    public static function deprecate_sensei_lesson_course_signup_hook(){
534
+    public static function deprecate_sensei_lesson_course_signup_hook() {
535 535
 
536
-        $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true );
537
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
536
+        $lesson_course_id = get_post_meta(get_the_ID(), '_lesson_course', true);
537
+        $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id());
538 538
 
539
-        if(  !$user_taking_course ) {
539
+        if ( ! $user_taking_course) {
540 540
 
541
-            sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id );
541
+            sensei_do_deprecated_action('sensei_lesson_course_signup', '1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id);
542 542
 
543 543
         }
544 544
     }// end deprecate_sensei_lesson_course_signup_hook
@@ -549,11 +549,11 @@  discard block
 block discarded – undo
549 549
      * @since 1.9.0
550 550
      * @deprecated since 1.9.0
551 551
      */
552
-    public static function deprecate_sensei_lesson_single_meta_hook(){
552
+    public static function deprecate_sensei_lesson_single_meta_hook() {
553 553
 
554
-        if ( sensei_can_user_view_lesson()  ) {
554
+        if (sensei_can_user_view_lesson()) {
555 555
 
556
-            sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' );
556
+            sensei_do_deprecated_action('sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after');
557 557
 
558 558
 
559 559
         }
@@ -564,9 +564,9 @@  discard block
 block discarded – undo
564 564
      * Deprecate the sensei lesson single title hook
565 565
      * @deprecated since 1.9.0
566 566
      */
567
-    public static function deprecate_sensei_lesson_single_title(){
567
+    public static function deprecate_sensei_lesson_single_title() {
568 568
 
569
-        sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
569
+        sensei_do_deprecated_action('sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID());
570 570
 
571 571
     }// end deprecate_sensei_lesson_single_title
572 572
 
@@ -574,9 +574,9 @@  discard block
 block discarded – undo
574 574
      * hook in the deperecated single main content to the lesson
575 575
      * @deprecated since 1.9.0
576 576
      */
577
-    public  static function deprecate_lesson_single_main_content_hook(){
577
+    public  static function deprecate_lesson_single_main_content_hook() {
578 578
 
579
-        sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' );
579
+        sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before');
580 580
 
581 581
     }// end sensei_deprecate_lesson_single_main_content_hook
582 582
 
@@ -584,9 +584,9 @@  discard block
 block discarded – undo
584 584
      * hook in the deperecated single main content to the lesson
585 585
      * @deprecated since 1.9.0
586 586
      */
587
-    public  static function deprecate_lesson_image_hook(){
587
+    public  static function deprecate_lesson_image_hook() {
588 588
 
589
-        sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
589
+        sensei_do_deprecated_action('sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID());
590 590
 
591 591
     }// end sensei_deprecate_lesson_single_main_content_hook
592 592
 
@@ -597,9 +597,9 @@  discard block
 block discarded – undo
597 597
      * @since 1.9.0
598 598
      * @deprecated since 1.9.0
599 599
      */
600
-    public static function deprecate_sensei_login_form_hook(){
600
+    public static function deprecate_sensei_login_form_hook() {
601 601
 
602
-        sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' );
602
+        sensei_do_deprecated_action('sensei_login_form', '1.9.0', 'sensei_login_form_before');
603 603
 
604 604
     } // end deprecate_sensei_login_form_hook
605 605
 
@@ -612,9 +612,9 @@  discard block
 block discarded – undo
612 612
      *
613 613
      * @since 1.9.0
614 614
      */
615
-    public static function  fire_sensei_complete_course_hook(){
615
+    public static function  fire_sensei_complete_course_hook() {
616 616
 
617
-        do_action( 'sensei_complete_course' );
617
+        do_action('sensei_complete_course');
618 618
 
619 619
     } //fire_sensei_complete_course_hook
620 620
 
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
      *
624 624
      * @since 1.9.0
625 625
      */
626
-    public static function  fire_frontend_messages_hook(){
626
+    public static function  fire_frontend_messages_hook() {
627 627
 
628
-        do_action( 'sensei_frontend_messages' );
628
+        do_action('sensei_frontend_messages');
629 629
 
630 630
     }// end sensei_complete_course_action
631 631
 
@@ -635,9 +635,9 @@  discard block
 block discarded – undo
635 635
      *
636 636
      * @deprected since 1.9.0
637 637
      */
638
-    public static function  deprecate_sensei_before_user_course_content_hook(){
638
+    public static function  deprecate_sensei_before_user_course_content_hook() {
639 639
 
640
-        sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() );
640
+        sensei_do_deprecated_action('sensei_before_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_before', wp_get_current_user());
641 641
 
642 642
     }// deprecate_sensei_before_user_course_content_hook
643 643
 
@@ -647,9 +647,9 @@  discard block
 block discarded – undo
647 647
      *
648 648
      * @deprected since 1.9.0
649 649
      */
650
-    public static function  deprecate_sensei_after_user_course_content_hook(){
650
+    public static function  deprecate_sensei_after_user_course_content_hook() {
651 651
 
652
-        sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() );
652
+        sensei_do_deprecated_action('sensei_after_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_after', wp_get_current_user());
653 653
 
654 654
     }// deprecate_sensei_after_user_course_content_hook
655 655
 
@@ -659,10 +659,10 @@  discard block
 block discarded – undo
659 659
      * @deprecated since 1.9.0
660 660
      * @since 1.9.0
661 661
      */
662
-    public static function deprecated_archive_message_hooks (){
662
+    public static function deprecated_archive_message_hooks() {
663 663
 
664
-        sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' );
665
-        sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' );
664
+        sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop');
665
+        sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop');
666 666
 
667 667
     }
668 668
 
@@ -672,9 +672,9 @@  discard block
 block discarded – undo
672 672
      *
673 673
      * @deprecated since 1.9.0
674 674
      */
675
-    public static function deprecate_sensei_complete_quiz_action(){
675
+    public static function deprecate_sensei_complete_quiz_action() {
676 676
 
677
-        sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' );
677
+        sensei_do_deprecated_action('sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before');
678 678
 
679 679
     }
680 680
 
@@ -684,7 +684,7 @@  discard block
 block discarded – undo
684 684
      *
685 685
      * @deprecated since 1.9.0
686 686
      */
687
-    public static function deprecate_sensei_quiz_question_type_action(){
687
+    public static function deprecate_sensei_quiz_question_type_action() {
688 688
 
689 689
         // Question Type
690 690
         global $sensei_question_loop;
Please login to merge, or discard this patch.
includes/class-sensei-learners-main.php 3 patches
Braces   +6 added lines, -5 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 Learners Overview List Table Class
@@ -409,8 +412,7 @@  discard block
 block discarded – undo
409 412
 		if( $this->lesson_id ) {
410 413
 			$post_id = intval( $this->lesson_id );
411 414
 			$activity = 'sensei_lesson_status';
412
-		}
413
-		elseif( $this->course_id ) {
415
+		} elseif( $this->course_id ) {
414 416
 			$post_id = intval( $this->course_id );
415 417
 			$activity = 'sensei_course_status';
416 418
 		}
@@ -601,8 +603,7 @@  discard block
 block discarded – undo
601 603
 			$post_type = __( 'Course', 'woothemes-sensei' );
602 604
 			$form_post_type = 'course';
603 605
 			$form_course_id = $this->course_id;
604
-		}
605
-		elseif( $this->course_id && $this->lesson_id ) {
606
+		} elseif( $this->course_id && $this->lesson_id ) {
606 607
 			$post_title = get_the_title( $this->lesson_id );
607 608
 			$post_type = __( 'Lesson', 'woothemes-sensei' );
608 609
 			$form_post_type = 'lesson';
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
 
206 206
 	/**
207 207
 	 * Generates content for a single row of the table in the user management
208
-     * screen.
209
-     *
208
+	 * screen.
209
+	 *
210 210
 	 * @since  1.7.0
211
-     *
211
+	 *
212 212
 	 * @param object $item The current item
213
-     *
214
-     * @return void
213
+	 *
214
+	 * @return void
215 215
 	 */
216 216
 	protected function get_row_data( $item ) {
217 217
 		global $wp_version;
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 		switch ( $this->view ) {
220 220
 			case 'learners' :
221 221
 
222
-                // in this case the item passed in is actually the users activity on course of lesson
223
-                $user_activity = $item;
222
+				// in this case the item passed in is actually the users activity on course of lesson
223
+				$user_activity = $item;
224 224
 				$post_id = false;
225 225
 
226 226
 				if( $this->lesson_id ) {
@@ -239,30 +239,30 @@  discard block
 block discarded – undo
239 239
 
240 240
 				if( 'complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved ) {
241 241
 
242
-                    $status_html = '<span class="graded">' .__( 'Completed', 'woothemes-sensei' ) . '</span>';
242
+					$status_html = '<span class="graded">' .__( 'Completed', 'woothemes-sensei' ) . '</span>';
243 243
 
244 244
 				} else {
245 245
 
246
-                    $status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>';
246
+					$status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>';
247 247
 
248 248
 				}
249 249
 
250
-                $title = Sensei_Learner::get_full_name( $user_activity->user_id );
250
+				$title = Sensei_Learner::get_full_name( $user_activity->user_id );
251 251
 				$a_title = sprintf( __( 'Edit &#8220;%s&#8221;' ), $title );
252 252
 
253
-                /**
254
-                 * sensei_learners_main_column_data filter
255
-                 *
256
-                 * This filter runs on the learner management screen for a specific course.
257
-                 * It provides the learner row column details.
258
-                 *
259
-                 * @param array $columns{
260
-                 *   type string $title
261
-                 *   type string $date_started
262
-                 *   type string $course_status (completed, started etc)
263
-                 *   type html $action_buttons
264
-                 * }
265
-                 */
253
+				/**
254
+				 * sensei_learners_main_column_data filter
255
+				 *
256
+				 * This filter runs on the learner management screen for a specific course.
257
+				 * It provides the learner row column details.
258
+				 *
259
+				 * @param array $columns{
260
+				 *   type string $title
261
+				 *   type string $date_started
262
+				 *   type string $course_status (completed, started etc)
263
+				 *   type html $action_buttons
264
+				 * }
265
+				 */
266 266
 				$column_data = apply_filters( 'sensei_learners_main_column_data', array(
267 267
 						'title' => '<strong><a class="row-title" href="' . admin_url( 'user-edit.php?user_id=' . $user_activity->user_id ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>',
268 268
 						'date_started' => get_comment_meta( $user_activity->comment_ID, 'start', true),
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
 			case 'courses' :
294 294
 			default:
295
-                $course_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_course_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any' ) ) );
295
+				$course_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_course_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any' ) ) );
296 296
 				$title = get_the_title( $item );
297 297
 				$a_title = sprintf( __( 'Edit &#8220;%s&#8221;' ), $title );
298 298
 
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 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 Learners Overview List Table Class
@@ -22,28 +22,28 @@  discard block
 block discarded – undo
22 22
 	 * Constructor
23 23
 	 * @since  1.6.0
24 24
 	 */
25
-	public function __construct ( $course_id = 0, $lesson_id = 0 ) {
26
-		$this->course_id = intval( $course_id );
27
-		$this->lesson_id = intval( $lesson_id );
25
+	public function __construct($course_id = 0, $lesson_id = 0) {
26
+		$this->course_id = intval($course_id);
27
+		$this->lesson_id = intval($lesson_id);
28 28
 
29
-		if( isset( $_GET['view'] ) && in_array( $_GET['view'], array( 'courses', 'lessons', 'learners' ) ) ) {
29
+		if (isset($_GET['view']) && in_array($_GET['view'], array('courses', 'lessons', 'learners'))) {
30 30
 			$this->view = $_GET['view'];
31 31
 		}
32 32
 
33 33
 		// Viewing a single lesson always sets the view to Learners
34
-		if( $this->lesson_id ) {
34
+		if ($this->lesson_id) {
35 35
 			$this->view = 'learners';
36 36
 		}
37 37
 
38 38
 		// Load Parent token into constructor
39
-		parent::__construct( 'learners_main' );
39
+		parent::__construct('learners_main');
40 40
 
41 41
 		// Actions
42
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
43
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
44
-		add_action( 'sensei_learners_extra', array( $this, 'add_learners_box' ) );
42
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
43
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
44
+		add_action('sensei_learners_extra', array($this, 'add_learners_box'));
45 45
 
46
-		add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) );
46
+		add_filter('sensei_list_table_search_button_text', array($this, 'search_button'));
47 47
 	} // End __construct()
48 48
 
49 49
 	/**
@@ -53,38 +53,38 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	function get_columns() {
55 55
 		$columns = array();
56
-		switch( $this->view ) {
56
+		switch ($this->view) {
57 57
 			case 'learners':
58 58
 				$columns = array(
59
-					'title' => __( 'Learner', 'woothemes-sensei' ),
60
-					'date_started' => __( 'Date Started', 'woothemes-sensei' ),
61
-					'user_status' => __( 'Status', 'woothemes-sensei' ),
59
+					'title' => __('Learner', 'woothemes-sensei'),
60
+					'date_started' => __('Date Started', 'woothemes-sensei'),
61
+					'user_status' => __('Status', 'woothemes-sensei'),
62 62
 				);
63 63
 				break;
64 64
 
65 65
 			case 'lessons':
66 66
 				$columns = array(
67
-					'title' => __( 'Lesson', 'woothemes-sensei' ),
68
-					'num_learners' => __( '# Learners', 'woothemes-sensei' ),
69
-					'updated' => __( 'Last Updated', 'woothemes-sensei' ),
67
+					'title' => __('Lesson', 'woothemes-sensei'),
68
+					'num_learners' => __('# Learners', 'woothemes-sensei'),
69
+					'updated' => __('Last Updated', 'woothemes-sensei'),
70 70
 				);
71 71
 				break;
72 72
 
73 73
 			case 'courses':
74 74
 			default:
75 75
 				$columns = array(
76
-					'title' => __( 'Course', 'woothemes-sensei' ),
77
-					'num_learners' => __( '# Learners', 'woothemes-sensei' ),
78
-					'updated' => __( 'Last Updated', 'woothemes-sensei' ),
76
+					'title' => __('Course', 'woothemes-sensei'),
77
+					'num_learners' => __('# Learners', 'woothemes-sensei'),
78
+					'updated' => __('Last Updated', 'woothemes-sensei'),
79 79
 				);
80 80
 				break;
81 81
 		}
82 82
 		$columns['actions'] = '';
83 83
 		// Backwards compatible
84
-		if ( 'learners' == $this->view ) {
85
-			$columns = apply_filters( 'sensei_learners_learners_columns', $columns, $this );
84
+		if ('learners' == $this->view) {
85
+			$columns = apply_filters('sensei_learners_learners_columns', $columns, $this);
86 86
 		}
87
-		$columns = apply_filters( 'sensei_learners_default_columns', $columns, $this );
87
+		$columns = apply_filters('sensei_learners_default_columns', $columns, $this);
88 88
 		return $columns;
89 89
 	}
90 90
 
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	function get_sortable_columns() {
97 97
 		$columns = array();
98
-		switch( $this->view ) {
98
+		switch ($this->view) {
99 99
 			case 'learners':
100 100
 				$columns = array(
101
-					'title' => array( 'title', false ),
101
+					'title' => array('title', false),
102 102
 				);
103 103
 				break;
104 104
 
105 105
 			case 'lessons':
106 106
 				$columns = array(
107
-					'title' => array( 'title', false ),
108
-					'updated' => array( 'post_modified', false ),
107
+					'title' => array('title', false),
108
+					'updated' => array('post_modified', false),
109 109
 				);
110 110
 				break;
111 111
 
112 112
 			default:
113 113
 				$columns = array(
114
-					'title' => array( 'title', false ),
115
-					'updated' => array( 'post_modified', false ),
114
+					'title' => array('title', false),
115
+					'updated' => array('post_modified', false),
116 116
 				);
117 117
 				break;
118 118
 		}
119 119
 		// Backwards compatible
120
-		if ( 'learners' == $this->view ) {
121
-			$columns = apply_filters( 'sensei_learners_learners_columns_sortable', $columns, $this );
120
+		if ('learners' == $this->view) {
121
+			$columns = apply_filters('sensei_learners_learners_columns_sortable', $columns, $this);
122 122
 		}
123
-		$columns = apply_filters( 'sensei_learners_default_columns_sortable', $columns, $this );
123
+		$columns = apply_filters('sensei_learners_default_columns_sortable', $columns, $this);
124 124
 		return $columns;
125 125
 	}
126 126
 
@@ -134,72 +134,72 @@  discard block
 block discarded – undo
134 134
 
135 135
 		// Handle orderby
136 136
 		$orderby = '';
137
-		if ( !empty( $_GET['orderby'] ) ) {
138
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
139
-				$orderby = esc_html( $_GET['orderby'] );
137
+		if ( ! empty($_GET['orderby'])) {
138
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
139
+				$orderby = esc_html($_GET['orderby']);
140 140
 			} // End If Statement
141 141
 		}
142 142
 
143 143
 		// Handle order
144 144
 		$order = 'DESC';
145
-		if ( !empty( $_GET['order'] ) ) {
146
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
145
+		if ( ! empty($_GET['order'])) {
146
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
147 147
 		}
148 148
 
149 149
 		// Handle category selection
150 150
 		$category = false;
151
-		if ( !empty( $_GET['course_cat'] ) ) {
152
-			$category = intval( $_GET['course_cat'] );
151
+		if ( ! empty($_GET['course_cat'])) {
152
+			$category = intval($_GET['course_cat']);
153 153
 		} // End If Statement
154 154
 
155 155
 		// Handle search
156 156
 		$search = false;
157
-		if ( !empty( $_GET['s'] ) ) {
158
-			$search = esc_html( $_GET['s'] );
157
+		if ( ! empty($_GET['s'])) {
158
+			$search = esc_html($_GET['s']);
159 159
 		} // End If Statement
160 160
 
161
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
162
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
161
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
162
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
163 163
 
164 164
 		$paged = $this->get_pagenum();
165 165
 		$offset = 0;
166
-		if ( !empty($paged) ) {
167
-			$offset = $per_page * ( $paged - 1 );
166
+		if ( ! empty($paged)) {
167
+			$offset = $per_page * ($paged - 1);
168 168
 		} // End If Statement
169 169
 
170
-		switch( $this->view ) {
170
+		switch ($this->view) {
171 171
 			case 'learners':
172
-				if ( empty($orderby) ) {
172
+				if (empty($orderby)) {
173 173
 					$orderby = '';
174 174
 				}
175
-				$this->items = $this->get_learners( compact( 'per_page', 'offset', 'orderby', 'order', 'search' ) );
175
+				$this->items = $this->get_learners(compact('per_page', 'offset', 'orderby', 'order', 'search'));
176 176
 
177 177
 			break;
178 178
 
179 179
 			case 'lessons':
180
-				if ( empty($orderby) ) {
180
+				if (empty($orderby)) {
181 181
 					$orderby = 'post_modified';
182 182
 				}
183
-				$this->items = $this->get_lessons( compact( 'per_page', 'offset', 'orderby', 'order', 'search' ) );
183
+				$this->items = $this->get_lessons(compact('per_page', 'offset', 'orderby', 'order', 'search'));
184 184
 
185 185
 			break;
186 186
 
187 187
 			default:
188
-				if ( empty($orderby) ) {
188
+				if (empty($orderby)) {
189 189
 					$orderby = 'post_modified';
190 190
 				}
191
-				$this->items = $this->get_courses( compact( 'per_page', 'offset', 'orderby', 'order', 'category', 'search' ) );
191
+				$this->items = $this->get_courses(compact('per_page', 'offset', 'orderby', 'order', 'category', 'search'));
192 192
 
193 193
 			break;
194 194
 		}
195 195
 
196 196
 		$total_items = $this->total_items;
197
-		$total_pages = ceil( $total_items / $per_page );
198
-		$this->set_pagination_args( array(
197
+		$total_pages = ceil($total_items / $per_page);
198
+		$this->set_pagination_args(array(
199 199
 			'total_items' => $total_items,
200 200
 			'total_pages' => $total_pages,
201 201
 			'per_page' => $per_page
202
-		) );
202
+		));
203 203
 
204 204
 	} // End prepare_items()
205 205
 
@@ -213,42 +213,42 @@  discard block
 block discarded – undo
213 213
      *
214 214
      * @return void
215 215
 	 */
216
-	protected function get_row_data( $item ) {
216
+	protected function get_row_data($item) {
217 217
 		global $wp_version;
218 218
 
219
-		switch ( $this->view ) {
219
+		switch ($this->view) {
220 220
 			case 'learners' :
221 221
 
222 222
                 // in this case the item passed in is actually the users activity on course of lesson
223 223
                 $user_activity = $item;
224 224
 				$post_id = false;
225 225
 
226
-				if( $this->lesson_id ) {
226
+				if ($this->lesson_id) {
227 227
 
228
-					$post_id = intval( $this->lesson_id );
229
-					$object_type = __( 'lesson', 'woothemes-sensei' );
228
+					$post_id = intval($this->lesson_id);
229
+					$object_type = __('lesson', 'woothemes-sensei');
230 230
 					$post_type = 'lesson';
231 231
 
232
-				} elseif( $this->course_id ) {
232
+				} elseif ($this->course_id) {
233 233
 
234
-					$post_id = intval( $this->course_id );
235
-					$object_type = __( 'course', 'woothemes-sensei' );
234
+					$post_id = intval($this->course_id);
235
+					$object_type = __('course', 'woothemes-sensei');
236 236
 					$post_type = 'course';
237 237
 
238 238
 				}
239 239
 
240
-				if( 'complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved ) {
240
+				if ('complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved) {
241 241
 
242
-                    $status_html = '<span class="graded">' .__( 'Completed', 'woothemes-sensei' ) . '</span>';
242
+                    $status_html = '<span class="graded">'.__('Completed', 'woothemes-sensei').'</span>';
243 243
 
244 244
 				} else {
245 245
 
246
-                    $status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>';
246
+                    $status_html = '<span class="in-progress">'.__('In Progress', 'woothemes-sensei').'</span>';
247 247
 
248 248
 				}
249 249
 
250
-                $title = Sensei_Learner::get_full_name( $user_activity->user_id );
251
-				$a_title = sprintf( __( 'Edit &#8220;%s&#8221;' ), $title );
250
+                $title = Sensei_Learner::get_full_name($user_activity->user_id);
251
+				$a_title = sprintf(__('Edit &#8220;%s&#8221;'), $title);
252 252
 
253 253
                 /**
254 254
                  * sensei_learners_main_column_data filter
@@ -263,50 +263,50 @@  discard block
 block discarded – undo
263 263
                  *   type html $action_buttons
264 264
                  * }
265 265
                  */
266
-				$column_data = apply_filters( 'sensei_learners_main_column_data', array(
267
-						'title' => '<strong><a class="row-title" href="' . admin_url( 'user-edit.php?user_id=' . $user_activity->user_id ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>',
268
-						'date_started' => get_comment_meta( $user_activity->comment_ID, 'start', true),
266
+				$column_data = apply_filters('sensei_learners_main_column_data', array(
267
+						'title' => '<strong><a class="row-title" href="'.admin_url('user-edit.php?user_id='.$user_activity->user_id).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>',
268
+						'date_started' => get_comment_meta($user_activity->comment_ID, 'start', true),
269 269
 						'user_status' => $status_html,
270
-						'actions' => '<a class="remove-learner button" data-user_id="' . $user_activity->user_id . '" data-post_id="' . $post_id . '" data-post_type="' . $post_type . '">' . sprintf( __( 'Remove from %1$s', 'woothemes-sensei' ), $object_type ) . '</a>',
271
-					), $item, $post_id, $post_type );
270
+						'actions' => '<a class="remove-learner button" data-user_id="'.$user_activity->user_id.'" data-post_id="'.$post_id.'" data-post_type="'.$post_type.'">'.sprintf(__('Remove from %1$s', 'woothemes-sensei'), $object_type).'</a>',
271
+					), $item, $post_id, $post_type);
272 272
 
273 273
 				break;
274 274
 
275 275
 			case 'lessons' :
276
-				$lesson_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_lesson_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_lesson_status', 'status' => 'any' ) ) );
277
-				$title = get_the_title( $item );
278
-				$a_title = sprintf( __( 'Edit &#8220;%s&#8221;' ), $title );
276
+				$lesson_learners = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_lesson_learners', array('post_id' => $item->ID, 'type' => 'sensei_lesson_status', 'status' => 'any')));
277
+				$title = get_the_title($item);
278
+				$a_title = sprintf(__('Edit &#8220;%s&#8221;'), $title);
279 279
 
280 280
 				$grading_action = '';
281
-				if ( get_post_meta( $item->ID, '_quiz_has_questions', true ) ) {
282
-					$grading_action = ' <a class="button" href="' . esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'lesson_id' => $item->ID, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Grading', 'woothemes-sensei' ) . '</a>';
281
+				if (get_post_meta($item->ID, '_quiz_has_questions', true)) {
282
+					$grading_action = ' <a class="button" href="'.esc_url(add_query_arg(array('page' => 'sensei_grading', 'lesson_id' => $item->ID, 'course_id' => $this->course_id), admin_url('admin.php'))).'">'.__('Grading', 'woothemes-sensei').'</a>';
283 283
 				}
284 284
 
285
-				$column_data = apply_filters( 'sensei_learners_main_column_data', array(
286
-						'title' => '<strong><a class="row-title" href="' . admin_url( 'post.php?action=edit&post=' . $item->ID ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>',
285
+				$column_data = apply_filters('sensei_learners_main_column_data', array(
286
+						'title' => '<strong><a class="row-title" href="'.admin_url('post.php?action=edit&post='.$item->ID).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>',
287 287
 						'num_learners' => $lesson_learners,
288 288
 						'updated' => $item->post_modified,
289
-						'actions' => '<a class="button" href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID, 'course_id' => $this->course_id, 'view' => 'learners' ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Manage learners', 'woothemes-sensei' ) . '</a> ' . $grading_action,
290
-					), $item, $this->course_id );
289
+						'actions' => '<a class="button" href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID, 'course_id' => $this->course_id, 'view' => 'learners'), admin_url('admin.php'))).'">'.__('Manage learners', 'woothemes-sensei').'</a> '.$grading_action,
290
+					), $item, $this->course_id);
291 291
 				break;
292 292
 
293 293
 			case 'courses' :
294 294
 			default:
295
-                $course_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_course_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any' ) ) );
296
-				$title = get_the_title( $item );
297
-				$a_title = sprintf( __( 'Edit &#8220;%s&#8221;' ), $title );
295
+                $course_learners = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_course_learners', array('post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any')));
296
+				$title = get_the_title($item);
297
+				$a_title = sprintf(__('Edit &#8220;%s&#8221;'), $title);
298 298
 
299 299
 				$grading_action = '';
300
-				if ( version_compare($wp_version, '4.1', '>=') ) {
301
-					$grading_action = ' <a class="button" href="' . esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $item->ID ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Grading', 'woothemes-sensei' ) . '</a>';
300
+				if (version_compare($wp_version, '4.1', '>=')) {
301
+					$grading_action = ' <a class="button" href="'.esc_url(add_query_arg(array('page' => 'sensei_grading', 'course_id' => $item->ID), admin_url('admin.php'))).'">'.__('Grading', 'woothemes-sensei').'</a>';
302 302
 				}
303 303
 
304
-				$column_data = apply_filters( 'sensei_learners_main_column_data', array(
305
-						'title' => '<strong><a class="row-title" href="' . admin_url( 'post.php?action=edit&post=' . $item->ID ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>',
304
+				$column_data = apply_filters('sensei_learners_main_column_data', array(
305
+						'title' => '<strong><a class="row-title" href="'.admin_url('post.php?action=edit&post='.$item->ID).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>',
306 306
 						'num_learners' => $course_learners,
307 307
 						'updated' => $item->post_modified,
308
-						'actions' => '<a class="button" href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $item->ID, 'view' => 'learners' ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Manage learners', 'woothemes-sensei' ) . '</a> ' . $grading_action,
309
-					), $item );
308
+						'actions' => '<a class="button" href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'course_id' => $item->ID, 'view' => 'learners'), admin_url('admin.php'))).'">'.__('Manage learners', 'woothemes-sensei').'</a> '.$grading_action,
309
+					), $item);
310 310
 
311 311
 				break;
312 312
 		} // switch
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @since  1.7.0
320 320
 	 * @return array courses
321 321
 	 */
322
-	private function get_courses( $args ) {
322
+	private function get_courses($args) {
323 323
 		$course_args = array(
324 324
 			'post_type' => 'course',
325 325
 			'post_status' => 'publish',
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 			'order' => $args['order'],
330 330
 		);
331 331
 
332
-		if( $args['category'] ) {
332
+		if ($args['category']) {
333 333
 			$course_args['tax_query'][] = array(
334 334
 				'taxonomy' => 'course-category',
335 335
 				'field' => 'id',
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 			);
338 338
 		}
339 339
 
340
-		if( $args['search'] ) {
340
+		if ($args['search']) {
341 341
 			$course_args['s'] = $args['search'];
342 342
 		}
343 343
 
344
-		$courses_query = new WP_Query( apply_filters( 'sensei_learners_filter_courses', $course_args ) );
344
+		$courses_query = new WP_Query(apply_filters('sensei_learners_filter_courses', $course_args));
345 345
 
346 346
 		$this->total_items = $courses_query->found_posts;
347 347
 		return $courses_query->posts;
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @since  1.7.0
353 353
 	 * @return array lessons
354 354
 	 */
355
-	private function get_lessons( $args ) {
355
+	private function get_lessons($args) {
356 356
 		$lesson_args = array(
357 357
 			'post_type' => 'lesson',
358 358
 			'post_status' => 'publish',
@@ -362,18 +362,18 @@  discard block
 block discarded – undo
362 362
 			'order' => $args['order'],
363 363
 		);
364 364
 
365
-		if( $this->course_id ) {
365
+		if ($this->course_id) {
366 366
 			$lesson_args['meta_query'][] = array(
367 367
 				'key' => '_lesson_course',
368 368
 				'value' => $this->course_id,
369 369
 			);
370 370
 		}
371 371
 
372
-		if( $args['search'] ) {
372
+		if ($args['search']) {
373 373
 			$lesson_args['s'] = $args['search'];
374 374
 		}
375 375
 
376
-		$lessons_query = new WP_Query( apply_filters( 'sensei_learners_filter_lessons', $lesson_args ) );
376
+		$lessons_query = new WP_Query(apply_filters('sensei_learners_filter_lessons', $lesson_args));
377 377
 
378 378
 		$this->total_items = $lessons_query->found_posts;
379 379
 		return $lessons_query->posts;
@@ -384,22 +384,22 @@  discard block
 block discarded – undo
384 384
 	 * @since  1.7.0
385 385
 	 * @return array learners
386 386
 	 */
387
-	private function get_learners( $args ) {
387
+	private function get_learners($args) {
388 388
 
389 389
 		$user_ids = false;
390 390
 		$post_id = 0;
391 391
 		$activity = '';
392 392
 
393
-		if( $this->lesson_id ) {
394
-			$post_id = intval( $this->lesson_id );
393
+		if ($this->lesson_id) {
394
+			$post_id = intval($this->lesson_id);
395 395
 			$activity = 'sensei_lesson_status';
396 396
 		}
397
-		elseif( $this->course_id ) {
398
-			$post_id = intval( $this->course_id );
397
+		elseif ($this->course_id) {
398
+			$post_id = intval($this->course_id);
399 399
 			$activity = 'sensei_course_status';
400 400
 		}
401 401
 
402
-		if( ! $post_id || ! $activity ) {
402
+		if ( ! $post_id || ! $activity) {
403 403
 			$this->total_items = 0;
404 404
 			return array();
405 405
 		}
@@ -415,32 +415,32 @@  discard block
 block discarded – undo
415 415
 			);
416 416
 
417 417
 		// Searching users on statuses requires sub-selecting the statuses by user_ids
418
-		if ( $args['search'] ) {
418
+		if ($args['search']) {
419 419
 			$user_args = array(
420
-				'search' => '*' . $args['search'] . '*',
420
+				'search' => '*'.$args['search'].'*',
421 421
 				'fields' => 'ID'
422 422
 			);
423 423
 			// Filter for extending
424
-			$user_args = apply_filters( 'sensei_learners_search_users', $user_args );
425
-			if ( !empty( $user_args ) ) {
426
-				$learners_search = new WP_User_Query( $user_args );
424
+			$user_args = apply_filters('sensei_learners_search_users', $user_args);
425
+			if ( ! empty($user_args)) {
426
+				$learners_search = new WP_User_Query($user_args);
427 427
 				$activity_args['user_id'] = $learners_search->get_results();
428 428
 			}
429 429
 		}
430 430
 
431
-		$activity_args = apply_filters( 'sensei_learners_filter_users', $activity_args );
431
+		$activity_args = apply_filters('sensei_learners_filter_users', $activity_args);
432 432
 
433 433
 		// WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice
434
-		$total_learners = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
434
+		$total_learners = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0)));
435 435
 		// Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views?
436
-		if ( $total_learners < $activity_args['offset'] ) {
437
-			$new_paged = floor( $total_learners / $activity_args['number'] );
436
+		if ($total_learners < $activity_args['offset']) {
437
+			$new_paged = floor($total_learners / $activity_args['number']);
438 438
 			$activity_args['offset'] = $new_paged * $activity_args['number'];
439 439
 		}
440
-		$learners = Sensei_Utils::sensei_check_for_activity( $activity_args, true );
440
+		$learners = Sensei_Utils::sensei_check_for_activity($activity_args, true);
441 441
 		// Need to always return an array, even with only 1 item
442
-		if ( !is_array($learners) ) {
443
-			$learners = array( $learners );
442
+		if ( ! is_array($learners)) {
443
+			$learners = array($learners);
444 444
 		}
445 445
 		$this->total_items = $total_learners;
446 446
 		return $learners;
@@ -453,22 +453,22 @@  discard block
 block discarded – undo
453 453
 	 * @return void
454 454
 	 */
455 455
 	public function no_items() {
456
-		switch( $this->view ) {
456
+		switch ($this->view) {
457 457
 			case 'learners' :
458
-				$text = __( 'No learners found.', 'woothemes-sensei' );
458
+				$text = __('No learners found.', 'woothemes-sensei');
459 459
 				break;
460 460
 
461 461
 			case 'lessons' :
462
-				$text = __( 'No lessons found.', 'woothemes-sensei' );
462
+				$text = __('No lessons found.', 'woothemes-sensei');
463 463
 				break;
464 464
 
465 465
 			case 'courses':
466 466
 			case 'default':
467 467
 			default:
468
-				$text = __( 'No courses found.', 'woothemes-sensei' );
468
+				$text = __('No courses found.', 'woothemes-sensei');
469 469
 				break;
470 470
 		}
471
-		echo apply_filters( 'sensei_learners_no_items_text', $text );
471
+		echo apply_filters('sensei_learners_no_items_text', $text);
472 472
 	} // End no_items()
473 473
 
474 474
 	/**
@@ -479,40 +479,40 @@  discard block
 block discarded – undo
479 479
 	public function data_table_header() {
480 480
 
481 481
 		echo '<div class="learners-selects">';
482
-		do_action( 'sensei_learners_before_dropdown_filters' );
482
+		do_action('sensei_learners_before_dropdown_filters');
483 483
 
484 484
 		// Display Course Categories only on default view
485
-		if( 'courses' == $this->view ) {
485
+		if ('courses' == $this->view) {
486 486
 
487 487
 			$selected_cat = 0;
488
-			if ( isset( $_GET['course_cat'] ) && '' != esc_html( $_GET['course_cat'] ) ) {
489
-				$selected_cat = intval( $_GET['course_cat'] );
488
+			if (isset($_GET['course_cat']) && '' != esc_html($_GET['course_cat'])) {
489
+				$selected_cat = intval($_GET['course_cat']);
490 490
 			}
491 491
 
492
-			$cats = get_terms( 'course-category', array( 'hide_empty' => false ) );
492
+			$cats = get_terms('course-category', array('hide_empty' => false));
493 493
 
494
-			echo '<div class="select-box">' . "\n";
494
+			echo '<div class="select-box">'."\n";
495 495
 
496
-				echo '<select id="course-category-options" data-placeholder="' . __( 'Course Category', 'woothemes-sensei' ) . '" name="learners_course_cat" class="chosen_select widefat">' . "\n";
496
+				echo '<select id="course-category-options" data-placeholder="'.__('Course Category', 'woothemes-sensei').'" name="learners_course_cat" class="chosen_select widefat">'."\n";
497 497
 
498
-					echo '<option value="0">' . __( 'All Course Categories', 'woothemes-sensei' ) . '</option>' . "\n";
498
+					echo '<option value="0">'.__('All Course Categories', 'woothemes-sensei').'</option>'."\n";
499 499
 
500
-					foreach( $cats as $cat ) {
501
-						echo '<option value="' . $cat->term_id . '"' . selected( $cat->term_id, $selected_cat, false ) . '>' . $cat->name . '</option>' . "\n";
500
+					foreach ($cats as $cat) {
501
+						echo '<option value="'.$cat->term_id.'"'.selected($cat->term_id, $selected_cat, false).'>'.$cat->name.'</option>'."\n";
502 502
 					}
503 503
 
504
-				echo '</select>' . "\n";
504
+				echo '</select>'."\n";
505 505
 
506
-			echo '</div>' . "\n";
506
+			echo '</div>'."\n";
507 507
 		}
508 508
 		echo '</div><!-- /.learners-selects -->';
509 509
 
510 510
 		$menu = array();
511 511
 		// Have Course no Lesson
512
-		if( $this->course_id && ! $this->lesson_id ) {
512
+		if ($this->course_id && ! $this->lesson_id) {
513 513
 
514 514
 			$learners_class = $lessons_class = '';
515
-			switch( $this->view ) {
515
+			switch ($this->view) {
516 516
 				case 'learners':
517 517
 					$learners_class = 'current';
518 518
 				break;
@@ -531,12 +531,12 @@  discard block
 block discarded – undo
531 531
 			$learner_args['view'] = 'learners';
532 532
 			$lesson_args['view'] = 'lessons';
533 533
 
534
-			$menu['learners'] = '<a class="' . $learners_class . '" href="' . esc_url( add_query_arg( $learner_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Learners', 'woothemes-sensei' ) . '</a>';
535
-			$menu['lessons'] = '<a class="' . $lessons_class . '" href="' . esc_url( add_query_arg( $lesson_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Lessons', 'woothemes-sensei' ) . '</a>';
534
+			$menu['learners'] = '<a class="'.$learners_class.'" href="'.esc_url(add_query_arg($learner_args, admin_url('admin.php'))).'">'.__('Learners', 'woothemes-sensei').'</a>';
535
+			$menu['lessons'] = '<a class="'.$lessons_class.'" href="'.esc_url(add_query_arg($lesson_args, admin_url('admin.php'))).'">'.__('Lessons', 'woothemes-sensei').'</a>';
536 536
 
537 537
 		} 
538 538
 		// Have Course and Lesson
539
-		elseif( $this->course_id && $this->lesson_id ) {
539
+		elseif ($this->course_id && $this->lesson_id) {
540 540
 
541 541
 			$query_args = array(
542 542
 				'page' => $this->page_slug,
@@ -544,18 +544,18 @@  discard block
 block discarded – undo
544 544
 				'view' => 'lessons'
545 545
 			);
546 546
 
547
-			$course = get_the_title( $this->course_id );
547
+			$course = get_the_title($this->course_id);
548 548
 
549
-			$menu['back'] = '<a href="' . esc_url( add_query_arg( $query_args, admin_url( 'admin.php' ) ) ) . '">' . sprintf( __( '%1$sBack to %2$s%3$s', 'woothemes-sensei' ), '<em>&larr; ', $course, '</em>' ) . '</a>';
549
+			$menu['back'] = '<a href="'.esc_url(add_query_arg($query_args, admin_url('admin.php'))).'">'.sprintf(__('%1$sBack to %2$s%3$s', 'woothemes-sensei'), '<em>&larr; ', $course, '</em>').'</a>';
550 550
 		}
551
-		$menu = apply_filters( 'sensei_learners_sub_menu', $menu );
552
-		if ( !empty($menu) ) {
553
-			echo '<ul class="subsubsub">' . "\n";
554
-			foreach ( $menu as $class => $item ) {
555
-				$menu[ $class ] = "\t<li class='$class'>$item";
551
+		$menu = apply_filters('sensei_learners_sub_menu', $menu);
552
+		if ( ! empty($menu)) {
553
+			echo '<ul class="subsubsub">'."\n";
554
+			foreach ($menu as $class => $item) {
555
+				$menu[$class] = "\t<li class='$class'>$item";
556 556
 			}
557
-			echo implode( " |</li>\n", $menu ) . "</li>\n";
558
-			echo '</ul>' . "\n";
557
+			echo implode(" |</li>\n", $menu)."</li>\n";
558
+			echo '</ul>'."\n";
559 559
 		}
560 560
 
561 561
 	} // End data_table_header()
@@ -580,50 +580,50 @@  discard block
 block discarded – undo
580 580
 		$form_post_type = '';
581 581
 		$form_course_id = 0;
582 582
 		$form_lesson_id = 0;
583
-		if( $this->course_id && ! $this->lesson_id ) {
584
-			$post_title = get_the_title( $this->course_id );
585
-			$post_type = __( 'Course', 'woothemes-sensei' );
583
+		if ($this->course_id && ! $this->lesson_id) {
584
+			$post_title = get_the_title($this->course_id);
585
+			$post_type = __('Course', 'woothemes-sensei');
586 586
 			$form_post_type = 'course';
587 587
 			$form_course_id = $this->course_id;
588 588
 		}
589
-		elseif( $this->course_id && $this->lesson_id ) {
590
-			$post_title = get_the_title( $this->lesson_id );
591
-			$post_type = __( 'Lesson', 'woothemes-sensei' );
589
+		elseif ($this->course_id && $this->lesson_id) {
590
+			$post_title = get_the_title($this->lesson_id);
591
+			$post_type = __('Lesson', 'woothemes-sensei');
592 592
 			$form_post_type = 'lesson';
593 593
 			$form_course_id = $this->course_id;
594 594
 			$form_lesson_id = $this->lesson_id;
595
-			$course_title = get_the_title( $this->course_id );
595
+			$course_title = get_the_title($this->course_id);
596 596
 		}
597
-		if ( empty($form_post_type) ) {
597
+		if (empty($form_post_type)) {
598 598
 			return;
599 599
 		}
600 600
 		?>
601 601
 		<div class="postbox">
602
-			<h3><span><?php printf( __( 'Add Learner to %1$s', 'woothemes-sensei' ), $post_type ); ?></span></h3>
602
+			<h3><span><?php printf(__('Add Learner to %1$s', 'woothemes-sensei'), $post_type); ?></span></h3>
603 603
 			<div class="inside">
604 604
 				<form name="add_learner" action="" method="post">
605 605
 					<p>
606
-						<input name="add_user_id" placeholder="<?php _e( 'Find learner', 'woothemes-sensei' ) ;?>" id="add_learner_search" style="min-width:300px;" />
607
-						<?php if( 'lesson' == $form_post_type ) { ?>
608
-							<label for="add_complete_lesson"><input type="checkbox" id="add_complete_lesson" name="add_complete_lesson"  value="yes" /> <?php _e( 'Complete lesson for learner', 'woothemes-sensei' ); ?></label>
609
-						<?php } elseif( 'course' == $form_post_type ) { ?>
610
-							<label for="add_complete_course"><input type="checkbox" id="add_complete_course" name="add_complete_course"  value="yes" /> <?php _e( 'Complete course for learner', 'woothemes-sensei' ); ?></label>
606
+						<input name="add_user_id" placeholder="<?php _e('Find learner', 'woothemes-sensei'); ?>" id="add_learner_search" style="min-width:300px;" />
607
+						<?php if ('lesson' == $form_post_type) { ?>
608
+							<label for="add_complete_lesson"><input type="checkbox" id="add_complete_lesson" name="add_complete_lesson"  value="yes" /> <?php _e('Complete lesson for learner', 'woothemes-sensei'); ?></label>
609
+						<?php } elseif ('course' == $form_post_type) { ?>
610
+							<label for="add_complete_course"><input type="checkbox" id="add_complete_course" name="add_complete_course"  value="yes" /> <?php _e('Complete course for learner', 'woothemes-sensei'); ?></label>
611 611
 						<?php } ?>
612 612
 						<br/>
613
-						<span class="description"><?php _e( 'Search for a user by typing their name or username.', 'woothemes-sensei' ); ?></span>
613
+						<span class="description"><?php _e('Search for a user by typing their name or username.', 'woothemes-sensei'); ?></span>
614 614
 					</p>
615
-					<p><?php submit_button( sprintf( __( 'Add to \'%1$s\'', 'woothemes-sensei' ), $post_title ), 'primary', 'add_learner_submit', false, array() ); ?></p>
616
-					<?php if( 'lesson' == $form_post_type ) { ?>
617
-						<p><span class="description"><?php printf( __( 'Learner will also be added to the course \'%1$s\' if they are not already taking it.', 'woothemes-sensei' ), $course_title ); ?></span></p>
615
+					<p><?php submit_button(sprintf(__('Add to \'%1$s\'', 'woothemes-sensei'), $post_title), 'primary', 'add_learner_submit', false, array()); ?></p>
616
+					<?php if ('lesson' == $form_post_type) { ?>
617
+						<p><span class="description"><?php printf(__('Learner will also be added to the course \'%1$s\' if they are not already taking it.', 'woothemes-sensei'), $course_title); ?></span></p>
618 618
 					<?php } ?>
619 619
 
620 620
 					<input type="hidden" name="add_post_type" value="<?php echo $form_post_type; ?>" />
621 621
 					<input type="hidden" name="add_course_id" value="<?php echo $form_course_id; ?>" />
622 622
 					<input type="hidden" name="add_lesson_id" value="<?php echo $form_lesson_id; ?>" />
623 623
 					<?php
624
-						do_action( 'sensei_learners_add_learner_form' );
624
+						do_action('sensei_learners_add_learner_form');
625 625
 					?>
626
-					<?php wp_nonce_field( 'add_learner_to_sensei', 'add_learner_nonce' ); ?>
626
+					<?php wp_nonce_field('add_learner_to_sensei', 'add_learner_nonce'); ?>
627 627
 				</form>
628 628
 			</div>
629 629
 		</div>
@@ -635,19 +635,19 @@  discard block
 block discarded – undo
635 635
 	 * @since  1.7.0
636 636
 	 * @return string $text
637 637
 	 */
638
-	public function search_button( $text = '' ) {
638
+	public function search_button($text = '') {
639 639
 
640
-		switch( $this->view ) {
640
+		switch ($this->view) {
641 641
 			case 'learners':
642
-				$text = __( 'Search Learners', 'woothemes-sensei' );
642
+				$text = __('Search Learners', 'woothemes-sensei');
643 643
 			break;
644 644
 
645 645
 			case 'lessons':
646
-				$text = __( 'Search Lessons', 'woothemes-sensei' );
646
+				$text = __('Search Lessons', 'woothemes-sensei');
647 647
 			break;
648 648
 
649 649
 			default:
650
-				$text = __( 'Search Courses', 'woothemes-sensei' );
650
+				$text = __('Search Courses', 'woothemes-sensei');
651 651
 			break;
652 652
 		}
653 653
 
Please login to merge, or discard this patch.
includes/class-sensei-analysis-course-list-table.php 3 patches
Braces   +12 added lines, -17 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 Course List Table Class
@@ -359,31 +362,26 @@  discard block
 block discarded – undo
359 362
 							$status_class = 'graded';
360 363
 
361 364
 							$grade = __( 'No Grade', 'woothemes-sensei' );
362
-						}
363
-						elseif( 'graded' == $lesson_status->comment_approved ) {
365
+						} elseif( 'graded' == $lesson_status->comment_approved ) {
364 366
 							$status =  __( 'Graded', 'woothemes-sensei' );
365 367
 							$status_class = 'graded';
366 368
 
367 369
 							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
368
-						}
369
-						elseif( 'passed' == $lesson_status->comment_approved ) {
370
+						} elseif( 'passed' == $lesson_status->comment_approved ) {
370 371
 							$status =  __( 'Passed', 'woothemes-sensei' );
371 372
 							$status_class = 'graded';
372 373
 
373 374
 							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
374
-						}
375
-						elseif( 'failed' == $lesson_status->comment_approved ) {
375
+						} elseif( 'failed' == $lesson_status->comment_approved ) {
376 376
 							$status =  __( 'Failed', 'woothemes-sensei' );
377 377
 							$status_class = 'failed';
378 378
 
379 379
 							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
380
-						}
381
-						elseif( 'ungraded' == $lesson_status->comment_approved ) {
380
+						} elseif( 'ungraded' == $lesson_status->comment_approved ) {
382 381
 							$status =  __( 'Ungraded', 'woothemes-sensei' );
383 382
 							$status_class = 'ungraded';
384 383
 
385
-						}
386
-						elseif( 'in-progress' == $lesson_status->comment_approved ) {
384
+						} elseif( 'in-progress' == $lesson_status->comment_approved ) {
387 385
 							$status =  __( 'In Progress', 'woothemes-sensei' );
388 386
 							$user_end_date = '';
389 387
 						}
@@ -392,8 +390,7 @@  discard block
 block discarded – undo
392 390
 					// Output users data
393 391
 					if ( $this->csv_output ) {
394 392
 						$lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID );
395
-					}
396
-					else {
393
+					} else {
397 394
 						$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) );
398 395
 						$lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>';
399 396
 
@@ -448,8 +445,7 @@  discard block
 block discarded – undo
448 445
 					// Output lesson data
449 446
 					if ( $this->csv_output ) {
450 447
 						$lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID );
451
-					}
452
-					else {
448
+					} else {
453 449
 						$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) );
454 450
 						$lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>';
455 451
 
@@ -582,8 +578,7 @@  discard block
 block discarded – undo
582 578
 	public function data_table_header() {
583 579
 		if ( $this->user_id ) {
584 580
 			$learners_text = __( 'Other Learners taking this Course', 'woothemes-sensei' );
585
-		}
586
-		else {
581
+		} else {
587 582
 			$learners_text = __( 'Learners taking this Course', 'woothemes-sensei' );
588 583
 		}
589 584
 		$lessons_text = __( 'Lessons in this Course', 'woothemes-sensei' );
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -627,7 +627,7 @@
 block discarded – undo
627 627
 		$course = get_post( $this->course_id );
628 628
 		$report = sanitize_title( $course->post_title ) . '-' . $this->view . 's-overview';
629 629
 		if ( $this->user_id ) {
630
-            $user_name = Sensei_Learner::get_full_name( $this->user_id );
630
+			$user_name = Sensei_Learner::get_full_name( $this->user_id );
631 631
 			$report = sanitize_title( $user_name  ) . '-' . $report;
632 632
 		}
633 633
 
Please login to merge, or discard this patch.
Spacing   +195 added lines, -195 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
  * Admin Analysis Course Data Table in Sensei.
@@ -20,27 +20,27 @@  discard block
 block discarded – undo
20 20
 	 * Constructor
21 21
 	 * @since  1.2.0
22 22
 	 */
23
-	public function __construct ( $course_id = 0, $user_id = 0 ) {
24
-		$this->course_id = intval( $course_id );
25
-		$this->user_id = intval( $user_id );
23
+	public function __construct($course_id = 0, $user_id = 0) {
24
+		$this->course_id = intval($course_id);
25
+		$this->user_id = intval($user_id);
26 26
 
27
-		if( isset( $_GET['view'] ) && in_array( $_GET['view'], array( 'user', 'lesson' ) ) ) {
27
+		if (isset($_GET['view']) && in_array($_GET['view'], array('user', 'lesson'))) {
28 28
 			$this->view = $_GET['view'];
29 29
 		}
30 30
 
31 31
 		// Viewing a single Learner always sets the view to Lessons
32
-		if( $this->user_id ) {
32
+		if ($this->user_id) {
33 33
 			$this->view = 'lesson';
34 34
 		}
35 35
 
36 36
 		// Load Parent token into constructor
37
-		parent::__construct( 'analysis_course' );
37
+		parent::__construct('analysis_course');
38 38
 
39 39
 		// Actions
40
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
41
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
40
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
41
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
42 42
 
43
-		add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) );
43
+		add_filter('sensei_list_table_search_button_text', array($this, 'search_button'));
44 44
 
45 45
 	} // End __construct()
46 46
 
@@ -51,45 +51,45 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	function get_columns() {
53 53
 
54
-		switch( $this->view ) {
54
+		switch ($this->view) {
55 55
 			case 'user' :
56 56
 				$columns = array(
57
-					'title' => __( 'Learner', 'woothemes-sensei' ),
58
-					'started' => __( 'Date Started', 'woothemes-sensei' ),
59
-					'completed' => __( 'Date Completed', 'woothemes-sensei' ),
60
-					'user_status' => __( 'Status', 'woothemes-sensei' ),
61
-					'percent' => __( 'Percent Complete', 'woothemes-sensei' ),
57
+					'title' => __('Learner', 'woothemes-sensei'),
58
+					'started' => __('Date Started', 'woothemes-sensei'),
59
+					'completed' => __('Date Completed', 'woothemes-sensei'),
60
+					'user_status' => __('Status', 'woothemes-sensei'),
61
+					'percent' => __('Percent Complete', 'woothemes-sensei'),
62 62
 				);
63 63
 				break;
64 64
 
65 65
 			case 'lesson' :
66 66
 			default:
67
-				if ( $this->user_id ) {
67
+				if ($this->user_id) {
68 68
 
69 69
 					$columns = array(
70
-						'title' => __( 'Lesson', 'woothemes-sensei' ),
71
-						'started' => __( 'Date Started', 'woothemes-sensei' ),
72
-						'completed' => __( 'Date Completed', 'woothemes-sensei' ),
73
-						'user_status' => __( 'Status', 'woothemes-sensei' ),
74
-						'grade' => __( 'Grade', 'woothemes-sensei' ),
70
+						'title' => __('Lesson', 'woothemes-sensei'),
71
+						'started' => __('Date Started', 'woothemes-sensei'),
72
+						'completed' => __('Date Completed', 'woothemes-sensei'),
73
+						'user_status' => __('Status', 'woothemes-sensei'),
74
+						'grade' => __('Grade', 'woothemes-sensei'),
75 75
 					);
76 76
 
77 77
 				} else {
78 78
 
79 79
 					$columns = array(
80
-						'title' => __( 'Lesson', 'woothemes-sensei' ),
81
-						'num_learners' => __( 'Learners', 'woothemes-sensei' ),
82
-						'completions' => __( 'Completed', 'woothemes-sensei' ),
83
-						'average_grade' => __( 'Average Grade', 'woothemes-sensei' ),
80
+						'title' => __('Lesson', 'woothemes-sensei'),
81
+						'num_learners' => __('Learners', 'woothemes-sensei'),
82
+						'completions' => __('Completed', 'woothemes-sensei'),
83
+						'average_grade' => __('Average Grade', 'woothemes-sensei'),
84 84
 					);
85 85
 
86 86
 				}
87 87
 				break;
88 88
 		}
89 89
 		// Backwards compatible
90
-		$columns = apply_filters( 'sensei_analysis_course_' . $this->view . '_columns', $columns, $this );
90
+		$columns = apply_filters('sensei_analysis_course_'.$this->view.'_columns', $columns, $this);
91 91
 		// Moving forward, single filter with args
92
-		$columns = apply_filters( 'sensei_analysis_course_columns', $columns, $this );
92
+		$columns = apply_filters('sensei_analysis_course_columns', $columns, $this);
93 93
 		return $columns;
94 94
 	}
95 95
 
@@ -100,46 +100,46 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	function get_sortable_columns() {
102 102
 
103
-		switch( $this->view ) {
103
+		switch ($this->view) {
104 104
 			case 'user' :
105 105
 				$columns = array(
106
-					'title' => array( 'title', false ),
107
-					'started' => array( 'started', false ),
108
-					'completed' => array( 'completed', false ),
109
-					'user_status' => array( 'user_status', false ),
106
+					'title' => array('title', false),
107
+					'started' => array('started', false),
108
+					'completed' => array('completed', false),
109
+					'user_status' => array('user_status', false),
110 110
 //					'grade' => array( 'grade', false ),
111
-					'percent' => array( 'percent', false )
111
+					'percent' => array('percent', false)
112 112
 				);
113 113
 				break;
114 114
 
115 115
 			case 'lesson' :
116 116
 			default:
117
-				if ( $this->user_id ) {
117
+				if ($this->user_id) {
118 118
 
119 119
 					$columns = array(
120
-						'title' => array( 'title', false ),
121
-						'started' => array( 'started', false ),
122
-						'completed' => array( 'completed', false ),
123
-						'user_status' => array( 'user_status', false ),
124
-						'grade' => array( 'grade', false ),
120
+						'title' => array('title', false),
121
+						'started' => array('started', false),
122
+						'completed' => array('completed', false),
123
+						'user_status' => array('user_status', false),
124
+						'grade' => array('grade', false),
125 125
 					);
126 126
 
127 127
 				} else {
128 128
 
129 129
 					$columns = array(
130
-						'title' => array( 'title', false ),
131
-						'num_learners' => array( 'num_learners', false ),
132
-						'completions' => array( 'completions', false ),
133
-						'average_grade' => array( 'average_grade', false )
130
+						'title' => array('title', false),
131
+						'num_learners' => array('num_learners', false),
132
+						'completions' => array('completions', false),
133
+						'average_grade' => array('average_grade', false)
134 134
 					);
135 135
 
136 136
 				}
137 137
 				break;
138 138
 		}
139 139
 		// Backwards compatible
140
-		$columns = apply_filters( 'sensei_analysis_course_' . $this->view . '_columns_sortable', $columns, $this );
140
+		$columns = apply_filters('sensei_analysis_course_'.$this->view.'_columns_sortable', $columns, $this);
141 141
 		// Moving forward, single filter with args
142
-		$columns = apply_filters( 'sensei_analysis_course_columns_sortable', $columns, $this );
142
+		$columns = apply_filters('sensei_analysis_course_columns_sortable', $columns, $this);
143 143
 		return $columns;
144 144
 	}
145 145
 
@@ -153,32 +153,32 @@  discard block
 block discarded – undo
153 153
 
154 154
 		// Handle orderby (needs work)
155 155
 		$orderby = '';
156
-		if ( !empty( $_GET['orderby'] ) ) {
157
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
158
-				$orderby = esc_html( $_GET['orderby'] );
156
+		if ( ! empty($_GET['orderby'])) {
157
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
158
+				$orderby = esc_html($_GET['orderby']);
159 159
 			} // End If Statement
160 160
 		}
161 161
 
162 162
 		// Handle order
163 163
 		$order = 'ASC';
164
-		if ( !empty( $_GET['order'] ) ) {
165
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
164
+		if ( ! empty($_GET['order'])) {
165
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
166 166
 		}
167 167
 
168 168
 		// Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids
169 169
 		$search = false;
170
-		if ( !empty( $_GET['s'] ) ) {
171
-			$search = esc_html( $_GET['s'] );
170
+		if ( ! empty($_GET['s'])) {
171
+			$search = esc_html($_GET['s']);
172 172
 		} // End If Statement
173 173
 		$this->search = $search;
174 174
 
175
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
176
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
175
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
176
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
177 177
 
178 178
 		$paged = $this->get_pagenum();
179 179
 		$offset = 0;
180
-		if ( !empty($paged) ) {
181
-			$offset = $per_page * ( $paged - 1 );
180
+		if ( ! empty($paged)) {
181
+			$offset = $per_page * ($paged - 1);
182 182
 		} // End If Statement
183 183
 
184 184
 		$args = array(
@@ -187,28 +187,28 @@  discard block
 block discarded – undo
187 187
 			'orderby' => $orderby,
188 188
 			'order' => $order,
189 189
 		);
190
-		if ( $this->search ) {
190
+		if ($this->search) {
191 191
 			$args['search'] = $this->search;
192 192
 		} // End If Statement
193 193
 
194
-		switch( $this->view ) {
194
+		switch ($this->view) {
195 195
 			case 'user' :
196
-				$this->items = $this->get_course_statuses( $args );
196
+				$this->items = $this->get_course_statuses($args);
197 197
 				break;
198 198
 
199 199
 			case 'lesson':
200 200
 			default:
201
-				$this->items = $this->get_lessons( $args );
201
+				$this->items = $this->get_lessons($args);
202 202
 				break;
203 203
 		}
204 204
 
205 205
 		$total_items = $this->total_items;
206
-		$total_pages = ceil( $total_items / $per_page );
207
-		$this->set_pagination_args( array(
206
+		$total_pages = ceil($total_items / $per_page);
207
+		$this->set_pagination_args(array(
208 208
 			'total_items' => $total_items,
209 209
 			'total_pages' => $total_pages,
210 210
 			'per_page' => $per_page
211
-		) );
211
+		));
212 212
 	}
213 213
 
214 214
 	/**
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @since  1.7.0
217 217
 	 * @return data
218 218
 	 */
219
-	public function generate_report( $report ) {
219
+	public function generate_report($report) {
220 220
 
221 221
 		$data = array();
222 222
 
@@ -224,22 +224,22 @@  discard block
 block discarded – undo
224 224
 
225 225
 		// Handle orderby
226 226
 		$orderby = '';
227
-		if ( !empty( $_GET['orderby'] ) ) {
228
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
229
-				$orderby = esc_html( $_GET['orderby'] );
227
+		if ( ! empty($_GET['orderby'])) {
228
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
229
+				$orderby = esc_html($_GET['orderby']);
230 230
 			} // End If Statement
231 231
 		}
232 232
 
233 233
 		// Handle order
234 234
 		$order = 'ASC';
235
-		if ( !empty( $_GET['order'] ) ) {
236
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
235
+		if ( ! empty($_GET['order'])) {
236
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
237 237
 		}
238 238
 
239 239
 		// Handle search
240 240
 		$search = false;
241
-		if ( !empty( $_GET['s'] ) ) {
242
-			$search = esc_html( $_GET['s'] );
241
+		if ( ! empty($_GET['s'])) {
242
+			$search = esc_html($_GET['s']);
243 243
 		} // End If Statement
244 244
 		$this->search = $search;
245 245
 
@@ -247,32 +247,32 @@  discard block
 block discarded – undo
247 247
 			'orderby' => $orderby,
248 248
 			'order' => $order,
249 249
 		);
250
-		if ( $this->search ) {
250
+		if ($this->search) {
251 251
 			$args['search'] = $this->search;
252 252
 		} // End If Statement
253 253
 
254 254
 		// Start the csv with the column headings
255 255
 		$column_headers = array();
256 256
 		$columns = $this->get_columns();
257
-		foreach( $columns AS $key => $title ) {
257
+		foreach ($columns AS $key => $title) {
258 258
 			$column_headers[] = $title;
259 259
 		}
260 260
 		$data[] = $column_headers;
261 261
 
262
-		switch( $this->view ) {
262
+		switch ($this->view) {
263 263
 			case 'user' :
264
-				$this->items = $this->get_course_statuses( $args );
264
+				$this->items = $this->get_course_statuses($args);
265 265
 				break;
266 266
 
267 267
 			case 'lesson':
268 268
 			default:
269
-				$this->items = $this->get_lessons( $args );
269
+				$this->items = $this->get_lessons($args);
270 270
 				break;
271 271
 		}
272 272
 
273 273
 		// Process each row
274
-		foreach( $this->items AS $item) {
275
-			$data[] = $this->get_row_data( $item );
274
+		foreach ($this->items AS $item) {
275
+			$data[] = $this->get_row_data($item);
276 276
 		}
277 277
 
278 278
 		return $data;
@@ -284,37 +284,37 @@  discard block
 block discarded – undo
284 284
 	 * @since  1.7.0
285 285
 	 * @param object $item The current item
286 286
 	 */
287
-	protected function get_row_data( $item ) {
287
+	protected function get_row_data($item) {
288 288
 
289
-		switch( $this->view ) {
289
+		switch ($this->view) {
290 290
 			case 'user' :
291
-				$user_start_date = get_comment_meta( $item->comment_ID, 'start', true );
291
+				$user_start_date = get_comment_meta($item->comment_ID, 'start', true);
292 292
 				$user_end_date = $item->comment_date;
293 293
 
294
-				if( 'complete' == $item->comment_approved ) {
294
+				if ('complete' == $item->comment_approved) {
295 295
 
296
-					$status =  __( 'Completed', 'woothemes-sensei' );
296
+					$status = __('Completed', 'woothemes-sensei');
297 297
 					$status_class = 'graded';
298 298
 
299 299
 				} else {
300 300
 
301
-					$status =  __( 'In Progress', 'woothemes-sensei' );
301
+					$status = __('In Progress', 'woothemes-sensei');
302 302
 					$status_class = 'in-progress';
303 303
 					$user_end_date = '';
304 304
 
305 305
 				}
306
-				$course_percent = get_comment_meta( $item->comment_ID, 'percent', true );
306
+				$course_percent = get_comment_meta($item->comment_ID, 'percent', true);
307 307
 
308 308
 				// Output users data
309
-				$user_name = Sensei_Learner::get_full_name( $item->user_id );
309
+				$user_name = Sensei_Learner::get_full_name($item->user_id);
310 310
 
311
-				if ( !$this->csv_output ) {
311
+				if ( ! $this->csv_output) {
312 312
 
313
-					$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) );
313
+					$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id), admin_url('admin.php'));
314 314
 
315
-					$user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>';
316
-					$status = sprintf( '<span class="%s">%s</span>', $status_class, $status );
317
-					if ( is_numeric($course_percent) ) {
315
+					$user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$user_name.'</a></strong>';
316
+					$status = sprintf('<span class="%s">%s</span>', $status_class, $status);
317
+					if (is_numeric($course_percent)) {
318 318
 
319 319
 						$course_percent .= '%';
320 320
 
@@ -322,19 +322,19 @@  discard block
 block discarded – undo
322 322
 
323 323
 				} // End If Statement
324 324
 
325
-				$column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $user_name,
325
+				$column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $user_name,
326 326
 												'started' => $user_start_date,
327 327
 												'completed' => $user_end_date,
328 328
 												'user_status' => $status,
329 329
 												'percent' => $course_percent,
330
-											), $item, $this );
330
+											), $item, $this);
331 331
 				break;
332 332
 
333 333
 			case 'lesson':
334 334
 			default:
335 335
 				// Displaying lessons for this Course for a specific User
336
-				if ( $this->user_id ) {
337
-					$status = __( 'Not started', 'woothemes-sensei' );
336
+				if ($this->user_id) {
337
+					$status = __('Not started', 'woothemes-sensei');
338 338
 					$user_start_date = $user_end_date = $status_class = $grade = '';
339 339
 
340 340
 					$lesson_args = array(
@@ -343,66 +343,66 @@  discard block
 block discarded – undo
343 343
 							'type' => 'sensei_lesson_status',
344 344
 							'status' => 'any',
345 345
 						);
346
-					$lesson_status = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_user_lesson', $lesson_args, $item, $this->user_id ), true );
346
+					$lesson_status = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_user_lesson', $lesson_args, $item, $this->user_id), true);
347 347
 
348
-					if ( !empty($lesson_status) ) {
349
-						$user_start_date = get_comment_meta( $lesson_status->comment_ID, 'start', true );
348
+					if ( ! empty($lesson_status)) {
349
+						$user_start_date = get_comment_meta($lesson_status->comment_ID, 'start', true);
350 350
 						$user_end_date = $lesson_status->comment_date;
351 351
 
352
-						if( 'complete' == $lesson_status->comment_approved ) {
353
-							$status = __( 'Completed', 'woothemes-sensei' );
352
+						if ('complete' == $lesson_status->comment_approved) {
353
+							$status = __('Completed', 'woothemes-sensei');
354 354
 							$status_class = 'graded';
355 355
 
356
-							$grade = __( 'No Grade', 'woothemes-sensei' );
356
+							$grade = __('No Grade', 'woothemes-sensei');
357 357
 						}
358
-						elseif( 'graded' == $lesson_status->comment_approved ) {
359
-							$status =  __( 'Graded', 'woothemes-sensei' );
358
+						elseif ('graded' == $lesson_status->comment_approved) {
359
+							$status = __('Graded', 'woothemes-sensei');
360 360
 							$status_class = 'graded';
361 361
 
362
-							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
362
+							$grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
363 363
 						}
364
-						elseif( 'passed' == $lesson_status->comment_approved ) {
365
-							$status =  __( 'Passed', 'woothemes-sensei' );
364
+						elseif ('passed' == $lesson_status->comment_approved) {
365
+							$status = __('Passed', 'woothemes-sensei');
366 366
 							$status_class = 'graded';
367 367
 
368
-							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
368
+							$grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
369 369
 						}
370
-						elseif( 'failed' == $lesson_status->comment_approved ) {
371
-							$status =  __( 'Failed', 'woothemes-sensei' );
370
+						elseif ('failed' == $lesson_status->comment_approved) {
371
+							$status = __('Failed', 'woothemes-sensei');
372 372
 							$status_class = 'failed';
373 373
 
374
-							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
374
+							$grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
375 375
 						}
376
-						elseif( 'ungraded' == $lesson_status->comment_approved ) {
377
-							$status =  __( 'Ungraded', 'woothemes-sensei' );
376
+						elseif ('ungraded' == $lesson_status->comment_approved) {
377
+							$status = __('Ungraded', 'woothemes-sensei');
378 378
 							$status_class = 'ungraded';
379 379
 
380 380
 						}
381
-						elseif( 'in-progress' == $lesson_status->comment_approved ) {
382
-							$status =  __( 'In Progress', 'woothemes-sensei' );
381
+						elseif ('in-progress' == $lesson_status->comment_approved) {
382
+							$status = __('In Progress', 'woothemes-sensei');
383 383
 							$user_end_date = '';
384 384
 						}
385 385
 					} // END lesson_status
386 386
 
387 387
 					// Output users data
388
-					if ( $this->csv_output ) {
389
-						$lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID );
388
+					if ($this->csv_output) {
389
+						$lesson_title = apply_filters('the_title', $item->post_title, $item->ID);
390 390
 					}
391 391
 					else {
392
-						$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) );
393
-						$lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>';
392
+						$url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php'));
393
+						$lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>';
394 394
 
395
-						$status = sprintf( '<span class="%s">%s</span>', $status_class, $status );
396
-						if ( is_numeric($grade) ) {
395
+						$status = sprintf('<span class="%s">%s</span>', $status_class, $status);
396
+						if (is_numeric($grade)) {
397 397
 							$grade .= '%';
398 398
 						}
399 399
 					} // End If Statement
400
-					$column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $lesson_title,
400
+					$column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $lesson_title,
401 401
 													'started' => $user_start_date,
402 402
 													'completed' => $user_end_date,
403 403
 													'user_status' => $status,
404 404
 													'grade' => $grade,
405
-												), $item, $this );
405
+												), $item, $this);
406 406
 				}
407 407
 				// Display lessons for this Course regardless of users
408 408
 				else {
@@ -412,51 +412,51 @@  discard block
 block discarded – undo
412 412
 							'type' => 'sensei_lesson_status',
413 413
 							'status' => 'any',
414 414
 						);
415
-					$lesson_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_learners', $lesson_args, $item ) );
415
+					$lesson_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_learners', $lesson_args, $item));
416 416
 
417 417
 					// Get Course Completions
418 418
 					$lesson_args = array(
419 419
 							'post_id' => $item->ID,
420 420
 							'type' => 'sensei_lesson_status',
421
-							'status' => array( 'complete', 'graded', 'passed', 'failed' ),
421
+							'status' => array('complete', 'graded', 'passed', 'failed'),
422 422
 							'count' => true,
423 423
 						);
424
-					$lesson_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_completions', $lesson_args, $item ) );
424
+					$lesson_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_completions', $lesson_args, $item));
425 425
 
426 426
 					$lesson_average_grade = __('n/a', 'woothemes-sensei');
427
-					if ( false != get_post_meta($item->ID, '_quiz_has_questions', true) ) {
427
+					if (false != get_post_meta($item->ID, '_quiz_has_questions', true)) {
428 428
 						// Get Percent Complete
429 429
 						$grade_args = array(
430 430
 								'post_id' => $item->ID,
431 431
 								'type' => 'sensei_lesson_status',
432
-								'status' => array( 'graded', 'passed', 'failed' ),
432
+								'status' => array('graded', 'passed', 'failed'),
433 433
 								'meta_key' => 'grade',
434 434
 							);
435
-						add_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) );
436
-						$lesson_grades = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_grades', $grade_args, $item ), true );
437
-						remove_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) );
435
+						add_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter'));
436
+						$lesson_grades = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_grades', $grade_args, $item), true);
437
+						remove_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter'));
438 438
 
439
-						$grade_count = !empty( $lesson_grades->total ) ? $lesson_grades->total : 1;
440
-						$grade_total = !empty( $lesson_grades->meta_sum ) ? doubleval( $lesson_grades->meta_sum ) : 0;
441
-						$lesson_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) );
439
+						$grade_count = ! empty($lesson_grades->total) ? $lesson_grades->total : 1;
440
+						$grade_total = ! empty($lesson_grades->meta_sum) ? doubleval($lesson_grades->meta_sum) : 0;
441
+						$lesson_average_grade = abs(round(doubleval($grade_total / $grade_count), 2));
442 442
 					}
443 443
 					// Output lesson data
444
-					if ( $this->csv_output ) {
445
-						$lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID );
444
+					if ($this->csv_output) {
445
+						$lesson_title = apply_filters('the_title', $item->post_title, $item->ID);
446 446
 					}
447 447
 					else {
448
-						$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) );
449
-						$lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>';
448
+						$url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php'));
449
+						$lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>';
450 450
 
451
-						if ( is_numeric( $lesson_average_grade ) ) {
451
+						if (is_numeric($lesson_average_grade)) {
452 452
 							$lesson_average_grade .= '%';
453 453
 						}
454 454
 					} // End If Statement
455
-					$column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $lesson_title,
455
+					$column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $lesson_title,
456 456
 													'num_learners' => $lesson_students,
457 457
 													'completions' => $lesson_completions,
458 458
 													'average_grade' => $lesson_average_grade,
459
-												), $item, $this );
459
+												), $item, $this);
460 460
 				} // END if
461 461
 				break;
462 462
 		} // END switch
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 	 * @since  1.7.0
470 470
 	 * @return array statuses
471 471
 	 */
472
-	private function get_course_statuses( $args ) {
472
+	private function get_course_statuses($args) {
473 473
 
474 474
 		$activity_args = array(
475 475
 				'post_id' => $this->course_id,
@@ -482,34 +482,34 @@  discard block
 block discarded – undo
482 482
 			);
483 483
 
484 484
 		// Searching users on statuses requires sub-selecting the statuses by user_ids
485
-		if ( $this->search ) {
485
+		if ($this->search) {
486 486
 			$user_args = array(
487
-				'search' => '*' . $this->search . '*',
487
+				'search' => '*'.$this->search.'*',
488 488
 				'fields' => 'ID',
489 489
 			);
490 490
 			// Filter for extending
491
-			$user_args = apply_filters( 'sensei_analysis_course_search_users', $user_args );
492
-			if ( !empty( $user_args ) ) {
493
-				$learners_search = new WP_User_Query( $user_args );
491
+			$user_args = apply_filters('sensei_analysis_course_search_users', $user_args);
492
+			if ( ! empty($user_args)) {
493
+				$learners_search = new WP_User_Query($user_args);
494 494
 				// Store for reuse on counts
495 495
 				$activity_args['user_id'] = (array) $learners_search->get_results();
496 496
 			}
497 497
 		} // End If Statement
498 498
 
499
-		$activity_args = apply_filters( 'sensei_analysis_course_filter_statuses', $activity_args );
499
+		$activity_args = apply_filters('sensei_analysis_course_filter_statuses', $activity_args);
500 500
 
501 501
 		// WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice
502
-		$this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
502
+		$this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0)));
503 503
 
504 504
 		// Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views?
505
-		if ( $this->total_items < $activity_args['offset'] ) {
506
-			$new_paged = floor( $this->total_items / $activity_args['number'] );
505
+		if ($this->total_items < $activity_args['offset']) {
506
+			$new_paged = floor($this->total_items / $activity_args['number']);
507 507
 			$activity_args['offset'] = $new_paged * $activity_args['number'];
508 508
 		}
509
-		$statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true );
509
+		$statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true);
510 510
 		// Need to always return an array, even with only 1 item
511
-		if ( !is_array($statuses) ) {
512
-			$statuses = array( $statuses );
511
+		if ( ! is_array($statuses)) {
512
+			$statuses = array($statuses);
513 513
 		}
514 514
 		return $statuses;
515 515
 	} // End get_course_statuses()
@@ -519,32 +519,32 @@  discard block
 block discarded – undo
519 519
 	 * @since  1.7.0
520 520
 	 * @return array statuses
521 521
 	 */
522
-	private function get_lessons( $args ) {
522
+	private function get_lessons($args) {
523 523
 
524
-		$lessons_args = array( 'post_type'         => 'lesson',
524
+		$lessons_args = array('post_type'         => 'lesson',
525 525
 							'posts_per_page'      => $args['number'],
526 526
 							'offset'              => $args['offset'],
527
-							'meta_key'            => '_order_' . $this->course_id,
527
+							'meta_key'            => '_order_'.$this->course_id,
528 528
 //							'orderby'             => $args['orderby'],
529 529
 							'order'               => $args['order'],
530 530
 							'meta_query'          => array(
531 531
 								array(
532 532
 									'key' => '_lesson_course',
533
-									'value' => intval( $this->course_id ),
533
+									'value' => intval($this->course_id),
534 534
 								),
535 535
 							),
536 536
 							'post_status'         => array('publish', 'private'),
537 537
 							'suppress_filters'    => 0
538 538
 							);
539
-		if ( $this->search ) {
539
+		if ($this->search) {
540 540
 			$lessons_args['s'] = $this->search;
541 541
 		}
542
-		if ( $this->csv_output ) {
542
+		if ($this->csv_output) {
543 543
 			$lessons_args['posts_per_page'] = '-1';
544 544
 		}
545 545
 
546 546
 		// Using WP_Query as get_posts() doesn't support 'found_posts'
547
-		$lessons_query = new WP_Query( apply_filters( 'sensei_analysis_course_filter_lessons', $lessons_args ) );
547
+		$lessons_query = new WP_Query(apply_filters('sensei_analysis_course_filter_lessons', $lessons_args));
548 548
 		$this->total_items = $lessons_query->found_posts;
549 549
 		return $lessons_query->posts;
550 550
 	} // End get_lessons()
@@ -556,17 +556,17 @@  discard block
 block discarded – undo
556 556
 	 * @return void
557 557
 	 */
558 558
 	public function no_items() {
559
-		switch( $this->view ) {
559
+		switch ($this->view) {
560 560
 			case 'user' :
561
-				$text = __( 'No learners found.', 'woothemes-sensei' );
561
+				$text = __('No learners found.', 'woothemes-sensei');
562 562
 				break;
563 563
 
564 564
 			case 'lesson':
565 565
 			default:
566
-				$text = __( 'No lessons found.', 'woothemes-sensei' );
566
+				$text = __('No lessons found.', 'woothemes-sensei');
567 567
 				break;
568 568
 		}
569
-		echo apply_filters( 'sensei_analysis_course_no_items_text', $text );
569
+		echo apply_filters('sensei_analysis_course_no_items_text', $text);
570 570
 	} // End no_items()
571 571
 
572 572
 	/**
@@ -575,25 +575,25 @@  discard block
 block discarded – undo
575 575
 	 * @return void
576 576
 	 */
577 577
 	public function data_table_header() {
578
-		if ( $this->user_id ) {
579
-			$learners_text = __( 'Other Learners taking this Course', 'woothemes-sensei' );
578
+		if ($this->user_id) {
579
+			$learners_text = __('Other Learners taking this Course', 'woothemes-sensei');
580 580
 		}
581 581
 		else {
582
-			$learners_text = __( 'Learners taking this Course', 'woothemes-sensei' );
582
+			$learners_text = __('Learners taking this Course', 'woothemes-sensei');
583 583
 		}
584
-		$lessons_text = __( 'Lessons in this Course', 'woothemes-sensei' );
584
+		$lessons_text = __('Lessons in this Course', 'woothemes-sensei');
585 585
 
586 586
 		$url_args = array(
587 587
 			'page' => $this->page_slug,
588 588
 			'course_id' => $this->course_id,
589 589
 		);
590
-		$learners_url = esc_url( add_query_arg( array_merge( $url_args, array( 'view' => 'user' ) ), admin_url( 'admin.php' ) ) );
591
-		$lessons_url = esc_url( add_query_arg( array_merge( $url_args, array( 'view' => 'lesson' ) ), admin_url( 'admin.php' ) ) );
590
+		$learners_url = esc_url(add_query_arg(array_merge($url_args, array('view' => 'user')), admin_url('admin.php')));
591
+		$lessons_url = esc_url(add_query_arg(array_merge($url_args, array('view' => 'lesson')), admin_url('admin.php')));
592 592
 
593 593
 		$learners_class = $lessons_class = '';
594 594
 
595 595
 		$menu = array();
596
-		switch( $this->view ) {
596
+		switch ($this->view) {
597 597
 			case 'user' :
598 598
 				$learners_class = 'current';
599 599
 				break;
@@ -603,17 +603,17 @@  discard block
 block discarded – undo
603 603
 				$lessons_class = 'current';
604 604
 				break;
605 605
 		}
606
-		$menu['lesson'] = sprintf( '<a href="%s" class="%s">%s</a>', $lessons_url, $lessons_class, $lessons_text );
607
-		$menu['user'] = sprintf( '<a href="%s" class="%s">%s</a>', $learners_url, $learners_class, $learners_text );
608
-
609
-		$menu = apply_filters( 'sensei_analysis_course_sub_menu', $menu );
610
-		if ( !empty($menu) ) {
611
-			echo '<ul class="subsubsub">' . "\n";
612
-			foreach ( $menu as $class => $item ) {
613
-				$menu[ $class ] = "\t<li class='$class'>$item";
606
+		$menu['lesson'] = sprintf('<a href="%s" class="%s">%s</a>', $lessons_url, $lessons_class, $lessons_text);
607
+		$menu['user'] = sprintf('<a href="%s" class="%s">%s</a>', $learners_url, $learners_class, $learners_text);
608
+
609
+		$menu = apply_filters('sensei_analysis_course_sub_menu', $menu);
610
+		if ( ! empty($menu)) {
611
+			echo '<ul class="subsubsub">'."\n";
612
+			foreach ($menu as $class => $item) {
613
+				$menu[$class] = "\t<li class='$class'>$item";
614 614
 			}
615
-			echo implode( " |</li>\n", $menu ) . "</li>\n";
616
-			echo '</ul>' . "\n";
615
+			echo implode(" |</li>\n", $menu)."</li>\n";
616
+			echo '</ul>'."\n";
617 617
 		}
618 618
 	} // End data_table_header()
619 619
 
@@ -624,19 +624,19 @@  discard block
 block discarded – undo
624 624
 	 */
625 625
 	public function data_table_footer() {
626 626
 
627
-		$course = get_post( $this->course_id );
628
-		$report = sanitize_title( $course->post_title ) . '-' . $this->view . 's-overview';
629
-		if ( $this->user_id ) {
630
-            $user_name = Sensei_Learner::get_full_name( $this->user_id );
631
-			$report = sanitize_title( $user_name  ) . '-' . $report;
627
+		$course = get_post($this->course_id);
628
+		$report = sanitize_title($course->post_title).'-'.$this->view.'s-overview';
629
+		if ($this->user_id) {
630
+            $user_name = Sensei_Learner::get_full_name($this->user_id);
631
+			$report = sanitize_title($user_name).'-'.$report;
632 632
 		}
633 633
 
634
-		$url_args = array( 'page' => $this->page_slug, 'course_id' => $this->course_id, 'view' => $this->view, 'sensei_report_download' => $report );
635
-		if ( $this->user_id ) {
634
+		$url_args = array('page' => $this->page_slug, 'course_id' => $this->course_id, 'view' => $this->view, 'sensei_report_download' => $report);
635
+		if ($this->user_id) {
636 636
 			$url_args['user_id'] = $this->user_id;
637 637
 		}
638
-		$url =  add_query_arg( $url_args, admin_url( 'admin.php' ) );
639
-		echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>';
638
+		$url = add_query_arg($url_args, admin_url('admin.php'));
639
+		echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>';
640 640
 	} // End data_table_footer()
641 641
 
642 642
 	/**
@@ -644,15 +644,15 @@  discard block
 block discarded – undo
644 644
 	 * @since  1.7.0
645 645
 	 * @return string $text
646 646
 	 */
647
-	public function search_button( $text = '' ) {
648
-		switch( $this->view ) {
647
+	public function search_button($text = '') {
648
+		switch ($this->view) {
649 649
 			case 'user':
650
-				$text = __( 'Search Learners', 'woothemes-sensei' );
650
+				$text = __('Search Learners', 'woothemes-sensei');
651 651
 			break;
652 652
 
653 653
 			case 'lesson':
654 654
 			default:
655
-				$text = __( 'Search Lessons', 'woothemes-sensei' );
655
+				$text = __('Search Lessons', 'woothemes-sensei');
656 656
 			break;
657 657
 		} // End Switch Statement
658 658
 
Please login to merge, or discard this patch.
includes/class-sensei-updates.php 4 patches
Braces   +44 added lines, -26 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 Updates Class
@@ -769,9 +772,15 @@  discard block
 block discarded – undo
769 772
 		$all_activity = get_comments( array( 'status' => 'approve' ) );
770 773
 		$activity_count = array();
771 774
 		foreach( $all_activity as $activity ) {
772
-			if( '' == $activity->comment_type ) continue;
773
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
774
-			if( 0 == $activity->user_id ) continue;
775
+			if( '' == $activity->comment_type ) {
776
+				continue;
777
+			}
778
+			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) {
779
+				continue;
780
+			}
781
+			if( 0 == $activity->user_id ) {
782
+				continue;
783
+			}
775 784
 			$activity_count[] = $activity->comment_ID;
776 785
 		}
777 786
 
@@ -784,9 +793,15 @@  discard block
 block discarded – undo
784 793
 		$activities = get_comments( $args );
785 794
 
786 795
 		foreach( $activities as $activity ) {
787
-			if( '' == $activity->comment_type ) continue;
788
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
789
-			if( 0 == $activity->user_id ) continue;
796
+			if( '' == $activity->comment_type ) {
797
+				continue;
798
+			}
799
+			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) {
800
+				continue;
801
+			}
802
+			if( 0 == $activity->user_id ) {
803
+				continue;
804
+			}
790 805
 
791 806
 			$user_exists = get_userdata( $activity->user_id );
792 807
 
@@ -845,7 +860,9 @@  discard block
 block discarded – undo
845 860
 
846 861
 		foreach( $questions as $question ) {
847 862
 
848
-			if( ! isset( $question->ID ) ) continue;
863
+			if( ! isset( $question->ID ) ) {
864
+				continue;
865
+			}
849 866
 
850 867
 			$quiz_id = get_post_meta( $question->ID, '_quiz_id', true );
851 868
 
@@ -882,7 +899,9 @@  discard block
 block discarded – undo
882 899
 
883 900
 		foreach( $quizzes as $quiz ) {
884 901
 
885
-			if( ! isset( $quiz->ID ) ) continue;
902
+			if( ! isset( $quiz->ID ) ) {
903
+				continue;
904
+			}
886 905
 
887 906
 			if( isset( $lesson_completion ) && 'passed' == $lesson_completion ) {
888 907
 				update_post_meta( $quiz->ID, '_pass_required', 'on' );
@@ -910,7 +929,9 @@  discard block
 block discarded – undo
910 929
 
911 930
 		foreach( $lessons as $lesson ) {
912 931
 
913
-			if( ! isset( $lesson->ID ) ) continue;
932
+			if( ! isset( $lesson->ID ) ) {
933
+				continue;
934
+			}
914 935
 
915 936
 			$course_id = get_post_meta( $lesson->ID, '_lesson_course', true);
916 937
 
@@ -984,11 +1005,15 @@  discard block
 block discarded – undo
984 1005
 
985 1006
 		foreach( $quizzes as $quiz ) {
986 1007
 
987
-			if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) continue;
1008
+			if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) {
1009
+				continue;
1010
+			}
988 1011
 
989 1012
 			$lesson_id = get_post_meta( $quiz->ID, '_quiz_lesson', true );
990 1013
 
991
-			if( empty( $lesson_id ) ) continue;
1014
+			if( empty( $lesson_id ) ) {
1015
+				continue;
1016
+			}
992 1017
 
993 1018
 			$data = array(
994 1019
 				'ID' => $quiz->ID,
@@ -1071,8 +1096,7 @@  discard block
 block discarded – undo
1071 1096
 				delete_post_meta( $quiz_id, '_quiz_passmark' );
1072 1097
 				delete_post_meta( $lesson_id, '_quiz_has_questions' );
1073 1098
 				$d_count++;
1074
-			}
1075
-			else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1099
+			} else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1076 1100
 
1077 1101
 				// Quiz has no questions, drop the corresponding data
1078 1102
 				update_post_meta( $lesson_id, '_quiz_has_questions', true );
@@ -1222,20 +1246,16 @@  discard block
 block discarded – undo
1222 1246
 							// Check if the user has to get the passmark and has or not
1223 1247
 							if ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] <= $quiz_grade ) {
1224 1248
 								$status = 'passed';
1225
-							}
1226
-							elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) {
1249
+							} elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) {
1227 1250
 								$status = 'failed';
1228
-							}
1229
-							else {
1251
+							} else {
1230 1252
 								$status = 'graded';
1231 1253
 							}
1232
-						}
1233
-						else {
1254
+						} else {
1234 1255
 							// If the lesson has a quiz, but the user doesn't have a grade, it's not yet been graded
1235 1256
 							$status = 'ungraded';
1236 1257
 						}
1237
-					}
1238
-					else {
1258
+					} else {
1239 1259
 						// Lesson has no quiz, so it can only ever be this status
1240 1260
 						$status = 'complete';
1241 1261
 					}
@@ -1374,8 +1394,7 @@  discard block
 block discarded – undo
1374 1394
 					}
1375 1395
 					$meta_data['complete'] = $lessons_completed;
1376 1396
 					$meta_data['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) );
1377
-				}
1378
-				else {
1397
+				} else {
1379 1398
 					// Course has no lessons, therefore cannot be 'complete'
1380 1399
 					$status = 'in-progress';
1381 1400
 				}
@@ -1506,8 +1525,7 @@  discard block
 block discarded – undo
1506 1525
 									$lessons_completed++;
1507 1526
 									break;
1508 1527
 							}
1509
-						}
1510
-						else {
1528
+						} else {
1511 1529
 							switch ( $lesson_status ) {
1512 1530
 								case 'complete': // Lesson has no quiz/questions
1513 1531
 								case 'graded': // Lesson has quiz, but it's not important what the grade was
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1424,8 +1424,8 @@  discard block
 block discarded – undo
1424 1424
 	 *
1425 1425
 	 * @global type $woothemes_sensei
1426 1426
 	 * @global type $wpdb
1427
-	 * @param type $n
1428
-	 * @param type $offset
1427
+	 * @param integer $n
1428
+	 * @param integer $offset
1429 1429
 	 * @return boolean
1430 1430
 	 */
1431 1431
 	function status_changes_repair_course_statuses( $n = 50, $offset = 0 ) {
@@ -1669,8 +1669,8 @@  discard block
 block discarded – undo
1669 1669
 	 * Update the comment counts for all Courses and Lessons now that sensei comments will no longer be counted.
1670 1670
 	 *
1671 1671
 	 * @global type $wpdb
1672
-	 * @param type $n
1673
-	 * @param type $offset
1672
+	 * @param integer $n
1673
+	 * @param integer $offset
1674 1674
 	 * @return boolean
1675 1675
 	 */
1676 1676
 	public function update_comment_course_lesson_comment_counts( $n = 50, $offset = 0 ) {
Please login to merge, or discard this patch.
Indentation   +276 added lines, -276 removed lines patch added patch discarded remove patch
@@ -12,107 +12,107 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class Sensei_Updates
14 14
 {
15
-    public $token = 'woothemes-sensei';
16
-    public $version;
17
-    public $updates_run;
18
-    public $updates;
19
-    private $parent;
20
-
21
-    /**
22
-     * Constructor.
23
-     *
24
-     * @access  public
25
-     * @since   1.1.0
26
-     * @param   string $parent The main Sensei object by Ref.
27
-     * @return  void
28
-     */
29
-    public function __construct($parent)
30
-    {
15
+	public $token = 'woothemes-sensei';
16
+	public $version;
17
+	public $updates_run;
18
+	public $updates;
19
+	private $parent;
20
+
21
+	/**
22
+	 * Constructor.
23
+	 *
24
+	 * @access  public
25
+	 * @since   1.1.0
26
+	 * @param   string $parent The main Sensei object by Ref.
27
+	 * @return  void
28
+	 */
29
+	public function __construct($parent)
30
+	{
31 31
 
32 32
 		// Setup object data
33 33
 		$this->parent = $parent;
34 34
 		$this->updates_run = get_option( 'woothemes-sensei-upgrades', array() );
35 35
 
36
-        // The list of upgrades to run
37
-        $this->updates = array('1.1.0' => array('auto' => array('assign_role_caps' => array('title' => __('Assign role capabilities', 'woothemes-sensei'), 'desc' => __('Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei'), 'product' => 'Sensei')),
38
-            'manual' => array()
39
-        ),
40
-            '1.3.0' => array('auto' => array('set_default_quiz_grade_type' => array('title' => __('Set default quiz grade type', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to the default \'auto\' grade type.', 'woothemes-sensei')),
41
-                'set_default_question_type' => array('title' => __('Set default question type', 'woothemes-sensei'), 'desc' => __('Sets all questions to the default \'multiple choice\' type.', 'woothemes-sensei'))
42
-            ),
43
-                'manual' => array('update_question_answer_data' => array('title' => __('Update question answer data', 'woothemes-sensei'), 'desc' => __('Updates questions to use the new question types structure.', 'woothemes-sensei')))
44
-            ),
45
-            '1.4.0' => array('auto' => array('update_question_grade_points' => array('title' => __('Update question grade points', 'woothemes-sensei'), 'desc' => __('Sets all question grade points to the default value of \'1\'.', 'woothemes-sensei'))),
46
-                'manual' => array()
47
-            ),
48
-            '1.5.0' => array('auto' => array('convert_essay_paste_questions' => array('title' => __('Convert essay paste questions into multi-line questions', 'woothemes-sensei'), 'desc' => __('Converts all essay paste questions into multi-line questions as the essay paste question type was removed in v1.5.0.', 'woothemes-sensei'))),
49
-                'manual' => array('set_random_question_order' => array('title' => __('Set all quizzes to have a random question order', 'woothemes-sensei'), 'desc' => __('Sets the order all of questions in all quizzes to a random order, which can be switched off per quiz.', 'woothemes-sensei')),
50
-                    'set_default_show_question_count' => array('title' => __('Set all quizzes to show all questions', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to show all questions - this can be changed per quiz.', 'woothemes-sensei')),
51
-                    'remove_deleted_user_activity' => array('title' => __('Remove Sensei activity for deleted users', 'woothemes-sensei'), 'desc' => __('Removes all course, lesson &amp; quiz activity for users that have already been deleted from the database. This will fix incorrect learner counts in the Analysis section.', 'woothemes-sensei')))
52
-            ),
53
-            '1.6.0' => array('auto' => array('add_teacher_role' => array('title' => __('Add \'Teacher\' role', 'woothemes-sensei'), 'desc' => __('Adds a \'Teacher\' role to your WordPress site that will allow users to mange the Grading and Analysis pages.', 'woothemes-sensei')),
54
-                'add_sensei_caps' => array('title' => __('Add administrator capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei\' and \'manage_sensei_grades\' capabilities to the Administrator role.', 'woothemes-sensei')),
55
-                'restructure_question_meta' => array('title' => __('Restructure question meta data', 'woothemes-sensei'), 'desc' => __('Restructures the question meta data as it relates to quizzes - this accounts for changes in the data structure in v1.6+.', 'woothemes-sensei')),
56
-                'update_quiz_settings' => array('title' => __('Add new quiz settings', 'woothemes-sensei'), 'desc' => __('Adds new settings to quizzes that were previously registered as global settings.', 'woothemes-sensei')),
57
-                'reset_lesson_order_meta' => array('title' => __('Set default order of lessons', 'woothemes-sensei'), 'desc' => __('Adds data to lessons to ensure that they show up on the \'Order Lessons\' screen - if this update has been run once before then it will reset all lessons to the default order.', 'woothemes-sensei')),),
58
-                'manual' => array()
59
-            ),
60
-            '1.7.0' => array('auto' => array('add_editor_caps' => array('title' => __('Add Editor capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei_grades\' capability to the Editor role.', 'woothemes-sensei')),),
61
-                'forced' => array('update_question_gap_fill_separators' => array('title' => __('Update Gap Fill questions', 'woothemes-sensei'), 'desc' => __('Updates the format of gap fill questions to allow auto grading and greater flexibility in matching.', 'woothemes-sensei')),
62
-                    'update_quiz_lesson_relationship' => array('title' => __('Restructure quiz lesson relationship', 'woothemes-sensei'), 'desc' => __('Adds data to quizzes and lessons to ensure that they maintain their 1 to 1 relationship.', 'woothemes-sensei')),
63
-                    'status_changes_fix_lessons' => array('title' => __('Update lesson statuses', 'woothemes-sensei'), 'desc' => __('Update existing lesson statuses.', 'woothemes-sensei')),
64
-                    'status_changes_convert_lessons' => array('title' => __('Convert lesson statuses', 'woothemes-sensei'), 'desc' => __('Convert to new lesson statuses.', 'woothemes-sensei')),
65
-                    'status_changes_convert_courses' => array('title' => __('Convert course statuses', 'woothemes-sensei'), 'desc' => __('Convert to new course statuses.', 'woothemes-sensei')),
66
-                    'status_changes_convert_questions' => array('title' => __('Convert question statuses', 'woothemes-sensei'), 'desc' => __('Convert to new question statuses.', 'woothemes-sensei')),
67
-                    'update_legacy_sensei_comments_status' => array('title' => __('Convert legacy Sensei activity types', 'woothemes-sensei'), 'desc' => __('Convert all legacy Sensei activity types such as \'sensei_lesson_start\' and \'sensei_user_answer\' to new status format.', 'woothemes-sensei')),
68
-                    'update_comment_course_lesson_comment_counts' => array('title' => __('Update comment counts', 'woothemes-sensei'), 'desc' => __('Update comment counts on Courses and Lessons due to status changes.', 'woothemes-sensei')),),
69
-            ),
70
-            '1.7.2' => array('auto' => array('index_comment_status_field' => array('title' => __('Add database index to comment statuses', 'woothemes-sensei'), 'desc' => __('This indexes the comment statuses in the database, which will speed up all Sensei activity queries.', 'woothemes-sensei')),),
71
-                /*'manual' 		=> array( 'remove_legacy_comments' => array( 'title' => __( 'Remove legacy Sensei activity types', 'woothemes-sensei' ), 'desc' => __( 'This removes all legacy (pre-1.7) Sensei activity types - only run this update once the update to v1.7 is complete and everything is stable.', 'woothemes-sensei' ) ) )*/
72
-            ),
73
-            '1.8.0' => array('auto' => array('enhance_teacher_role' => array('title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.'),),
74
-                'manual' => array()
75
-            ),
76
-        );
36
+		// The list of upgrades to run
37
+		$this->updates = array('1.1.0' => array('auto' => array('assign_role_caps' => array('title' => __('Assign role capabilities', 'woothemes-sensei'), 'desc' => __('Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei'), 'product' => 'Sensei')),
38
+			'manual' => array()
39
+		),
40
+			'1.3.0' => array('auto' => array('set_default_quiz_grade_type' => array('title' => __('Set default quiz grade type', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to the default \'auto\' grade type.', 'woothemes-sensei')),
41
+				'set_default_question_type' => array('title' => __('Set default question type', 'woothemes-sensei'), 'desc' => __('Sets all questions to the default \'multiple choice\' type.', 'woothemes-sensei'))
42
+			),
43
+				'manual' => array('update_question_answer_data' => array('title' => __('Update question answer data', 'woothemes-sensei'), 'desc' => __('Updates questions to use the new question types structure.', 'woothemes-sensei')))
44
+			),
45
+			'1.4.0' => array('auto' => array('update_question_grade_points' => array('title' => __('Update question grade points', 'woothemes-sensei'), 'desc' => __('Sets all question grade points to the default value of \'1\'.', 'woothemes-sensei'))),
46
+				'manual' => array()
47
+			),
48
+			'1.5.0' => array('auto' => array('convert_essay_paste_questions' => array('title' => __('Convert essay paste questions into multi-line questions', 'woothemes-sensei'), 'desc' => __('Converts all essay paste questions into multi-line questions as the essay paste question type was removed in v1.5.0.', 'woothemes-sensei'))),
49
+				'manual' => array('set_random_question_order' => array('title' => __('Set all quizzes to have a random question order', 'woothemes-sensei'), 'desc' => __('Sets the order all of questions in all quizzes to a random order, which can be switched off per quiz.', 'woothemes-sensei')),
50
+					'set_default_show_question_count' => array('title' => __('Set all quizzes to show all questions', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to show all questions - this can be changed per quiz.', 'woothemes-sensei')),
51
+					'remove_deleted_user_activity' => array('title' => __('Remove Sensei activity for deleted users', 'woothemes-sensei'), 'desc' => __('Removes all course, lesson &amp; quiz activity for users that have already been deleted from the database. This will fix incorrect learner counts in the Analysis section.', 'woothemes-sensei')))
52
+			),
53
+			'1.6.0' => array('auto' => array('add_teacher_role' => array('title' => __('Add \'Teacher\' role', 'woothemes-sensei'), 'desc' => __('Adds a \'Teacher\' role to your WordPress site that will allow users to mange the Grading and Analysis pages.', 'woothemes-sensei')),
54
+				'add_sensei_caps' => array('title' => __('Add administrator capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei\' and \'manage_sensei_grades\' capabilities to the Administrator role.', 'woothemes-sensei')),
55
+				'restructure_question_meta' => array('title' => __('Restructure question meta data', 'woothemes-sensei'), 'desc' => __('Restructures the question meta data as it relates to quizzes - this accounts for changes in the data structure in v1.6+.', 'woothemes-sensei')),
56
+				'update_quiz_settings' => array('title' => __('Add new quiz settings', 'woothemes-sensei'), 'desc' => __('Adds new settings to quizzes that were previously registered as global settings.', 'woothemes-sensei')),
57
+				'reset_lesson_order_meta' => array('title' => __('Set default order of lessons', 'woothemes-sensei'), 'desc' => __('Adds data to lessons to ensure that they show up on the \'Order Lessons\' screen - if this update has been run once before then it will reset all lessons to the default order.', 'woothemes-sensei')),),
58
+				'manual' => array()
59
+			),
60
+			'1.7.0' => array('auto' => array('add_editor_caps' => array('title' => __('Add Editor capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei_grades\' capability to the Editor role.', 'woothemes-sensei')),),
61
+				'forced' => array('update_question_gap_fill_separators' => array('title' => __('Update Gap Fill questions', 'woothemes-sensei'), 'desc' => __('Updates the format of gap fill questions to allow auto grading and greater flexibility in matching.', 'woothemes-sensei')),
62
+					'update_quiz_lesson_relationship' => array('title' => __('Restructure quiz lesson relationship', 'woothemes-sensei'), 'desc' => __('Adds data to quizzes and lessons to ensure that they maintain their 1 to 1 relationship.', 'woothemes-sensei')),
63
+					'status_changes_fix_lessons' => array('title' => __('Update lesson statuses', 'woothemes-sensei'), 'desc' => __('Update existing lesson statuses.', 'woothemes-sensei')),
64
+					'status_changes_convert_lessons' => array('title' => __('Convert lesson statuses', 'woothemes-sensei'), 'desc' => __('Convert to new lesson statuses.', 'woothemes-sensei')),
65
+					'status_changes_convert_courses' => array('title' => __('Convert course statuses', 'woothemes-sensei'), 'desc' => __('Convert to new course statuses.', 'woothemes-sensei')),
66
+					'status_changes_convert_questions' => array('title' => __('Convert question statuses', 'woothemes-sensei'), 'desc' => __('Convert to new question statuses.', 'woothemes-sensei')),
67
+					'update_legacy_sensei_comments_status' => array('title' => __('Convert legacy Sensei activity types', 'woothemes-sensei'), 'desc' => __('Convert all legacy Sensei activity types such as \'sensei_lesson_start\' and \'sensei_user_answer\' to new status format.', 'woothemes-sensei')),
68
+					'update_comment_course_lesson_comment_counts' => array('title' => __('Update comment counts', 'woothemes-sensei'), 'desc' => __('Update comment counts on Courses and Lessons due to status changes.', 'woothemes-sensei')),),
69
+			),
70
+			'1.7.2' => array('auto' => array('index_comment_status_field' => array('title' => __('Add database index to comment statuses', 'woothemes-sensei'), 'desc' => __('This indexes the comment statuses in the database, which will speed up all Sensei activity queries.', 'woothemes-sensei')),),
71
+				/*'manual' 		=> array( 'remove_legacy_comments' => array( 'title' => __( 'Remove legacy Sensei activity types', 'woothemes-sensei' ), 'desc' => __( 'This removes all legacy (pre-1.7) Sensei activity types - only run this update once the update to v1.7 is complete and everything is stable.', 'woothemes-sensei' ) ) )*/
72
+			),
73
+			'1.8.0' => array('auto' => array('enhance_teacher_role' => array('title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.'),),
74
+				'manual' => array()
75
+			),
76
+		);
77 77
 
78 78
 		$this->updates = apply_filters( 'sensei_upgrade_functions', $this->updates, $this->updates );
79 79
 		$this->version = get_option( 'woothemes-sensei-version' );
80 80
 
81
-        // Manual Update Screen
82
-        add_action('admin_menu', array($this, 'add_update_admin_screen'), 50);
83
-
84
-    } // End __construct()
85
-
86
-    /**
87
-     * add_update_admin_screen Adds admin screen to run manual udpates
88
-     *
89
-     * @access public
90
-     * @since  1.3.7
91
-     * @return void
92
-     */
93
-    public function add_update_admin_screen()
94
-    {
95
-        if (current_user_can('manage_options')) {
96
-            add_submenu_page('sensei', __('Sensei Updates', 'woothemes-sensei'), __('Data Updates', 'woothemes-sensei'), 'manage_options', 'sensei_updates', array($this, 'sensei_updates_page'));
97
-        }
98
-    } // End add_update_admin_screen()
99
-
100
-    /**
101
-     * sensei_updates_page HTML output for manual update screen
102
-     *
103
-     * @access public
104
-     * @since  1.3.7
105
-     * @return void
106
-     */
107
-    public function sensei_updates_page() {
108
-
109
-        // Only allow admins to load this page and run the update functions
110
-        if ( ! current_user_can('manage_options')) {
111
-
112
-            return;
113
-
114
-        }
115
-        ?>
81
+		// Manual Update Screen
82
+		add_action('admin_menu', array($this, 'add_update_admin_screen'), 50);
83
+
84
+	} // End __construct()
85
+
86
+	/**
87
+	 * add_update_admin_screen Adds admin screen to run manual udpates
88
+	 *
89
+	 * @access public
90
+	 * @since  1.3.7
91
+	 * @return void
92
+	 */
93
+	public function add_update_admin_screen()
94
+	{
95
+		if (current_user_can('manage_options')) {
96
+			add_submenu_page('sensei', __('Sensei Updates', 'woothemes-sensei'), __('Data Updates', 'woothemes-sensei'), 'manage_options', 'sensei_updates', array($this, 'sensei_updates_page'));
97
+		}
98
+	} // End add_update_admin_screen()
99
+
100
+	/**
101
+	 * sensei_updates_page HTML output for manual update screen
102
+	 *
103
+	 * @access public
104
+	 * @since  1.3.7
105
+	 * @return void
106
+	 */
107
+	public function sensei_updates_page() {
108
+
109
+		// Only allow admins to load this page and run the update functions
110
+		if ( ! current_user_can('manage_options')) {
111
+
112
+			return;
113
+
114
+		}
115
+		?>
116 116
 
117 117
         <div class="wrap">
118 118
 
@@ -120,111 +120,111 @@  discard block
 block discarded – undo
120 120
         <h2><?php _e('Sensei Updates', 'woothemes-sensei'); ?></h2>
121 121
 
122 122
         <?php
123
-        $function_name= '';
124
-        if ( isset($_GET['action']) && $_GET['action'] == 'update'
125
-            && isset($_GET['n']) && intval($_GET['n']) >= 0
126
-            && ( (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) {
123
+		$function_name= '';
124
+		if ( isset($_GET['action']) && $_GET['action'] == 'update'
125
+			&& isset($_GET['n']) && intval($_GET['n']) >= 0
126
+			&& ( (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) {
127 127
 
128
-            // Setup the data variables
129
-            $n = intval($_GET['n']);
130
-            $functions_list = '';
131
-            $done_processing = false;
128
+			// Setup the data variables
129
+			$n = intval($_GET['n']);
130
+			$functions_list = '';
131
+			$done_processing = false;
132 132
 
133
-            // Check for updates to run
134
-            if (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) {
133
+			// Check for updates to run
134
+			if (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) {
135 135
 
136
-                foreach ($_POST['checked'] as $key => $function_name) {
136
+				foreach ($_POST['checked'] as $key => $function_name) {
137 137
 
138
-                    if( ! isset(  $_POST[ $function_name.'_nonce_field' ] ) 
139
-                        || ! wp_verify_nonce( $_POST[ $function_name.'_nonce_field' ] , 'run_'.$function_name ) ){
138
+					if( ! isset(  $_POST[ $function_name.'_nonce_field' ] ) 
139
+						|| ! wp_verify_nonce( $_POST[ $function_name.'_nonce_field' ] , 'run_'.$function_name ) ){
140 140
 
141
-                        wp_die(
142
-                            '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
143
-                            '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>',
144
-                            403
145
-                        );
141
+						wp_die(
142
+							'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
143
+							'<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>',
144
+							403
145
+						);
146 146
 
147
-                    }
147
+					}
148 148
 
149
-                    // Dynamic function call
150
-                    if (method_exists($this, $function_name)) {
149
+					// Dynamic function call
150
+					if (method_exists($this, $function_name)) {
151 151
 
152
-                        $done_processing = call_user_func_array(array($this, $function_name), array(50, $n));
152
+						$done_processing = call_user_func_array(array($this, $function_name), array(50, $n));
153 153
 
154
-                    } elseif ($this->function_in_whitelist($function_name)) {
154
+					} elseif ($this->function_in_whitelist($function_name)) {
155 155
 
156
-                        $done_processing = call_user_func_array($function_name, array(50, $n));
156
+						$done_processing = call_user_func_array($function_name, array(50, $n));
157 157
 
158
-                    } else {
158
+					} else {
159 159
 
160
-                        _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
161
-                        return;
160
+						_doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
161
+						return;
162 162
 
163
-                    }// End If Statement
163
+					}// End If Statement
164 164
 
165
-                // Add to functions list get args
166
-                if ('' == $functions_list) {
167
-                    $functions_list .= $function_name;
168
-                } else {
169
-                    $functions_list .= '+' . $function_name;
170
-                } // End If Statement
165
+				// Add to functions list get args
166
+				if ('' == $functions_list) {
167
+					$functions_list .= $function_name;
168
+				} else {
169
+					$functions_list .= '+' . $function_name;
170
+				} // End If Statement
171 171
 
172
-                // Mark update has having been run
173
-                $this->set_update_run($function_name);
172
+				// Mark update has having been run
173
+				$this->set_update_run($function_name);
174 174
 
175
-            } // End For Loop
175
+			} // End For Loop
176 176
 
177
-        } // End If Statement
177
+		} // End If Statement
178 178
 
179
-        // Check for updates to run
180
-        if (isset($_GET['functions']) && '' != $_GET['functions']) {
179
+		// Check for updates to run
180
+		if (isset($_GET['functions']) && '' != $_GET['functions']) {
181 181
 
182
-            // Existing functions from GET variables instead of POST
183
-            $functions_array = $_GET['functions'];
182
+			// Existing functions from GET variables instead of POST
183
+			$functions_array = $_GET['functions'];
184 184
 
185
-            foreach ($functions_array as $key => $function_name) {
185
+			foreach ($functions_array as $key => $function_name) {
186 186
 
187
-                if( ! isset( $_GET[ $function_name.'_nonce' ] )
188
-                    || ! wp_verify_nonce( $_GET[ $function_name.'_nonce' ] , 'run_'.$function_name ) ){
187
+				if( ! isset( $_GET[ $function_name.'_nonce' ] )
188
+					|| ! wp_verify_nonce( $_GET[ $function_name.'_nonce' ] , 'run_'.$function_name ) ){
189 189
 
190
-                    wp_die(
191
-                        '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
192
-                        '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>',
193
-                        403
194
-                    );
190
+					wp_die(
191
+						'<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
192
+						'<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>',
193
+						403
194
+					);
195 195
 
196
-                }
196
+				}
197 197
 
198
-                // Dynamic function call
199
-                if (method_exists($this, $function_name)) {
198
+				// Dynamic function call
199
+				if (method_exists($this, $function_name)) {
200 200
 
201
-                    $done_processing = call_user_func_array(array($this, $function_name), array(50, $n));
201
+					$done_processing = call_user_func_array(array($this, $function_name), array(50, $n));
202 202
 
203
-                } elseif ($this->function_in_whitelist($function_name)) {
203
+				} elseif ($this->function_in_whitelist($function_name)) {
204 204
 
205
-                    $done_processing = call_user_func_array($function_name, array(50, $n));
205
+					$done_processing = call_user_func_array($function_name, array(50, $n));
206 206
 
207
-                } else {
207
+				} else {
208 208
 
209
-                    _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
210
-                    return;
209
+					_doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
210
+					return;
211 211
 
212
-                } // End If Statement
212
+				} // End If Statement
213 213
 
214
-                // Add to functions list get args
215
-                if ('' == $functions_list) {
216
-                    $functions_list .= $function_name;
217
-                } else {
218
-                    $functions_list .= '+' . $function_name;
219
-                } // End If Statement
214
+				// Add to functions list get args
215
+				if ('' == $functions_list) {
216
+					$functions_list .= $function_name;
217
+				} else {
218
+					$functions_list .= '+' . $function_name;
219
+				} // End If Statement
220 220
 
221
-                $this->set_update_run($function_name);
221
+				$this->set_update_run($function_name);
222 222
 
223
-            } // End For Loop
223
+			} // End For Loop
224 224
 
225
-        } // End If Statement
225
+		} // End If Statement
226 226
 
227
-        if (!$done_processing) { ?>
227
+		if (!$done_processing) { ?>
228 228
 
229 229
             <h3><?php _e('Processing Updates...', 'woothemes-sensei'); ?></h3>
230 230
 
@@ -233,14 +233,14 @@  discard block
 block discarded – undo
233 233
                 <?php _e( "If your browser doesn't start loading the next page automatically, click this button:", 'woothemes-sensei' ); ?>
234 234
 
235 235
                 <?php
236
-                $next_action_url = add_query_arg( array(
237
-                    'page' => 'sensei_updates',
238
-                    'action' => 'update',
239
-                    'n' => $n + 50,
240
-                    'functions' => array( $functions_list ),
241
-                    $function_name.'_nonce' => wp_create_nonce( 'run_'. $function_name ),
242
-                ), admin_url( 'admin.php' ) );
243
-                ?>
236
+				$next_action_url = add_query_arg( array(
237
+					'page' => 'sensei_updates',
238
+					'action' => 'update',
239
+					'n' => $n + 50,
240
+					'functions' => array( $functions_list ),
241
+					$function_name.'_nonce' => wp_create_nonce( 'run_'. $function_name ),
242
+				), admin_url( 'admin.php' ) );
243
+				?>
244 244
 
245 245
                 <a class="button"  href="<?php echo esc_url( $next_action_url ); ?>">
246 246
 
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 
270 270
         <?php } // End If Statement
271 271
 
272
-        } else { ?>
272
+		} else { ?>
273 273
 
274 274
             <h3><?php _e('Updates', 'woothemes-sensei'); ?></h3>
275 275
             <p><?php printf(__('These are updates that have been made available as new Sensei versions have been released. Updates of type %1$sAuto%2$s will run as you update Sensei to the relevant version - other updates need to be run manually and you can do that here.', 'woothemes-sensei'), '<code>', '</code>'); ?></p>
@@ -298,19 +298,19 @@  discard block
 block discarded – undo
298 298
 
299 299
                 <tbody class="updates">
300 300
                 <?php
301
-                // Sort updates with the latest at the top
302
-                uksort($this->updates, array($this, 'sort_updates'));
303
-                $this->updates = array_reverse($this->updates, true);
304
-                $class = 'alternate';
305
-                foreach ($this->updates as $version => $version_updates) {
306
-                    foreach ($version_updates as $type => $updates) {
307
-                        foreach ($updates as $update => $data) {
308
-                            $update_run = $this->has_update_run($update);
309
-                            $product = 'Sensei';
310
-                            if (isset($data['product']) && '' != $data['product']) {
311
-                                $product = $data['product'];
312
-                            } // End If Statement
313
-                            ?>
301
+				// Sort updates with the latest at the top
302
+				uksort($this->updates, array($this, 'sort_updates'));
303
+				$this->updates = array_reverse($this->updates, true);
304
+				$class = 'alternate';
305
+				foreach ($this->updates as $version => $version_updates) {
306
+					foreach ($version_updates as $type => $updates) {
307
+						foreach ($updates as $update => $data) {
308
+							$update_run = $this->has_update_run($update);
309
+							$product = 'Sensei';
310
+							if (isset($data['product']) && '' != $data['product']) {
311
+								$product = $data['product'];
312
+							} // End If Statement
313
+							?>
314 314
                             <form method="post" action="admin.php?page=sensei_updates&action=update&n=0"
315 315
                                   name="update-sensei" class="upgrade">
316 316
                                 <tr class="<?php echo $class; ?>">
@@ -323,11 +323,11 @@  discard block
 block discarded – undo
323 323
                                         </p>
324 324
                                     </td>
325 325
                                     <?php
326
-                                    $type_label = __('Auto', 'woothemes-sensei');
327
-                                    if ($type != 'auto') {
328
-                                        $type_label = __('Manual', 'woothemes-sensei');
329
-                                    }
330
-                                    ?>
326
+									$type_label = __('Auto', 'woothemes-sensei');
327
+									if ($type != 'auto') {
328
+										$type_label = __('Manual', 'woothemes-sensei');
329
+									}
330
+									?>
331 331
                                     <td><p><?php echo $type_label; ?></p></td>
332 332
                                     <td>
333 333
                                         <p>
@@ -339,24 +339,24 @@  discard block
 block discarded – undo
339 339
                                                    name="update">
340 340
 
341 341
                                             <?php
342
-                                            $nonce_action = 'run_'.$update;
343
-                                            $nonce_field_name = $update.'_nonce_field';
344
-                                            wp_nonce_field( $nonce_action, $nonce_field_name, false, true );
345
-                                            ?>
342
+											$nonce_action = 'run_'.$update;
343
+											$nonce_field_name = $update.'_nonce_field';
344
+											wp_nonce_field( $nonce_action, $nonce_field_name, false, true );
345
+											?>
346 346
                                         </p>
347 347
                                     </td>
348 348
                                 </tr>
349 349
                             </form>
350 350
                             <?php
351
-                            if ('alternate' == $class) {
352
-                                $class = '';
353
-                            } else {
354
-                                $class = 'alternate';
355
-                            }
356
-                        }
357
-                    }
358
-                }
359
-                ?>
351
+							if ('alternate' == $class) {
352
+								$class = '';
353
+							} else {
354
+								$class = 'alternate';
355
+							}
356
+						}
357
+					}
358
+				}
359
+				?>
360 360
                 </tbody>
361 361
 
362 362
             </table>
@@ -364,31 +364,31 @@  discard block
 block discarded – undo
364 364
             </div>
365 365
 
366 366
             <?php
367
-        } // End If Statement
368
-    } // End sensei_updates_page()
367
+		} // End If Statement
368
+	} // End sensei_updates_page()
369 369
 
370
-    /**
371
-     * Since 1.9.0
372
-     *
373
-     * A list of safe to execute functions withing the
374
-     * updater context.
375
-     *
376
-     * @param string $function_name
377
-     */
378
-    public function function_in_whitelist( $function_name ){
370
+	/**
371
+	 * Since 1.9.0
372
+	 *
373
+	 * A list of safe to execute functions withing the
374
+	 * updater context.
375
+	 *
376
+	 * @param string $function_name
377
+	 */
378
+	public function function_in_whitelist( $function_name ){
379 379
 
380
-        $function_whitelist = array(
381
-            'status_changes_convert_questions',
382
-            'status_changes_fix_lessons',
383
-            'status_changes_convert_courses',
384
-            'status_changes_convert_lessons',
385
-            'status_changes_repair_course_statuses',
380
+		$function_whitelist = array(
381
+			'status_changes_convert_questions',
382
+			'status_changes_fix_lessons',
383
+			'status_changes_convert_courses',
384
+			'status_changes_convert_lessons',
385
+			'status_changes_repair_course_statuses',
386 386
 
387
-        );
387
+		);
388 388
 
389
-        return in_array($function_name, $function_whitelist );
389
+		return in_array($function_name, $function_whitelist );
390 390
 
391
-    }// end function_in_whitelist
391
+	}// end function_in_whitelist
392 392
 
393 393
 	/**
394 394
 	 * Sort updates list by version number
@@ -413,47 +413,47 @@  discard block
 block discarded – undo
413 413
 
414 414
 		// Only allow admins to run update functions
415 415
 		if( ! current_user_can( 'manage_options' ) ) {
416
-            return false;
417
-        }
418
-
419
-        $this->force_updates();
420
-
421
-        // Run through all functions
422
-        foreach ( $this->updates as $version => $value ) {
423
-            foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) {
424
-                if ( $upgrade_type == $type ) {
425
-                    $updated = false;
426
-                    // Run the update function
427
-                    foreach ( $function_to_run as $function_name => $update_data ) {
428
-                        if ( isset( $function_name ) && '' != $function_name ) {
429
-                            if ( ! in_array( $function_name, $this->updates_run ) ) {
430
-                                $updated = false;
431
-                                if ( method_exists( $this, $function_name ) ) {
432
-
433
-            $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
416
+			return false;
417
+		}
418
+
419
+		$this->force_updates();
420
+
421
+		// Run through all functions
422
+		foreach ( $this->updates as $version => $value ) {
423
+			foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) {
424
+				if ( $upgrade_type == $type ) {
425
+					$updated = false;
426
+					// Run the update function
427
+					foreach ( $function_to_run as $function_name => $update_data ) {
428
+						if ( isset( $function_name ) && '' != $function_name ) {
429
+							if ( ! in_array( $function_name, $this->updates_run ) ) {
430
+								$updated = false;
431
+								if ( method_exists( $this, $function_name ) ) {
432
+
433
+			$this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
434 434
 			update_option( Sensei()->token . '-upgrades', $this->updates_run );
435 435
 			return true;
436 436
 
437
-                                } elseif( $this->function_in_whitelist( $function_name ) ) {
437
+								} elseif( $this->function_in_whitelist( $function_name ) ) {
438 438
 
439
-                                    $updated = call_user_func( $function_name );
439
+									$updated = call_user_func( $function_name );
440 440
 
441
-                                }  // End If Statement
441
+								}  // End If Statement
442 442
 
443
-                                if ( $updated ) {
444
-                                    array_push( $this->updates_run, $function_name );
445
-                                } // End If Statement
446
-                            }
447
-                        } // End If Statement
448
-                    } // End For Loop
449
-                } // End If Statement
450
-            } // End For Loop
451
-        } // End For Loop
443
+								if ( $updated ) {
444
+									array_push( $this->updates_run, $function_name );
445
+								} // End If Statement
446
+							}
447
+						} // End If Statement
448
+					} // End For Loop
449
+				} // End If Statement
450
+			} // End For Loop
451
+		} // End For Loop
452 452
 
453
-        $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
454
-        update_option( $this->token . '-upgrades', $this->updates_run );
453
+		$this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
454
+		update_option( $this->token . '-upgrades', $this->updates_run );
455 455
 
456
-        return true;
456
+		return true;
457 457
 
458 458
 	} // End update()
459 459
 
@@ -566,7 +566,7 @@  discard block
 block discarded – undo
566 566
 	 */
567 567
 	private function set_update_run( $update ) {
568 568
 		array_push( $this->updates_run, $update );
569
-        $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
569
+		$this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
570 570
 		update_option( Sensei()->token . '-upgrades', $this->updates_run );
571 571
 	}
572 572
 
@@ -1030,11 +1030,11 @@  discard block
 block discarded – undo
1030 1030
 				update_post_meta( $lesson->ID, '_order_' . $course_id, 0 );
1031 1031
 			}
1032 1032
 
1033
-            $module = Sensei()->modules->get_lesson_module( $lesson->ID );
1033
+			$module = Sensei()->modules->get_lesson_module( $lesson->ID );
1034 1034
 
1035
-            if( $module ) {
1036
-                update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 );
1037
-            }
1035
+			if( $module ) {
1036
+				update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 );
1037
+			}
1038 1038
 
1039 1039
 		}
1040 1040
 
@@ -1844,22 +1844,22 @@  discard block
 block discarded – undo
1844 1844
 
1845 1845
 	}
1846 1846
 
1847
-     /**
1848
-     * WooThemes_Sensei_Updates::enhance_teacher_role
1849
-     *
1850
-     * This runs the update to create the teacher role
1851
-     * @access public
1852
-     * @since 1.8.0
1853
-     * @return bool;
1854
-     */
1855
-    public  function enhance_teacher_role ( ) {
1856
-
1857
-        require_once('class-sensei-teacher.php');
1858
-        $teacher = new Sensei_Teacher();
1859
-        $teacher->create_role();
1860
-        return true;
1861
-
1862
-    }// end enhance_teacher_role
1847
+	 /**
1848
+	  * WooThemes_Sensei_Updates::enhance_teacher_role
1849
+	  *
1850
+	  * This runs the update to create the teacher role
1851
+	  * @access public
1852
+	  * @since 1.8.0
1853
+	  * @return bool;
1854
+	  */
1855
+	public  function enhance_teacher_role ( ) {
1856
+
1857
+		require_once('class-sensei-teacher.php');
1858
+		$teacher = new Sensei_Teacher();
1859
+		$teacher->create_role();
1860
+		return true;
1861
+
1862
+	}// end enhance_teacher_role
1863 1863
 
1864 1864
 } // End Class
1865 1865
 
Please login to merge, or discard this patch.
Spacing   +436 added lines, -436 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 Updates Class
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 
32 32
 		// Setup object data
33 33
 		$this->parent = $parent;
34
-		$this->updates_run = get_option( 'woothemes-sensei-upgrades', array() );
34
+		$this->updates_run = get_option('woothemes-sensei-upgrades', array());
35 35
 
36 36
         // The list of upgrades to run
37 37
         $this->updates = array('1.1.0' => array('auto' => array('assign_role_caps' => array('title' => __('Assign role capabilities', 'woothemes-sensei'), 'desc' => __('Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei'), 'product' => 'Sensei')),
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
             ),
76 76
         );
77 77
 
78
-		$this->updates = apply_filters( 'sensei_upgrade_functions', $this->updates, $this->updates );
79
-		$this->version = get_option( 'woothemes-sensei-version' );
78
+		$this->updates = apply_filters('sensei_upgrade_functions', $this->updates, $this->updates);
79
+		$this->version = get_option('woothemes-sensei-version');
80 80
 
81 81
         // Manual Update Screen
82 82
         add_action('admin_menu', array($this, 'add_update_admin_screen'), 50);
@@ -120,10 +120,10 @@  discard block
 block discarded – undo
120 120
         <h2><?php _e('Sensei Updates', 'woothemes-sensei'); ?></h2>
121 121
 
122 122
         <?php
123
-        $function_name= '';
124
-        if ( isset($_GET['action']) && $_GET['action'] == 'update'
123
+        $function_name = '';
124
+        if (isset($_GET['action']) && $_GET['action'] == 'update'
125 125
             && isset($_GET['n']) && intval($_GET['n']) >= 0
126
-            && ( (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) {
126
+            && ((isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) {
127 127
 
128 128
             // Setup the data variables
129 129
             $n = intval($_GET['n']);
@@ -135,12 +135,12 @@  discard block
 block discarded – undo
135 135
 
136 136
                 foreach ($_POST['checked'] as $key => $function_name) {
137 137
 
138
-                    if( ! isset(  $_POST[ $function_name.'_nonce_field' ] ) 
139
-                        || ! wp_verify_nonce( $_POST[ $function_name.'_nonce_field' ] , 'run_'.$function_name ) ){
138
+                    if ( ! isset($_POST[$function_name.'_nonce_field']) 
139
+                        || ! wp_verify_nonce($_POST[$function_name.'_nonce_field'], 'run_'.$function_name)) {
140 140
 
141 141
                         wp_die(
142
-                            '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
143
-                            '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>',
142
+                            '<h1>'.__('Cheatin&#8217; uh?').'</h1>'.
143
+                            '<p>'.__('The nonce supplied in order to run this update function is invalid', 'woothemes-sensei').'</p>',
144 144
                             403
145 145
                         );
146 146
 
@@ -157,7 +157,7 @@  discard block
 block discarded – undo
157 157
 
158 158
                     } else {
159 159
 
160
-                        _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
160
+                        _doing_it_wrong(esc_html($function_name), 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
161 161
                         return;
162 162
 
163 163
                     }// End If Statement
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
                 if ('' == $functions_list) {
167 167
                     $functions_list .= $function_name;
168 168
                 } else {
169
-                    $functions_list .= '+' . $function_name;
169
+                    $functions_list .= '+'.$function_name;
170 170
                 } // End If Statement
171 171
 
172 172
                 // Mark update has having been run
@@ -184,12 +184,12 @@  discard block
 block discarded – undo
184 184
 
185 185
             foreach ($functions_array as $key => $function_name) {
186 186
 
187
-                if( ! isset( $_GET[ $function_name.'_nonce' ] )
188
-                    || ! wp_verify_nonce( $_GET[ $function_name.'_nonce' ] , 'run_'.$function_name ) ){
187
+                if ( ! isset($_GET[$function_name.'_nonce'])
188
+                    || ! wp_verify_nonce($_GET[$function_name.'_nonce'], 'run_'.$function_name)) {
189 189
 
190 190
                     wp_die(
191
-                        '<h1>' . __( 'Cheatin&#8217; uh?' ) . '</h1>' .
192
-                        '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>',
191
+                        '<h1>'.__('Cheatin&#8217; uh?').'</h1>'.
192
+                        '<p>'.__('The nonce supplied in order to run this update function is invalid', 'woothemes-sensei').'</p>',
193 193
                         403
194 194
                     );
195 195
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 
207 207
                 } else {
208 208
 
209
-                    _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
209
+                    _doing_it_wrong(esc_html($function_name), 'Is not a valid Sensei updater function', 'Sensei 1.9.0');
210 210
                     return;
211 211
 
212 212
                 } // End If Statement
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
                 if ('' == $functions_list) {
216 216
                     $functions_list .= $function_name;
217 217
                 } else {
218
-                    $functions_list .= '+' . $function_name;
218
+                    $functions_list .= '+'.$function_name;
219 219
                 } // End If Statement
220 220
 
221 221
                 $this->set_update_run($function_name);
@@ -224,27 +224,27 @@  discard block
 block discarded – undo
224 224
 
225 225
         } // End If Statement
226 226
 
227
-        if (!$done_processing) { ?>
227
+        if ( ! $done_processing) { ?>
228 228
 
229 229
             <h3><?php _e('Processing Updates...', 'woothemes-sensei'); ?></h3>
230 230
 
231 231
             <p>
232 232
 
233
-                <?php _e( "If your browser doesn't start loading the next page automatically, click this button:", 'woothemes-sensei' ); ?>
233
+                <?php _e("If your browser doesn't start loading the next page automatically, click this button:", 'woothemes-sensei'); ?>
234 234
 
235 235
                 <?php
236
-                $next_action_url = add_query_arg( array(
236
+                $next_action_url = add_query_arg(array(
237 237
                     'page' => 'sensei_updates',
238 238
                     'action' => 'update',
239 239
                     'n' => $n + 50,
240
-                    'functions' => array( $functions_list ),
241
-                    $function_name.'_nonce' => wp_create_nonce( 'run_'. $function_name ),
242
-                ), admin_url( 'admin.php' ) );
240
+                    'functions' => array($functions_list),
241
+                    $function_name.'_nonce' => wp_create_nonce('run_'.$function_name),
242
+                ), admin_url('admin.php'));
243 243
                 ?>
244 244
 
245
-                <a class="button"  href="<?php echo esc_url( $next_action_url ); ?>">
245
+                <a class="button"  href="<?php echo esc_url($next_action_url); ?>">
246 246
 
247
-                    <?php _e( 'Next', 'woothemes-sensei' ); ?>
247
+                    <?php _e('Next', 'woothemes-sensei'); ?>
248 248
 
249 249
                 </a>
250 250
 
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
             <script type='text/javascript'>
253 253
                 <!--
254 254
                 function js_sensei_nextpage() {
255
-                    location.href = "<?php echo esc_url_raw(  $next_action_url );?>";
255
+                    location.href = "<?php echo esc_url_raw($next_action_url); ?>";
256 256
                 }
257 257
                 setTimeout( "js_sensei_nextpage()", 250 );
258 258
                 //-->
@@ -331,17 +331,17 @@  discard block
 block discarded – undo
331 331
                                     <td><p><?php echo $type_label; ?></p></td>
332 332
                                     <td>
333 333
                                         <p>
334
-                                            <input onclick="javascript:return confirm('<?php echo addslashes( sprintf( __( 'Are you sure you want to run the \'%s\' update?', 'woothemes-sensei' ), $data['title'] ) ); ?>');"
334
+                                            <input onclick="javascript:return confirm('<?php echo addslashes(sprintf(__('Are you sure you want to run the \'%s\' update?', 'woothemes-sensei'), $data['title'])); ?>');"
335 335
                                                    id="update-sensei"
336
-                                                   class="button<?php if( ! $update_run ) { echo ' button-primary'; } ?>"
336
+                                                   class="button<?php if ( ! $update_run) { echo ' button-primary'; } ?>"
337 337
                                                    type="submit"
338
-                                                   value="<?php if( $update_run ) { _e( 'Re-run Update', 'woothemes-sensei' ); } else { _e( 'Run Update', 'woothemes-sensei' ); } ?>"
338
+                                                   value="<?php if ($update_run) { _e('Re-run Update', 'woothemes-sensei'); } else { _e('Run Update', 'woothemes-sensei'); } ?>"
339 339
                                                    name="update">
340 340
 
341 341
                                             <?php
342 342
                                             $nonce_action = 'run_'.$update;
343 343
                                             $nonce_field_name = $update.'_nonce_field';
344
-                                            wp_nonce_field( $nonce_action, $nonce_field_name, false, true );
344
+                                            wp_nonce_field($nonce_action, $nonce_field_name, false, true);
345 345
                                             ?>
346 346
                                         </p>
347 347
                                     </td>
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
      *
376 376
      * @param string $function_name
377 377
      */
378
-    public function function_in_whitelist( $function_name ){
378
+    public function function_in_whitelist($function_name) {
379 379
 
380 380
         $function_whitelist = array(
381 381
             'status_changes_convert_questions',
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 
387 387
         );
388 388
 
389
-        return in_array($function_name, $function_whitelist );
389
+        return in_array($function_name, $function_whitelist);
390 390
 
391 391
     }// end function_in_whitelist
392 392
 
@@ -397,8 +397,8 @@  discard block
 block discarded – undo
397 397
 	 * @param  string $b Second key
398 398
 	 * @return integer
399 399
 	 */
400
-	private function sort_updates( $a, $b ) {
401
-		return strcmp( $a, $b );
400
+	private function sort_updates($a, $b) {
401
+		return strcmp($a, $b);
402 402
 	}
403 403
 
404 404
 	/**
@@ -409,39 +409,39 @@  discard block
 block discarded – undo
409 409
 	 * @access public
410 410
 	 * @return boolean
411 411
 	 */
412
-	public function update ( $type = 'auto' ) {
412
+	public function update($type = 'auto') {
413 413
 
414 414
 		// Only allow admins to run update functions
415
-		if( ! current_user_can( 'manage_options' ) ) {
415
+		if ( ! current_user_can('manage_options')) {
416 416
             return false;
417 417
         }
418 418
 
419 419
         $this->force_updates();
420 420
 
421 421
         // Run through all functions
422
-        foreach ( $this->updates as $version => $value ) {
423
-            foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) {
424
-                if ( $upgrade_type == $type ) {
422
+        foreach ($this->updates as $version => $value) {
423
+            foreach ($this->updates[$version] as $upgrade_type => $function_to_run) {
424
+                if ($upgrade_type == $type) {
425 425
                     $updated = false;
426 426
                     // Run the update function
427
-                    foreach ( $function_to_run as $function_name => $update_data ) {
428
-                        if ( isset( $function_name ) && '' != $function_name ) {
429
-                            if ( ! in_array( $function_name, $this->updates_run ) ) {
427
+                    foreach ($function_to_run as $function_name => $update_data) {
428
+                        if (isset($function_name) && '' != $function_name) {
429
+                            if ( ! in_array($function_name, $this->updates_run)) {
430 430
                                 $updated = false;
431
-                                if ( method_exists( $this, $function_name ) ) {
431
+                                if (method_exists($this, $function_name)) {
432 432
 
433
-            $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
434
-			update_option( Sensei()->token . '-upgrades', $this->updates_run );
433
+            $this->updates_run = array_unique($this->updates_run); // we only need one reference per update
434
+			update_option(Sensei()->token.'-upgrades', $this->updates_run);
435 435
 			return true;
436 436
 
437
-                                } elseif( $this->function_in_whitelist( $function_name ) ) {
437
+                                } elseif ($this->function_in_whitelist($function_name)) {
438 438
 
439
-                                    $updated = call_user_func( $function_name );
439
+                                    $updated = call_user_func($function_name);
440 440
 
441 441
                                 }  // End If Statement
442 442
 
443
-                                if ( $updated ) {
444
-                                    array_push( $this->updates_run, $function_name );
443
+                                if ($updated) {
444
+                                    array_push($this->updates_run, $function_name);
445 445
                                 } // End If Statement
446 446
                             }
447 447
                         } // End If Statement
@@ -450,8 +450,8 @@  discard block
 block discarded – undo
450 450
             } // End For Loop
451 451
         } // End For Loop
452 452
 
453
-        $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
454
-        update_option( $this->token . '-upgrades', $this->updates_run );
453
+        $this->updates_run = array_unique($this->updates_run); // we only need one reference per update
454
+        update_option($this->token.'-upgrades', $this->updates_run);
455 455
 
456 456
         return true;
457 457
 
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
 
460 460
 	private function force_updates() {
461 461
 
462
-		if( ! isset( $_GET['page'] ) || 'sensei_updates' != $_GET['page'] ) {
462
+		if ( ! isset($_GET['page']) || 'sensei_updates' != $_GET['page']) {
463 463
 
464 464
 			// $skip_forced_updates = false;
465 465
 			// if( ! get_option( 'woothemes-sensei-force-updates', false ) ) {
@@ -468,8 +468,8 @@  discard block
 block discarded – undo
468 468
 
469 469
 			// Force critical updates if only if lessons already exist
470 470
 			$skip_forced_updates = false;
471
-			$lesson_posts = wp_count_posts( 'lesson' );
472
-			if( ! isset( $lesson_posts->publish ) || ! $lesson_posts->publish ) {
471
+			$lesson_posts = wp_count_posts('lesson');
472
+			if ( ! isset($lesson_posts->publish) || ! $lesson_posts->publish) {
473 473
 				$skip_forced_updates = true;
474 474
 			}
475 475
 
@@ -477,69 +477,69 @@  discard block
 block discarded – undo
477 477
 
478 478
 			$updates_to_run = array();
479 479
 
480
-			foreach ( $this->updates as $version => $value ) {
481
-				foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) {
482
-					if ( $upgrade_type == 'forced' ) {
483
-						foreach ( $function_to_run as $function_name => $update_data ) {
480
+			foreach ($this->updates as $version => $value) {
481
+				foreach ($this->updates[$version] as $upgrade_type => $function_to_run) {
482
+					if ($upgrade_type == 'forced') {
483
+						foreach ($function_to_run as $function_name => $update_data) {
484 484
 
485
-							if( $skip_forced_updates ) {
486
-								$this->set_update_run( $function_name );
485
+							if ($skip_forced_updates) {
486
+								$this->set_update_run($function_name);
487 487
 								continue;
488 488
 							}
489 489
 
490
-							$update_run = $this->has_update_run( $function_name );
490
+							$update_run = $this->has_update_run($function_name);
491 491
 
492
-							if( ! $update_run ) {
492
+							if ( ! $update_run) {
493 493
 								$use_the_force = true;
494
-								$updates_to_run[ $function_name ] = $update_data;
494
+								$updates_to_run[$function_name] = $update_data;
495 495
 							}
496 496
 						}
497 497
 					}
498 498
 				}
499 499
 			}
500 500
 
501
-			if( $skip_forced_updates ) {
501
+			if ($skip_forced_updates) {
502 502
 				return;
503 503
 			}
504 504
 
505
-			if( $use_the_force && 0 < count( $updates_to_run ) ) {
505
+			if ($use_the_force && 0 < count($updates_to_run)) {
506 506
 
507
-				$update_title = __( 'Important Sensei updates required', 'woothemes-sensei' );
507
+				$update_title = __('Important Sensei updates required', 'woothemes-sensei');
508 508
 
509
-				$update_message = '<h1>' . __( 'Important Sensei upgrades required!', 'woothemes-sensei' ) . '</h1>' . "\n";
509
+				$update_message = '<h1>'.__('Important Sensei upgrades required!', 'woothemes-sensei').'</h1>'."\n";
510 510
 
511 511
 				// $update_message .= '<h4>' . sprintf( __( 'These updates are only required if you are updating from a previous version of Sensei. If you are installing Sensei for the first time, %1$syou can dismiss this page by clicking here%2$s.', 'woothemes-sensei' ), '<a href="' . add_query_arg( array( 'sensei_skip_forced_updates' => 'true' ) ) . '">', '</a>' ) . '</h4>' ."\n";
512 512
 
513
-				$update_message .= '<p>' . __( 'The latest version of Sensei requires some important database upgrades. In order to run these upgrades you will need to follow the step by step guide below. Your site will not function correctly unless you run these critical updates.', 'woothemes-sensei' ) . '</p>' . "\n";
513
+				$update_message .= '<p>'.__('The latest version of Sensei requires some important database upgrades. In order to run these upgrades you will need to follow the step by step guide below. Your site will not function correctly unless you run these critical updates.', 'woothemes-sensei').'</p>'."\n";
514 514
 
515
-				$update_message .= '<p><b>' . __( 'To run the upgrades click on each of the links below in the order that they appear.', 'woothemes-sensei' ) . '</b></p>' . "\n";
515
+				$update_message .= '<p><b>'.__('To run the upgrades click on each of the links below in the order that they appear.', 'woothemes-sensei').'</b></p>'."\n";
516 516
 
517
-				$update_message .= '<p>' . __( 'Clicking each link will open up a new window/tab - do not close that window/tab until you see the message \'Update completed successfully\'. Once you see that message you can close the window/tab and start the next upgrade by clicking on the next link in the list.', 'woothemes-sensei' ) . '</p>' . "\n";
517
+				$update_message .= '<p>'.__('Clicking each link will open up a new window/tab - do not close that window/tab until you see the message \'Update completed successfully\'. Once you see that message you can close the window/tab and start the next upgrade by clicking on the next link in the list.', 'woothemes-sensei').'</p>'."\n";
518 518
 
519
-				$update_message .= '<p><b>' . __( 'Once all the upgrades have been completed you will be able to use your WordPress site again.', 'woothemes-sensei' ) . '</b></p>' . "\n";
519
+				$update_message .= '<p><b>'.__('Once all the upgrades have been completed you will be able to use your WordPress site again.', 'woothemes-sensei').'</b></p>'."\n";
520 520
 
521
-				$update_message .= '<ol>' . "\n";
521
+				$update_message .= '<ol>'."\n";
522 522
 
523
-					foreach( $updates_to_run as $function => $data ) {
523
+					foreach ($updates_to_run as $function => $data) {
524 524
 
525
-						if( ! isset( $data['title'] ) ) {
525
+						if ( ! isset($data['title'])) {
526 526
 							break;
527 527
 						}
528 528
 
529
-						$update_message .= '<li style="margin:5px 0;"><a href="' . admin_url( 'admin.php?page=sensei_updates&action=update&n=0&functions[]=' . $function ) . '" target="_blank">' . $data['title'] . '</a></li>';
529
+						$update_message .= '<li style="margin:5px 0;"><a href="'.admin_url('admin.php?page=sensei_updates&action=update&n=0&functions[]='.$function).'" target="_blank">'.$data['title'].'</a></li>';
530 530
 					}
531 531
 
532
-				$update_message .= '</ol>' . "\n";
532
+				$update_message .= '</ol>'."\n";
533 533
 
534
-				switch( $version ) {
534
+				switch ($version) {
535 535
 
536 536
 					case '1.7.0':
537
-						$update_message .= '<p><em>' . sprintf( __( 'Want to know what these upgrades are all about? %1$sFind out more here%2$s.', 'woothemes-sensei' ), '<a href="http://develop.woothemes.com/sensei/2014/12/03/important-information-about-sensei-1-7" target="_blank">', '</a>' ) . '</em></p>' . "\n";
537
+						$update_message .= '<p><em>'.sprintf(__('Want to know what these upgrades are all about? %1$sFind out more here%2$s.', 'woothemes-sensei'), '<a href="http://develop.woothemes.com/sensei/2014/12/03/important-information-about-sensei-1-7" target="_blank">', '</a>').'</em></p>'."\n";
538 538
 					break;
539 539
 
540 540
 				}
541 541
 
542
-				wp_die( $update_message, $update_title );
542
+				wp_die($update_message, $update_title);
543 543
 			}
544 544
 		}
545 545
 	}
@@ -551,8 +551,8 @@  discard block
 block discarded – undo
551 551
 	 * @since  1.4.0
552 552
 	 * @return boolean
553 553
 	 */
554
-	private function has_update_run( $update ) {
555
-		if ( in_array( $update, $this->updates_run ) ) {
554
+	private function has_update_run($update) {
555
+		if (in_array($update, $this->updates_run)) {
556 556
 			return true;
557 557
 		}
558 558
 		return false;
@@ -564,10 +564,10 @@  discard block
 block discarded – undo
564 564
 	 * @param string $update Update to process
565 565
 	 * @since  1.4.0
566 566
 	 */
567
-	private function set_update_run( $update ) {
568
-		array_push( $this->updates_run, $update );
569
-        $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
570
-		update_option( Sensei()->token . '-upgrades', $this->updates_run );
567
+	private function set_update_run($update) {
568
+		array_push($this->updates_run, $update);
569
+        $this->updates_run = array_unique($this->updates_run); // we only need one reference per update
570
+		update_option(Sensei()->token.'-upgrades', $this->updates_run);
571 571
 	}
572 572
 
573 573
 	/**
@@ -578,15 +578,15 @@  discard block
 block discarded – undo
578 578
 	 * @return void
579 579
 	 */
580 580
 	public function assign_role_caps() {
581
-		foreach ( $this->parent->post_types->role_caps as $role_cap_set  ) {
582
-			foreach ( $role_cap_set as $role_key => $capabilities_array ) {
581
+		foreach ($this->parent->post_types->role_caps as $role_cap_set) {
582
+			foreach ($role_cap_set as $role_key => $capabilities_array) {
583 583
 				/* Get the role. */
584
-				$role = get_role( $role_key );
585
-				foreach ( $capabilities_array as $cap_name  ) {
584
+				$role = get_role($role_key);
585
+				foreach ($capabilities_array as $cap_name) {
586 586
 					/* If the role exists, add required capabilities for the plugin. */
587
-					if ( !empty( $role ) ) {
588
-						if ( !$role->has_cap( $cap_name ) ) {
589
-							$role->add_cap( $cap_name );
587
+					if ( ! empty($role)) {
588
+						if ( ! $role->has_cap($cap_name)) {
589
+							$role->add_cap($cap_name);
590 590
 						} // End If Statement
591 591
 					} // End If Statement
592 592
 				} // End For Loop
@@ -602,16 +602,16 @@  discard block
 block discarded – undo
602 602
 	 * @return void
603 603
 	 */
604 604
 	public function set_default_quiz_grade_type() {
605
-		$args = array(	'post_type' 		=> 'quiz',
605
+		$args = array('post_type' 		=> 'quiz',
606 606
 						'posts_per_page' 		=> -1,
607 607
 						'post_status'		=> 'publish',
608 608
 						'suppress_filters' 	=> 0
609 609
 						);
610
-		$quizzes = get_posts( $args );
610
+		$quizzes = get_posts($args);
611 611
 
612
-		foreach( $quizzes as $quiz ) {
613
-			update_post_meta( $quiz->ID, '_quiz_grade_type', 'auto' );
614
-			update_post_meta( $quiz->ID, '_quiz_grade_type_disabled', '' );
612
+		foreach ($quizzes as $quiz) {
613
+			update_post_meta($quiz->ID, '_quiz_grade_type', 'auto');
614
+			update_post_meta($quiz->ID, '_quiz_grade_type_disabled', '');
615 615
 		}
616 616
 	} // End set_default_quiz_grade_type
617 617
 
@@ -623,23 +623,23 @@  discard block
 block discarded – undo
623 623
 	 * @return void
624 624
 	 */
625 625
 	public function set_default_question_type() {
626
-		$args = array(	'post_type' 		=> 'question',
626
+		$args = array('post_type' 		=> 'question',
627 627
 						'posts_per_page' 		=> -1,
628 628
 						'post_status'		=> 'publish',
629 629
 						'suppress_filters' 	=> 0
630 630
 						);
631
-		$questions = get_posts( $args );
631
+		$questions = get_posts($args);
632 632
 
633 633
 		$already_run = true;
634
-		foreach( $questions as $question ) {
635
-			if( $already_run ) {
636
-				$terms = wp_get_post_terms( $question->ID, 'question-type' );
637
-				if( is_array( $terms ) && count( $terms ) > 0 ) {
634
+		foreach ($questions as $question) {
635
+			if ($already_run) {
636
+				$terms = wp_get_post_terms($question->ID, 'question-type');
637
+				if (is_array($terms) && count($terms) > 0) {
638 638
 					break;
639 639
 				}
640 640
 			}
641 641
 			$already_run = false;
642
-			wp_set_post_terms( $question->ID, array( 'multiple-choice' ), 'question-type' );
642
+			wp_set_post_terms($question->ID, array('multiple-choice'), 'question-type');
643 643
 		}
644 644
 
645 645
 	} // End set_default_question_type
@@ -651,90 +651,90 @@  discard block
 block discarded – undo
651 651
 	 * @access public
652 652
 	 * @return boolean
653 653
 	 */
654
-	public function update_question_answer_data( $n = 50, $offset = 0 ) {
654
+	public function update_question_answer_data($n = 50, $offset = 0) {
655 655
 
656 656
 		// Get Total Number of Updates to run
657
-		$quiz_count_object = wp_count_posts( 'quiz' );
657
+		$quiz_count_object = wp_count_posts('quiz');
658 658
 		$quiz_count_published = $quiz_count_object->publish;
659 659
 
660 660
 		// Calculate if this is the last page
661
-		if ( 0 == $offset ) {
661
+		if (0 == $offset) {
662 662
 			$current_page = 1;
663 663
 		} else {
664
-			$current_page = intval( $offset / $n );
664
+			$current_page = intval($offset / $n);
665 665
 		} // End If Statement
666
-		$total_pages = intval( $quiz_count_published / $n );
666
+		$total_pages = intval($quiz_count_published / $n);
667 667
 
668 668
 
669
-		$args = array(	'post_type' 		=> 'quiz',
669
+		$args = array('post_type' 		=> 'quiz',
670 670
 						'posts_per_page' 		=> $n,
671 671
 						'offset'			=> $offset,
672 672
 						'post_status'		=> 'publish',
673 673
 						'suppress_filters' 	=> 0
674 674
 						);
675
-		$quizzes = get_posts( $args );
675
+		$quizzes = get_posts($args);
676 676
 
677 677
 		$old_answers = array();
678 678
 		$right_answers = array();
679 679
 		$old_user_answers = array();
680 680
 
681
-		if( is_array( $quizzes ) ) {
682
-			foreach( $quizzes as $quiz ) {
681
+		if (is_array($quizzes)) {
682
+			foreach ($quizzes as $quiz) {
683 683
 				$quiz_id = $quiz->ID;
684 684
 
685 685
 				// Get current user answers
686
-				$comments = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $quiz_id, 'type' => 'sensei_quiz_answers' ), true  );
686
+				$comments = Sensei_Utils::sensei_check_for_activity(array('post_id' => $quiz_id, 'type' => 'sensei_quiz_answers'), true);
687 687
 				// Need to always return an array, even with only 1 item
688
-				if ( !is_array($comments) ) {
689
-					$comments = array( $comments );
688
+				if ( ! is_array($comments)) {
689
+					$comments = array($comments);
690 690
 				}
691
-				foreach ( $comments as $comment ) {
691
+				foreach ($comments as $comment) {
692 692
 					$user_id = $comment->user_id;
693
-					$content = maybe_unserialize( base64_decode( $comment->comment_content ) );
694
-					$old_user_answers[ $quiz_id ][ $user_id ] = $content;
693
+					$content = maybe_unserialize(base64_decode($comment->comment_content));
694
+					$old_user_answers[$quiz_id][$user_id] = $content;
695 695
 				}
696 696
 
697 697
 				// Get correct answers
698
-				$questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
699
-				if( is_array( $questions ) ) {
700
-					foreach( $questions as $question ) {
701
-						$right_answer = get_post_meta( $question->ID, '_question_right_answer', true );
702
-						$right_answers[ $quiz_id ][ $question->ID ] = $right_answer;
698
+				$questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id);
699
+				if (is_array($questions)) {
700
+					foreach ($questions as $question) {
701
+						$right_answer = get_post_meta($question->ID, '_question_right_answer', true);
702
+						$right_answers[$quiz_id][$question->ID] = $right_answer;
703 703
 					}
704 704
 				}
705 705
 			}
706 706
 		}
707 707
 
708
-		if( is_array( $right_answers ) ) {
709
-			foreach( $right_answers as $quiz_id => $question ) {
708
+		if (is_array($right_answers)) {
709
+			foreach ($right_answers as $quiz_id => $question) {
710 710
 				$count = 0;
711
-				if( is_array( $question ) ) {
712
-					foreach( $question as $question_id => $answer ) {
711
+				if (is_array($question)) {
712
+					foreach ($question as $question_id => $answer) {
713 713
 						++$count;
714
-						if( isset( $old_user_answers[ $quiz_id ] ) ) {
715
-							$answers_linkup[ $quiz_id ][ $count ] = $question_id;
714
+						if (isset($old_user_answers[$quiz_id])) {
715
+							$answers_linkup[$quiz_id][$count] = $question_id;
716 716
 						}
717 717
 					}
718 718
 				}
719 719
 			}
720 720
 		}
721 721
 
722
-		if( is_array( $old_user_answers ) ) {
723
-			foreach( $old_user_answers as $quiz_id => $user_answers ) {
724
-				foreach( $user_answers as $user_id => $answers ) {
725
-					foreach( $answers as $answer_id => $user_answer ) {
726
-						$question_id = $answers_linkup[ $quiz_id ][ $answer_id ];
727
-						$new_user_answers[ $question_id ] = $user_answer;
728
-						Sensei_Utils::sensei_grade_question_auto( $question_id, '', $user_answer, $user_id );
722
+		if (is_array($old_user_answers)) {
723
+			foreach ($old_user_answers as $quiz_id => $user_answers) {
724
+				foreach ($user_answers as $user_id => $answers) {
725
+					foreach ($answers as $answer_id => $user_answer) {
726
+						$question_id = $answers_linkup[$quiz_id][$answer_id];
727
+						$new_user_answers[$question_id] = $user_answer;
728
+						Sensei_Utils::sensei_grade_question_auto($question_id, '', $user_answer, $user_id);
729 729
 					}
730
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
731
-					Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id );
732
-					Sensei_Utils::sensei_save_quiz_answers( $new_user_answers, $user_id );
730
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
731
+					Sensei_Utils::sensei_start_lesson($lesson_id, $user_id);
732
+					Sensei_Utils::sensei_save_quiz_answers($new_user_answers, $user_id);
733 733
 				}
734 734
 			}
735 735
 		}
736 736
 
737
-		if ( $current_page == $total_pages ) {
737
+		if ($current_page == $total_pages) {
738 738
 			return true;
739 739
 		} else {
740 740
 			return false;
@@ -749,15 +749,15 @@  discard block
 block discarded – undo
749 749
 	 * @return boolean
750 750
 	 */
751 751
 	public function update_question_grade_points() {
752
-		$args = array(	'post_type' 		=> 'question',
752
+		$args = array('post_type' 		=> 'question',
753 753
 						'posts_per_page' 		=> -1,
754 754
 						'post_status'		=> 'publish',
755 755
 						'suppress_filters' 	=> 0
756 756
 						);
757
-		$questions = get_posts( $args );
757
+		$questions = get_posts($args);
758 758
 
759
-		foreach( $questions as $question ) {
760
-			update_post_meta( $question->ID, '_question_grade', '1' );
759
+		foreach ($questions as $question) {
760
+			update_post_meta($question->ID, '_question_grade', '1');
761 761
 		}
762 762
 		return true;
763 763
 	} // End update_question_grade_points
@@ -769,7 +769,7 @@  discard block
 block discarded – undo
769 769
 	 * @return boolean
770 770
 	 */
771 771
 	public function convert_essay_paste_questions() {
772
-		$args = array(	'post_type' 		=> 'question',
772
+		$args = array('post_type' 		=> 'question',
773 773
 						'posts_per_page' 		=> -1,
774 774
 						'post_status'		=> 'publish',
775 775
 						'tax_query'			=> array(
@@ -781,14 +781,14 @@  discard block
 block discarded – undo
781 781
 						),
782 782
 						'suppress_filters' 	=> 0
783 783
 						);
784
-		$questions = get_posts( $args );
784
+		$questions = get_posts($args);
785 785
 
786
-		foreach( $questions as $question ) {
787
-			wp_set_object_terms( $question->ID, 'multi-line', 'question-type', false );
786
+		foreach ($questions as $question) {
787
+			wp_set_object_terms($question->ID, 'multi-line', 'question-type', false);
788 788
 
789
-			$quiz_id = get_post_meta( $question->ID, '_quiz_id', true );
790
-			if( 0 < intval( $quiz_id ) ) {
791
-				add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '0000', true );
789
+			$quiz_id = get_post_meta($question->ID, '_quiz_id', true);
790
+			if (0 < intval($quiz_id)) {
791
+				add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'0000', true);
792 792
 			}
793 793
 		}
794 794
 		return true;
@@ -800,33 +800,33 @@  discard block
 block discarded – undo
800 800
 	 * @since  1.5.0
801 801
 	 * @return boolean
802 802
 	 */
803
-	public function set_random_question_order( $n = 50, $offset = 0 ) {
803
+	public function set_random_question_order($n = 50, $offset = 0) {
804 804
 
805 805
 		// Get Total Number of Updates to run
806
-		$quiz_count_object = wp_count_posts( 'quiz' );
806
+		$quiz_count_object = wp_count_posts('quiz');
807 807
 		$quiz_count_published = $quiz_count_object->publish;
808 808
 
809 809
 		// Calculate if this is the last page
810
-		if ( 0 == $offset ) {
810
+		if (0 == $offset) {
811 811
 			$current_page = 1;
812 812
 		} else {
813
-			$current_page = intval( $offset / $n );
813
+			$current_page = intval($offset / $n);
814 814
 		} // End If Statement
815
-		$total_pages = intval( $quiz_count_published / $n );
815
+		$total_pages = intval($quiz_count_published / $n);
816 816
 
817
-		$args = array(	'post_type' 		=> 'quiz',
817
+		$args = array('post_type' 		=> 'quiz',
818 818
 						'post_status'		=> 'any',
819 819
 						'posts_per_page' 		=> $n,
820 820
 						'offset'			=> $offset,
821 821
 						'suppress_filters' 	=> 0
822 822
 						);
823
-		$quizzes = get_posts( $args );
823
+		$quizzes = get_posts($args);
824 824
 
825
-		foreach( $quizzes as $quiz ) {
826
-			update_post_meta( $quiz->ID, '_random_question_order', 'yes' );
825
+		foreach ($quizzes as $quiz) {
826
+			update_post_meta($quiz->ID, '_random_question_order', 'yes');
827 827
 		}
828 828
 
829
-		if ( $current_page == $total_pages ) {
829
+		if ($current_page == $total_pages) {
830 830
 			return true;
831 831
 		} else {
832 832
 			return false;
@@ -840,37 +840,37 @@  discard block
 block discarded – undo
840 840
 	 * @since  1.5.0
841 841
 	 * @return boolean
842 842
 	 */
843
-	public function set_default_show_question_count( $n = 50, $offset = 0 ) {
843
+	public function set_default_show_question_count($n = 50, $offset = 0) {
844 844
 
845
-		$args = array(	'post_type' 		=> 'quiz',
845
+		$args = array('post_type' 		=> 'quiz',
846 846
 						'post_status'		=> 'any',
847 847
 						'posts_per_page' 		=> $n,
848 848
 						'offset'			=> $offset,
849 849
 						'meta_key'			=> '_show_questions',
850 850
 						'suppress_filters' 	=> 0
851 851
 						);
852
-		$quizzes = get_posts( $args );
852
+		$quizzes = get_posts($args);
853 853
 
854
-		$total_quizzes = count( $quizzes );
854
+		$total_quizzes = count($quizzes);
855 855
 
856
-		if( 0 == intval( $total_quizzes ) ) {
856
+		if (0 == intval($total_quizzes)) {
857 857
 			return true;
858 858
 		}
859 859
 
860
-		foreach( $quizzes as $quiz ) {
861
-			delete_post_meta( $quiz->ID, '_show_questions' );
860
+		foreach ($quizzes as $quiz) {
861
+			delete_post_meta($quiz->ID, '_show_questions');
862 862
 		}
863 863
 
864
-		$total_pages = intval( $total_quizzes / $n );
864
+		$total_pages = intval($total_quizzes / $n);
865 865
 
866 866
 		// Calculate if this is the last page
867
-		if ( 0 == $offset ) {
867
+		if (0 == $offset) {
868 868
 			$current_page = 1;
869 869
 		} else {
870
-			$current_page = intval( $offset / $n );
870
+			$current_page = intval($offset / $n);
871 871
 		} // End If Statement
872 872
 
873
-		if ( $current_page == $total_pages ) {
873
+		if ($current_page == $total_pages) {
874 874
 			return true;
875 875
 		} else {
876 876
 			return false;
@@ -878,14 +878,14 @@  discard block
 block discarded – undo
878 878
 
879 879
 	}
880 880
 
881
-	public function remove_deleted_user_activity( $n = 50, $offset = 0 ) {
881
+	public function remove_deleted_user_activity($n = 50, $offset = 0) {
882 882
 
883
-		$all_activity = get_comments( array( 'status' => 'approve' ) );
883
+		$all_activity = get_comments(array('status' => 'approve'));
884 884
 		$activity_count = array();
885
-		foreach( $all_activity as $activity ) {
886
-			if( '' == $activity->comment_type ) continue;
887
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
888
-			if( 0 == $activity->user_id ) continue;
885
+		foreach ($all_activity as $activity) {
886
+			if ('' == $activity->comment_type) continue;
887
+			if (strpos('sensei_', $activity->comment_type) != 0) continue;
888
+			if (0 == $activity->user_id) continue;
889 889
 			$activity_count[] = $activity->comment_ID;
890 890
 		}
891 891
 
@@ -895,33 +895,33 @@  discard block
 block discarded – undo
895 895
 			'status' => 'approve'
896 896
 		);
897 897
 
898
-		$activities = get_comments( $args );
898
+		$activities = get_comments($args);
899 899
 
900
-		foreach( $activities as $activity ) {
901
-			if( '' == $activity->comment_type ) continue;
902
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
903
-			if( 0 == $activity->user_id ) continue;
900
+		foreach ($activities as $activity) {
901
+			if ('' == $activity->comment_type) continue;
902
+			if (strpos('sensei_', $activity->comment_type) != 0) continue;
903
+			if (0 == $activity->user_id) continue;
904 904
 
905
-			$user_exists = get_userdata( $activity->user_id );
905
+			$user_exists = get_userdata($activity->user_id);
906 906
 
907
-			if( ! $user_exists ) {
908
-				wp_delete_comment( intval( $activity->comment_ID ), true );
907
+			if ( ! $user_exists) {
908
+				wp_delete_comment(intval($activity->comment_ID), true);
909 909
 				wp_cache_flush();
910 910
 			}
911 911
 		}
912 912
 
913
-		$total_activities = count( $activity_count );
913
+		$total_activities = count($activity_count);
914 914
 
915
-		$total_pages = intval( $total_activities / $n );
915
+		$total_pages = intval($total_activities / $n);
916 916
 
917 917
 		// Calculate if this is the last page
918
-		if ( 0 == $offset ) {
918
+		if (0 == $offset) {
919 919
 			$current_page = 1;
920 920
 		} else {
921
-			$current_page = intval( $offset / $n );
921
+			$current_page = intval($offset / $n);
922 922
 		} // End If Statement
923 923
 
924
-		if ( $current_page >= $total_pages ) {
924
+		if ($current_page >= $total_pages) {
925 925
 			return true;
926 926
 		} else {
927 927
 			return false;
@@ -930,16 +930,16 @@  discard block
 block discarded – undo
930 930
 	}
931 931
 
932 932
 	public function add_teacher_role() {
933
-		add_role( 'teacher', __( 'Teacher', 'woothemes-sensei' ), array( 'read' => true, 'manage_sensei_grades' => true ) );
933
+		add_role('teacher', __('Teacher', 'woothemes-sensei'), array('read' => true, 'manage_sensei_grades' => true));
934 934
 		return true;
935 935
 	}
936 936
 
937 937
 	public function add_sensei_caps() {
938
-		$role = get_role( 'administrator' );
938
+		$role = get_role('administrator');
939 939
 
940
-		if( ! is_null( $role ) ) {
941
-			$role->add_cap( 'manage_sensei' );
942
-			$role->add_cap( 'manage_sensei_grades' );
940
+		if ( ! is_null($role)) {
941
+			$role->add_cap('manage_sensei');
942
+			$role->add_cap('manage_sensei_grades');
943 943
 		}
944 944
 
945 945
 		return true;
@@ -953,16 +953,16 @@  discard block
 block discarded – undo
953 953
 			'suppress_filters' 	=> 0
954 954
 		);
955 955
 
956
-		$questions = get_posts( $args );
956
+		$questions = get_posts($args);
957 957
 
958
-		foreach( $questions as $question ) {
958
+		foreach ($questions as $question) {
959 959
 
960
-			if( ! isset( $question->ID ) ) continue;
960
+			if ( ! isset($question->ID)) continue;
961 961
 
962
-			$quiz_id = get_post_meta( $question->ID, '_quiz_id', true );
962
+			$quiz_id = get_post_meta($question->ID, '_quiz_id', true);
963 963
 
964
-			$question_order = get_post_meta( $question->ID, '_quiz_question_order', true );
965
-			update_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $question_order );
964
+			$question_order = get_post_meta($question->ID, '_quiz_question_order', true);
965
+			update_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $question_order);
966 966
 
967 967
 		}
968 968
 
@@ -971,15 +971,15 @@  discard block
 block discarded – undo
971 971
 
972 972
 	public function update_quiz_settings() {
973 973
 
974
-		$settings = get_option( 'woothemes-sensei-settings', array() );
974
+		$settings = get_option('woothemes-sensei-settings', array());
975 975
 
976 976
 		$lesson_completion = false;
977
-		if( isset( $settings['lesson_completion'] ) ) {
977
+		if (isset($settings['lesson_completion'])) {
978 978
 			$lesson_completion = $settings['lesson_completion'];
979 979
 		}
980 980
 
981 981
 		$reset_quiz_allowed = false;
982
-		if( isset( $settings['quiz_reset_allowed'] ) ) {
982
+		if (isset($settings['quiz_reset_allowed'])) {
983 983
 			$reset_quiz_allowed = $settings['quiz_reset_allowed'];
984 984
 		}
985 985
 
@@ -990,20 +990,20 @@  discard block
 block discarded – undo
990 990
 			'suppress_filters' 	=> 0
991 991
 		);
992 992
 
993
-		$quizzes = get_posts( $args );
993
+		$quizzes = get_posts($args);
994 994
 
995
-		foreach( $quizzes as $quiz ) {
995
+		foreach ($quizzes as $quiz) {
996 996
 
997
-			if( ! isset( $quiz->ID ) ) continue;
997
+			if ( ! isset($quiz->ID)) continue;
998 998
 
999
-			if( isset( $lesson_completion ) && 'passed' == $lesson_completion ) {
1000
-				update_post_meta( $quiz->ID, '_pass_required', 'on' );
999
+			if (isset($lesson_completion) && 'passed' == $lesson_completion) {
1000
+				update_post_meta($quiz->ID, '_pass_required', 'on');
1001 1001
 			} else {
1002
-				update_post_meta( $quiz->ID, '_quiz_passmark', 0 );
1002
+				update_post_meta($quiz->ID, '_quiz_passmark', 0);
1003 1003
 			}
1004 1004
 
1005
-			if( isset( $reset_quiz_allowed ) && $reset_quiz_allowed ) {
1006
-				update_post_meta( $quiz->ID, '_enable_quiz_reset', 'on' );
1005
+			if (isset($reset_quiz_allowed) && $reset_quiz_allowed) {
1006
+				update_post_meta($quiz->ID, '_enable_quiz_reset', 'on');
1007 1007
 			}
1008 1008
 		}
1009 1009
 
@@ -1018,22 +1018,22 @@  discard block
 block discarded – undo
1018 1018
 			'suppress_filters' 	=> 0
1019 1019
 		);
1020 1020
 
1021
-		$lessons = get_posts( $args );
1021
+		$lessons = get_posts($args);
1022 1022
 
1023
-		foreach( $lessons as $lesson ) {
1023
+		foreach ($lessons as $lesson) {
1024 1024
 
1025
-			if( ! isset( $lesson->ID ) ) continue;
1025
+			if ( ! isset($lesson->ID)) continue;
1026 1026
 
1027
-			$course_id = get_post_meta( $lesson->ID, '_lesson_course', true);
1027
+			$course_id = get_post_meta($lesson->ID, '_lesson_course', true);
1028 1028
 
1029
-			if( $course_id ) {
1030
-				update_post_meta( $lesson->ID, '_order_' . $course_id, 0 );
1029
+			if ($course_id) {
1030
+				update_post_meta($lesson->ID, '_order_'.$course_id, 0);
1031 1031
 			}
1032 1032
 
1033
-            $module = Sensei()->modules->get_lesson_module( $lesson->ID );
1033
+            $module = Sensei()->modules->get_lesson_module($lesson->ID);
1034 1034
 
1035
-            if( $module ) {
1036
-                update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 );
1035
+            if ($module) {
1036
+                update_post_meta($lesson->ID, '_order_module_'.$module->term_id, 0);
1037 1037
             }
1038 1038
 
1039 1039
 		}
@@ -1042,10 +1042,10 @@  discard block
 block discarded – undo
1042 1042
 	}
1043 1043
 
1044 1044
 	public function add_editor_caps() {
1045
-		$role = get_role( 'editor' );
1045
+		$role = get_role('editor');
1046 1046
 
1047
-		if( ! is_null( $role ) ) {
1048
-			$role->add_cap( 'manage_sensei_grades' );
1047
+		if ( ! is_null($role)) {
1048
+			$role->add_cap('manage_sensei_grades');
1049 1049
 		}
1050 1050
 
1051 1051
 		return true;
@@ -1064,26 +1064,26 @@  discard block
 block discarded – undo
1064 1064
 					WHERE m.meta_key = '_question_right_answer' AND m.meta_value LIKE '%|%' AND m.meta_value NOT LIKE '%||%'
1065 1065
 						AND m.post_id = tr.object_id AND tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.term_id = t.term_id
1066 1066
 						AND tt.taxonomy = 'question-type' AND t.slug = 'gap-fill'";
1067
-		$wpdb->query( $sql );
1067
+		$wpdb->query($sql);
1068 1068
 
1069 1069
 		return true;
1070 1070
 	}
1071 1071
 
1072
-	public function update_quiz_lesson_relationship( $n = 50, $offset = 0 ) {
1073
-		$count_object = wp_count_posts( 'quiz' );
1072
+	public function update_quiz_lesson_relationship($n = 50, $offset = 0) {
1073
+		$count_object = wp_count_posts('quiz');
1074 1074
 
1075 1075
 		$count_published = 0;
1076
-		foreach ( $count_object AS $status => $count ) {
1076
+		foreach ($count_object AS $status => $count) {
1077 1077
 			$count_published += $count;
1078 1078
 		}
1079 1079
 
1080 1080
 		// Calculate if this is the last page
1081
-		if ( 0 == $offset ) {
1081
+		if (0 == $offset) {
1082 1082
 			$current_page = 1;
1083 1083
 		} else {
1084
-			$current_page = intval( $offset / $n );
1084
+			$current_page = intval($offset / $n);
1085 1085
 		}
1086
-		$total_pages = ceil( $count_published / $n );
1086
+		$total_pages = ceil($count_published / $n);
1087 1087
 
1088 1088
 		$args = array(
1089 1089
 			'post_type' => 'quiz',
@@ -1092,52 +1092,52 @@  discard block
 block discarded – undo
1092 1092
 			'post_status' => 'any'
1093 1093
 		);
1094 1094
 
1095
-		$quizzes = get_posts( $args );
1095
+		$quizzes = get_posts($args);
1096 1096
 
1097
-		foreach( $quizzes as $quiz ) {
1097
+		foreach ($quizzes as $quiz) {
1098 1098
 
1099
-			if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) continue;
1099
+			if ( ! isset($quiz->ID) || 0 != $quiz->post_parent) continue;
1100 1100
 
1101
-			$lesson_id = get_post_meta( $quiz->ID, '_quiz_lesson', true );
1101
+			$lesson_id = get_post_meta($quiz->ID, '_quiz_lesson', true);
1102 1102
 
1103
-			if( empty( $lesson_id ) ) continue;
1103
+			if (empty($lesson_id)) continue;
1104 1104
 
1105 1105
 			$data = array(
1106 1106
 				'ID' => $quiz->ID,
1107 1107
 				'post_parent' => $lesson_id,
1108 1108
 			);
1109
-			wp_update_post( $data );
1109
+			wp_update_post($data);
1110 1110
 
1111
-			update_post_meta( $lesson_id, '_lesson_quiz', $quiz->ID );
1111
+			update_post_meta($lesson_id, '_lesson_quiz', $quiz->ID);
1112 1112
 		}
1113 1113
 
1114
-		if ( $current_page == $total_pages || 0 == $total_pages ) {
1114
+		if ($current_page == $total_pages || 0 == $total_pages) {
1115 1115
 			return true;
1116 1116
 		} else {
1117 1117
 			return false;
1118 1118
 		}
1119 1119
 	}
1120 1120
 
1121
-	function status_changes_fix_lessons( $n = 50, $offset = 0 ) {
1121
+	function status_changes_fix_lessons($n = 50, $offset = 0) {
1122 1122
 		global $wpdb;
1123 1123
 
1124
-		$count_object = wp_count_posts( 'lesson' );
1124
+		$count_object = wp_count_posts('lesson');
1125 1125
 		$count_published = 0;
1126
-		foreach ( $count_object AS $status => $count ) {
1126
+		foreach ($count_object AS $status => $count) {
1127 1127
 			$count_published += $count;
1128 1128
 		}
1129 1129
 
1130
-		if ( 0 == $count_published ) {
1130
+		if (0 == $count_published) {
1131 1131
 			return true;
1132 1132
 		}
1133 1133
 
1134 1134
 		// Calculate if this is the last page
1135
-		if ( 0 == $offset ) {
1135
+		if (0 == $offset) {
1136 1136
 			$current_page = 1;
1137 1137
 		} else {
1138
-			$current_page = intval( $offset / $n );
1138
+			$current_page = intval($offset / $n);
1139 1139
 		}
1140
-		$total_pages = ceil( $count_published / $n );
1140
+		$total_pages = ceil($count_published / $n);
1141 1141
 
1142 1142
 		// Get all Lessons with (and without) Quizzes...
1143 1143
 		$args = array(
@@ -1147,26 +1147,26 @@  discard block
 block discarded – undo
1147 1147
 			'offset' => $offset,
1148 1148
 			'fields' => 'ids'
1149 1149
 		);
1150
-		$lesson_ids = get_posts( $args );
1150
+		$lesson_ids = get_posts($args);
1151 1151
 
1152 1152
 		// ...get all Quiz IDs for the above Lessons
1153
-		$id_list = join( ',', $lesson_ids );
1154
-		$meta_list = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A );
1153
+		$id_list = join(',', $lesson_ids);
1154
+		$meta_list = $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A);
1155 1155
 		$lesson_quiz_ids = array();
1156
-		if ( !empty($meta_list) ) {
1157
-			foreach ( $meta_list as $metarow ) {
1156
+		if ( ! empty($meta_list)) {
1157
+			foreach ($meta_list as $metarow) {
1158 1158
 				$lesson_id = $metarow['meta_value'];
1159 1159
 				$quiz_id = $metarow['post_id'];
1160
-				$lesson_quiz_ids[ $lesson_id ] = $quiz_id;
1160
+				$lesson_quiz_ids[$lesson_id] = $quiz_id;
1161 1161
 			}
1162 1162
 		}
1163 1163
 
1164 1164
 		// ...check all Quiz IDs for questions
1165
-		$id_list = join( ',', array_values($lesson_quiz_ids) );
1166
-		$meta_list = $wpdb->get_results( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A );
1165
+		$id_list = join(',', array_values($lesson_quiz_ids));
1166
+		$meta_list = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A);
1167 1167
 		$lesson_quiz_ids_with_questions = array();
1168
-		if ( !empty($meta_list) ) {
1169
-			foreach ( $meta_list as $metarow ) {
1168
+		if ( ! empty($meta_list)) {
1169
+			foreach ($meta_list as $metarow) {
1170 1170
 				$quiz_id = $metarow['meta_value'];
1171 1171
 				$lesson_quiz_ids_with_questions[] = $quiz_id;
1172 1172
 			}
@@ -1174,49 +1174,49 @@  discard block
 block discarded – undo
1174 1174
 
1175 1175
 		// For each quiz check there are questions, if not remove the corresponding meta keys from Quizzes and Lessons
1176 1176
 		// if there are questions on the quiz add the corresponding meta keys to Quizzes and Lessons
1177
-		$d_count = $a_count =0;
1178
-		foreach ( $lesson_quiz_ids AS $lesson_id => $quiz_id ) {
1179
-			if ( !in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1177
+		$d_count = $a_count = 0;
1178
+		foreach ($lesson_quiz_ids AS $lesson_id => $quiz_id) {
1179
+			if ( ! in_array($quiz_id, $lesson_quiz_ids_with_questions)) {
1180 1180
 
1181 1181
 				// Quiz has no questions, drop the corresponding data
1182
-				delete_post_meta( $quiz_id, '_pass_required' );
1183
-				delete_post_meta( $quiz_id, '_quiz_passmark' );
1184
-				delete_post_meta( $lesson_id, '_quiz_has_questions' );
1182
+				delete_post_meta($quiz_id, '_pass_required');
1183
+				delete_post_meta($quiz_id, '_quiz_passmark');
1184
+				delete_post_meta($lesson_id, '_quiz_has_questions');
1185 1185
 				$d_count++;
1186 1186
 			}
1187
-			else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1187
+			else if (in_array($quiz_id, $lesson_quiz_ids_with_questions)) {
1188 1188
 
1189 1189
 				// Quiz has no questions, drop the corresponding data
1190
-				update_post_meta( $lesson_id, '_quiz_has_questions', true );
1190
+				update_post_meta($lesson_id, '_quiz_has_questions', true);
1191 1191
 				$a_count++;
1192 1192
 			}
1193 1193
 		}
1194 1194
 
1195
-		if ( $current_page == $total_pages ) {
1195
+		if ($current_page == $total_pages) {
1196 1196
 			return true;
1197 1197
 		} else {
1198 1198
 			return false;
1199 1199
 		}
1200 1200
 	}
1201 1201
 
1202
-	function status_changes_convert_lessons( $n = 50, $offset = 0 ) {
1202
+	function status_changes_convert_lessons($n = 50, $offset = 0) {
1203 1203
 		global $wpdb;
1204 1204
 
1205
-		wp_defer_comment_counting( true );
1205
+		wp_defer_comment_counting(true);
1206 1206
 
1207
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1207
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1208 1208
 
1209
-		if ( 0 == $user_count_result ) {
1209
+		if (0 == $user_count_result) {
1210 1210
 			return true;
1211 1211
 		}
1212 1212
 
1213
-		if ( 0 == $offset ) {
1213
+		if (0 == $offset) {
1214 1214
 			$current_page = 1;
1215 1215
 		} else {
1216
-			$current_page = intval( $offset / $n );
1216
+			$current_page = intval($offset / $n);
1217 1217
 		}
1218 1218
 
1219
-		$total_pages = ceil( $user_count_result / $n );
1219
+		$total_pages = ceil($user_count_result / $n);
1220 1220
 
1221 1221
 		// Get all Lessons with Quizzes...
1222 1222
 		$args = array(
@@ -1231,34 +1231,34 @@  discard block
 block discarded – undo
1231 1231
 			),
1232 1232
 			'fields' => 'ids'
1233 1233
 		);
1234
-		$lesson_ids_with_quizzes = get_posts( $args );
1234
+		$lesson_ids_with_quizzes = get_posts($args);
1235 1235
 		// ...get all Quiz IDs for the above Lessons
1236
-		$id_list = join( ',', $lesson_ids_with_quizzes );
1237
-		$meta_list = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A );
1236
+		$id_list = join(',', $lesson_ids_with_quizzes);
1237
+		$meta_list = $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A);
1238 1238
 		$lesson_quiz_ids = array();
1239
-		if ( !empty($meta_list) ) {
1240
-			foreach ( $meta_list as $metarow ) {
1239
+		if ( ! empty($meta_list)) {
1240
+			foreach ($meta_list as $metarow) {
1241 1241
 				$lesson_id = $metarow['meta_value'];
1242 1242
 				$quiz_id = $metarow['post_id'];
1243
-				$lesson_quiz_ids[ $lesson_id ] = $quiz_id;
1243
+				$lesson_quiz_ids[$lesson_id] = $quiz_id;
1244 1244
 			}
1245 1245
 		}
1246 1246
 
1247 1247
 		// ...get all Pass Required & Passmarks for the above Lesson/Quizzes
1248
-		$id_list = join( ',', array_values($lesson_quiz_ids) );
1249
-		$meta_list = $wpdb->get_results( "SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE ( meta_key = '_pass_required' OR meta_key = '_quiz_passmark' ) AND post_id IN ($id_list)", ARRAY_A );
1248
+		$id_list = join(',', array_values($lesson_quiz_ids));
1249
+		$meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE ( meta_key = '_pass_required' OR meta_key = '_quiz_passmark' ) AND post_id IN ($id_list)", ARRAY_A);
1250 1250
 		$quizzes_pass_required = $quizzes_passmarks = array();
1251
-		if ( !empty($meta_list) ) {
1252
-			foreach ( $meta_list as $metarow ) {
1253
-				if ( !empty($metarow['meta_value']) ) {
1251
+		if ( ! empty($meta_list)) {
1252
+			foreach ($meta_list as $metarow) {
1253
+				if ( ! empty($metarow['meta_value'])) {
1254 1254
 					$quiz_id = $metarow['post_id'];
1255 1255
 					$key = $metarow['meta_key'];
1256 1256
 					$value = $metarow['meta_value'];
1257
-					if ( '_pass_required' == $key ) {
1258
-						$quizzes_pass_required[ $quiz_id ] = $value;
1257
+					if ('_pass_required' == $key) {
1258
+						$quizzes_pass_required[$quiz_id] = $value;
1259 1259
 					}
1260
-					if ( '_quiz_passmark' == $key ) {
1261
-						$quizzes_passmarks[ $quiz_id ] = $value;
1260
+					if ('_quiz_passmark' == $key) {
1261
+						$quizzes_passmarks[$quiz_id] = $value;
1262 1262
 					}
1263 1263
 				}
1264 1264
 			}
@@ -1272,41 +1272,41 @@  discard block
 block discarded – undo
1272 1272
 		$check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_lesson_status' ";
1273 1273
 
1274 1274
 		// $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time?
1275
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1275
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1276 1276
 
1277
-		foreach ( $user_ids AS $user_id ) {
1277
+		foreach ($user_ids AS $user_id) {
1278 1278
 
1279 1279
 			$lesson_ends = $lesson_grades = $lesson_answers = array();
1280 1280
 
1281 1281
 			// Pre-process the lesson ends
1282
-			$_lesson_ends = $wpdb->get_results( $wpdb->prepare($end_sql, $user_id), ARRAY_A );
1283
-			foreach ( $_lesson_ends as $lesson_end ) {
1282
+			$_lesson_ends = $wpdb->get_results($wpdb->prepare($end_sql, $user_id), ARRAY_A);
1283
+			foreach ($_lesson_ends as $lesson_end) {
1284 1284
 				// This will overwrite existing entries with the newer ones
1285
-				$lesson_ends[ $lesson_end['comment_post_ID'] ] = $lesson_end['comment_date'];
1285
+				$lesson_ends[$lesson_end['comment_post_ID']] = $lesson_end['comment_date'];
1286 1286
 			}
1287
-			unset( $_lesson_ends );
1287
+			unset($_lesson_ends);
1288 1288
 
1289 1289
 			// Pre-process the lesson grades
1290
-			$_lesson_grades = $wpdb->get_results( $wpdb->prepare($grade_sql, $user_id), ARRAY_A );
1291
-			foreach ( $_lesson_grades as $lesson_grade ) {
1290
+			$_lesson_grades = $wpdb->get_results($wpdb->prepare($grade_sql, $user_id), ARRAY_A);
1291
+			foreach ($_lesson_grades as $lesson_grade) {
1292 1292
 				// This will overwrite existing entries with the newer ones (assuming the grade is higher)
1293
-				if ( empty($lesson_grades[ $lesson_grade['comment_post_ID'] ]) || $lesson_grades[ $lesson_grade['comment_post_ID'] ] < $lesson_grade['comment_content'] ) {
1294
-					$lesson_grades[ $lesson_grade['comment_post_ID'] ] = $lesson_grade['comment_content'];
1293
+				if (empty($lesson_grades[$lesson_grade['comment_post_ID']]) || $lesson_grades[$lesson_grade['comment_post_ID']] < $lesson_grade['comment_content']) {
1294
+					$lesson_grades[$lesson_grade['comment_post_ID']] = $lesson_grade['comment_content'];
1295 1295
 				}
1296 1296
 			}
1297
-			unset( $_lesson_grades );
1297
+			unset($_lesson_grades);
1298 1298
 
1299 1299
 			// Pre-process the lesson answers
1300
-			$_lesson_answers = $wpdb->get_results( $wpdb->prepare($answers_sql, $user_id), ARRAY_A );
1301
-			foreach ( $_lesson_answers as $lesson_answer ) {
1300
+			$_lesson_answers = $wpdb->get_results($wpdb->prepare($answers_sql, $user_id), ARRAY_A);
1301
+			foreach ($_lesson_answers as $lesson_answer) {
1302 1302
 				// This will overwrite existing entries with the newer ones
1303
-				$lesson_answers[ $lesson_answer['comment_post_ID'] ] = $lesson_answer['comment_content'];
1303
+				$lesson_answers[$lesson_answer['comment_post_ID']] = $lesson_answer['comment_content'];
1304 1304
 			}
1305
-			unset( $_lesson_answers );
1305
+			unset($_lesson_answers);
1306 1306
 
1307 1307
 			// Grab all the lesson starts for the user
1308
-			$lesson_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A );
1309
-			foreach ( $lesson_starts as $lesson_log ) {
1308
+			$lesson_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A);
1309
+			foreach ($lesson_starts as $lesson_log) {
1310 1310
 
1311 1311
 				$lesson_id = $lesson_log['comment_post_ID'];
1312 1312
 
@@ -1319,23 +1319,23 @@  discard block
 block discarded – undo
1319 1319
 					'start' => $status_date,
1320 1320
 				);
1321 1321
 				// Check if there is a lesson end
1322
-				if ( !empty($lesson_ends[$lesson_id]) ) {
1322
+				if ( ! empty($lesson_ends[$lesson_id])) {
1323 1323
 					$status_date = $lesson_ends[$lesson_id];
1324 1324
 					// Check lesson has quiz
1325
-					if ( !empty( $lesson_quiz_ids[$lesson_id] ) ) {
1325
+					if ( ! empty($lesson_quiz_ids[$lesson_id])) {
1326 1326
 						// Check for the quiz answers
1327
-						if ( !empty($lesson_answers[$quiz_id]) ) {
1327
+						if ( ! empty($lesson_answers[$quiz_id])) {
1328 1328
 							$meta_data['questions_asked'] = $lesson_answers[$quiz_id];
1329 1329
 						}
1330 1330
 						// Check if there is a quiz grade
1331 1331
 						$quiz_id = $lesson_quiz_ids[$lesson_id];
1332
-						if ( !empty($lesson_grades[$quiz_id]) ) {
1332
+						if ( ! empty($lesson_grades[$quiz_id])) {
1333 1333
 							$meta_data['grade'] = $quiz_grade = $lesson_grades[$quiz_id];
1334 1334
 							// Check if the user has to get the passmark and has or not
1335
-							if ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] <= $quiz_grade ) {
1335
+							if ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] <= $quiz_grade) {
1336 1336
 								$status = 'passed';
1337 1337
 							}
1338
-							elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) {
1338
+							elseif ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] > $quiz_grade) {
1339 1339
 								$status = 'failed';
1340 1340
 							}
1341 1341
 							else {
@@ -1363,26 +1363,26 @@  discard block
 block discarded – undo
1363 1363
 						'comment_author' => '',
1364 1364
 					);
1365 1365
 				// Check it doesn't already exist
1366
-				$sql = $wpdb->prepare( $check_existing_sql, $lesson_id, $user_id );
1367
-				$comment_ID = $wpdb->get_var( $sql );
1368
-				if ( !$comment_ID ) {
1366
+				$sql = $wpdb->prepare($check_existing_sql, $lesson_id, $user_id);
1367
+				$comment_ID = $wpdb->get_var($sql);
1368
+				if ( ! $comment_ID) {
1369 1369
 					// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1370 1370
 					$wpdb->insert($wpdb->comments, $data);
1371 1371
 					$comment_ID = (int) $wpdb->insert_id;
1372 1372
 
1373
-					if ( $comment_ID && !empty($meta_data) ) {
1374
-						foreach ( $meta_data as $key => $value ) {
1373
+					if ($comment_ID && ! empty($meta_data)) {
1374
+						foreach ($meta_data as $key => $value) {
1375 1375
 							// Bypassing WP add_comment_meta(() so no actions/filters are run
1376
-							if ( $wpdb->get_var( $wpdb->prepare(
1376
+							if ($wpdb->get_var($wpdb->prepare(
1377 1377
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1378
-									$comment_ID, $key ) ) ) {
1378
+									$comment_ID, $key ))) {
1379 1379
 									continue; // Found the meta data already
1380 1380
 							}
1381
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1381
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1382 1382
 								'comment_id' => $comment_ID,
1383 1383
 								'meta_key' => $key,
1384 1384
 								'meta_value' => $value
1385
-							) );
1385
+							));
1386 1386
 						}
1387 1387
 					}
1388 1388
 				}
@@ -1390,40 +1390,40 @@  discard block
 block discarded – undo
1390 1390
 		}
1391 1391
 		$wpdb->flush();
1392 1392
 
1393
-		if ( $current_page == $total_pages ) {
1393
+		if ($current_page == $total_pages) {
1394 1394
 			return true;
1395 1395
 		} else {
1396 1396
 			return false;
1397 1397
 		}
1398 1398
 	}
1399 1399
 
1400
-	function status_changes_convert_courses( $n = 50, $offset = 0 ) {
1400
+	function status_changes_convert_courses($n = 50, $offset = 0) {
1401 1401
 		global $wpdb;
1402 1402
 
1403
-		wp_defer_comment_counting( true );
1403
+		wp_defer_comment_counting(true);
1404 1404
 
1405
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1405
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1406 1406
 
1407
-		if ( 0 == $user_count_result ) {
1407
+		if (0 == $user_count_result) {
1408 1408
 			return true;
1409 1409
 		}
1410 1410
 
1411
-		if ( 0 == $offset ) {
1411
+		if (0 == $offset) {
1412 1412
 			$current_page = 1;
1413 1413
 		} else {
1414
-			$current_page = intval( $offset / $n );
1414
+			$current_page = intval($offset / $n);
1415 1415
 		}
1416 1416
 
1417
-		$total_pages = ceil( $user_count_result / $n );
1417
+		$total_pages = ceil($user_count_result / $n);
1418 1418
 
1419 1419
 		// Get all Lesson => Course relationships
1420
-		$meta_list = $wpdb->get_results( "SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course'", ARRAY_A );
1420
+		$meta_list = $wpdb->get_results("SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course'", ARRAY_A);
1421 1421
 		$course_lesson_ids = array();
1422
-		if ( !empty($meta_list) ) {
1423
-			foreach ( $meta_list as $metarow ) {
1422
+		if ( ! empty($meta_list)) {
1423
+			foreach ($meta_list as $metarow) {
1424 1424
 				$lesson_id = $metarow['post_id'];
1425 1425
 				$course_id = $metarow['meta_value'];
1426
-				$course_lesson_ids[ $course_id ][] = $lesson_id;
1426
+				$course_lesson_ids[$course_id][] = $lesson_id;
1427 1427
 			}
1428 1428
 		}
1429 1429
 
@@ -1433,13 +1433,13 @@  discard block
 block discarded – undo
1433 1433
 		$check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_course_status' ";
1434 1434
 
1435 1435
 		// $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time?
1436
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1436
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1437 1437
 
1438
-		foreach ( $user_ids AS $user_id ) {
1438
+		foreach ($user_ids AS $user_id) {
1439 1439
 
1440 1440
 			// Grab all the course starts for the user
1441
-			$course_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A );
1442
-			foreach ( $course_starts as $course_log ) {
1441
+			$course_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A);
1442
+			foreach ($course_starts as $course_log) {
1443 1443
 
1444 1444
 				$course_id = $course_log['comment_post_ID'];
1445 1445
 
@@ -1454,23 +1454,23 @@  discard block
 block discarded – undo
1454 1454
 					'percent' => 0,
1455 1455
 				);
1456 1456
 				// Check if the course has lessons
1457
-				if ( !empty( $course_lesson_ids[$course_id] ) ) {
1457
+				if ( ! empty($course_lesson_ids[$course_id])) {
1458 1458
 
1459 1459
 					$lessons_completed = 0;
1460
-					$total_lessons = count( $course_lesson_ids[ $course_id ] );
1460
+					$total_lessons = count($course_lesson_ids[$course_id]);
1461 1461
 
1462 1462
 					// Don't use prepare as we need to provide the id join
1463
-					$sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[ $course_id ]) );
1463
+					$sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[$course_id]));
1464 1464
 					// Get all lesson statuses for this Courses' lessons
1465
-					$lesson_statuses = $wpdb->get_results( $sql, ARRAY_A );
1465
+					$lesson_statuses = $wpdb->get_results($sql, ARRAY_A);
1466 1466
 					// Not enough lesson statuses, thus cannot be complete
1467
-					if ( $total_lessons > count($lesson_statuses) ) {
1467
+					if ($total_lessons > count($lesson_statuses)) {
1468 1468
 						$status = 'in-progress';
1469 1469
 					}
1470 1470
 					// Count each lesson to work out the overall percentage
1471
-					foreach ( $lesson_statuses as $lesson_status ) {
1471
+					foreach ($lesson_statuses as $lesson_status) {
1472 1472
 						$status_date = $lesson_status['comment_date'];
1473
-						switch ( $lesson_status['status'] ) {
1473
+						switch ($lesson_status['status']) {
1474 1474
 							case 'complete': // Lesson has no quiz/questions
1475 1475
 							case 'graded': // Lesson has quiz, but it's not important what the grade was
1476 1476
 							case 'passed':
@@ -1485,7 +1485,7 @@  discard block
 block discarded – undo
1485 1485
 						}
1486 1486
 					}
1487 1487
 					$meta_data['complete'] = $lessons_completed;
1488
-					$meta_data['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) );
1488
+					$meta_data['percent'] = abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0));
1489 1489
 				}
1490 1490
 				else {
1491 1491
 					// Course has no lessons, therefore cannot be 'complete'
@@ -1502,26 +1502,26 @@  discard block
 block discarded – undo
1502 1502
 						'comment_author' => '',
1503 1503
 					);
1504 1504
 				// Check it doesn't already exist
1505
-				$sql = $wpdb->prepare( $check_existing_sql, $course_id, $user_id );
1506
-				$comment_ID = $wpdb->get_var( $sql );
1507
-				if ( !$comment_ID ) {
1505
+				$sql = $wpdb->prepare($check_existing_sql, $course_id, $user_id);
1506
+				$comment_ID = $wpdb->get_var($sql);
1507
+				if ( ! $comment_ID) {
1508 1508
 					// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1509 1509
 					$wpdb->insert($wpdb->comments, $data);
1510 1510
 					$comment_ID = (int) $wpdb->insert_id;
1511 1511
 
1512
-					if ( $comment_ID && !empty($meta_data) ) {
1513
-						foreach ( $meta_data as $key => $value ) {
1512
+					if ($comment_ID && ! empty($meta_data)) {
1513
+						foreach ($meta_data as $key => $value) {
1514 1514
 							// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1515
-							if ( $wpdb->get_var( $wpdb->prepare(
1515
+							if ($wpdb->get_var($wpdb->prepare(
1516 1516
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1517
-									$comment_ID, $key ) ) ) {
1517
+									$comment_ID, $key ))) {
1518 1518
 									continue; // Found the meta data already
1519 1519
 							}
1520
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1520
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1521 1521
 								'comment_id' => $comment_ID,
1522 1522
 								'meta_key' => $key,
1523 1523
 								'meta_value' => $value
1524
-							) );
1524
+							));
1525 1525
 						}
1526 1526
 					}
1527 1527
 				}
@@ -1529,7 +1529,7 @@  discard block
 block discarded – undo
1529 1529
 		}
1530 1530
 		$wpdb->flush();
1531 1531
 
1532
-		if ( $current_page == $total_pages ) {
1532
+		if ($current_page == $total_pages) {
1533 1533
 			return true;
1534 1534
 		} else {
1535 1535
 			return false;
@@ -1545,70 +1545,70 @@  discard block
 block discarded – undo
1545 1545
 	 * @param type $offset
1546 1546
 	 * @return boolean
1547 1547
 	 */
1548
-	function status_changes_repair_course_statuses( $n = 50, $offset = 0 ) {
1548
+	function status_changes_repair_course_statuses($n = 50, $offset = 0) {
1549 1549
 		global $wpdb;
1550 1550
 
1551
-		$count_object = wp_count_posts( 'lesson' );
1551
+		$count_object = wp_count_posts('lesson');
1552 1552
 		$count_published = $count_object->publish;
1553 1553
 
1554
-		if ( 0 == $count_published ) {
1554
+		if (0 == $count_published) {
1555 1555
 			return true;
1556 1556
 		}
1557 1557
 
1558 1558
 		// Calculate if this is the last page
1559
-		if ( 0 == $offset ) {
1559
+		if (0 == $offset) {
1560 1560
 			$current_page = 1;
1561 1561
 		} else {
1562
-			$current_page = intval( $offset / $n );
1562
+			$current_page = intval($offset / $n);
1563 1563
 		}
1564
-		$total_pages = ceil( $count_published / $n );
1564
+		$total_pages = ceil($count_published / $n);
1565 1565
 
1566 1566
 		$course_lesson_ids = $lesson_user_statuses = array();
1567 1567
 
1568 1568
 		// Get all Lesson => Course relationships
1569
-		$meta_list = $wpdb->get_results( "SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course' LIMIT $n OFFSET $offset ", ARRAY_A );
1570
-		if ( !empty($meta_list) ) {
1571
-			foreach ( $meta_list as $metarow ) {
1569
+		$meta_list = $wpdb->get_results("SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course' LIMIT $n OFFSET $offset ", ARRAY_A);
1570
+		if ( ! empty($meta_list)) {
1571
+			foreach ($meta_list as $metarow) {
1572 1572
 				$lesson_id = $metarow['post_id'];
1573 1573
 				$course_id = $metarow['meta_value'];
1574
-				$course_lesson_ids[ $course_id ][] = $lesson_id;
1574
+				$course_lesson_ids[$course_id][] = $lesson_id;
1575 1575
 			}
1576 1576
 		}
1577 1577
 
1578 1578
 		// Get all Lesson => Course relationships
1579
-		$status_list = $wpdb->get_results( "SELECT user_id, comment_post_ID, comment_approved FROM $wpdb->comments WHERE comment_type = 'sensei_lesson_status' GROUP BY user_id, comment_post_ID ", ARRAY_A );
1580
-		if ( !empty($status_list) ) {
1581
-			foreach ( $status_list as $status ) {
1582
-				$lesson_user_statuses[ $status['comment_post_ID'] ][ $status['user_id'] ] = $status['comment_approved'];
1579
+		$status_list = $wpdb->get_results("SELECT user_id, comment_post_ID, comment_approved FROM $wpdb->comments WHERE comment_type = 'sensei_lesson_status' GROUP BY user_id, comment_post_ID ", ARRAY_A);
1580
+		if ( ! empty($status_list)) {
1581
+			foreach ($status_list as $status) {
1582
+				$lesson_user_statuses[$status['comment_post_ID']][$status['user_id']] = $status['comment_approved'];
1583 1583
 			}
1584 1584
 		}
1585 1585
 
1586
-		$course_completion = Sensei()->settings->settings[ 'course_completion' ];
1586
+		$course_completion = Sensei()->settings->settings['course_completion'];
1587 1587
 
1588 1588
 		$per_page = 40;
1589 1589
 		$comment_id_offset = $count = 0;
1590 1590
 
1591 1591
 		$course_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_course_status' AND comment_ID > %d LIMIT $per_page";
1592 1592
 		// $per_page users at a time
1593
-		while ( $course_statuses = $wpdb->get_results( $wpdb->prepare($course_sql, $comment_id_offset) ) ) {
1593
+		while ($course_statuses = $wpdb->get_results($wpdb->prepare($course_sql, $comment_id_offset))) {
1594 1594
 
1595
-			foreach ( $course_statuses AS $course_status ) {
1595
+			foreach ($course_statuses AS $course_status) {
1596 1596
 				$user_id = $course_status->user_id;
1597 1597
 				$course_id = $course_status->comment_post_ID;
1598
-				$total_lessons = count( $course_lesson_ids[ $course_id ] );
1599
-				if ( $total_lessons <= 0 ) {
1598
+				$total_lessons = count($course_lesson_ids[$course_id]);
1599
+				if ($total_lessons <= 0) {
1600 1600
 					$total_lessons = 1; // Fix division of zero error, some courses have no lessons
1601 1601
 				}
1602 1602
 				$lessons_completed = 0;
1603 1603
 				$status = 'in-progress';
1604 1604
 
1605 1605
 				// Some Courses have no lessons... (can they ever be complete?)
1606
-				if ( !empty($course_lesson_ids[ $course_id ]) ) {
1607
-					foreach( $course_lesson_ids[ $course_id ] AS $lesson_id ) {
1608
-						$lesson_status = $lesson_user_statuses[ $lesson_id ][ $user_id ];
1606
+				if ( ! empty($course_lesson_ids[$course_id])) {
1607
+					foreach ($course_lesson_ids[$course_id] AS $lesson_id) {
1608
+						$lesson_status = $lesson_user_statuses[$lesson_id][$user_id];
1609 1609
 						// If lessons are complete without needing quizzes to be passed
1610
-						if ( 'passed' != $course_completion ) {
1611
-							switch ( $lesson_status ) {
1610
+						if ('passed' != $course_completion) {
1611
+							switch ($lesson_status) {
1612 1612
 								// A user cannot 'complete' a course if a lesson...
1613 1613
 								case 'in-progress': // ...is still in progress
1614 1614
 								case 'ungraded': // ...hasn't yet been graded
@@ -1620,7 +1620,7 @@  discard block
 block discarded – undo
1620 1620
 							}
1621 1621
 						}
1622 1622
 						else {
1623
-							switch ( $lesson_status ) {
1623
+							switch ($lesson_status) {
1624 1624
 								case 'complete': // Lesson has no quiz/questions
1625 1625
 								case 'graded': // Lesson has quiz, but it's not important what the grade was
1626 1626
 								case 'passed': // Lesson has quiz and the user passed
@@ -1635,79 +1635,79 @@  discard block
 block discarded – undo
1635 1635
 						}
1636 1636
 					} // Each lesson
1637 1637
 				} // Check for lessons
1638
-				if ( $lessons_completed == $total_lessons ) {
1638
+				if ($lessons_completed == $total_lessons) {
1639 1639
 					$status = 'complete';
1640 1640
 				}
1641 1641
 				// update the overall percentage of the course lessons complete (or graded) compared to 'in-progress' regardless of the above
1642 1642
 				$metadata = array(
1643 1643
 					'complete' => $lessons_completed,
1644
-					'percent' => abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) ),
1644
+					'percent' => abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0)),
1645 1645
 				);
1646
-				Sensei_Utils::update_course_status( $user_id, $course_id, $status, $metadata );
1646
+				Sensei_Utils::update_course_status($user_id, $course_id, $status, $metadata);
1647 1647
 				$count++;
1648 1648
 
1649 1649
 			} // per course status
1650 1650
 			$comment_id_offset = $course_status->comment_ID;
1651 1651
 		} // all course statuses
1652 1652
 
1653
-		if ( $current_page == $total_pages ) {
1653
+		if ($current_page == $total_pages) {
1654 1654
 			return true;
1655 1655
 		} else {
1656 1656
 			return false;
1657 1657
 		}
1658 1658
 	}
1659 1659
 
1660
-	function status_changes_convert_questions( $n = 50, $offset = 0 ) {
1660
+	function status_changes_convert_questions($n = 50, $offset = 0) {
1661 1661
 		global $wpdb;
1662 1662
 
1663
-		wp_defer_comment_counting( true );
1663
+		wp_defer_comment_counting(true);
1664 1664
 
1665
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1665
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1666 1666
 
1667
-		if ( 0 == $user_count_result ) {
1667
+		if (0 == $user_count_result) {
1668 1668
 			return true;
1669 1669
 		}
1670 1670
 
1671 1671
 		// Calculate if this is the last page
1672
-		if ( 0 == $offset ) {
1672
+		if (0 == $offset) {
1673 1673
 			$current_page = 1;
1674 1674
 		} else {
1675
-			$current_page = intval( $offset / $n );
1675
+			$current_page = intval($offset / $n);
1676 1676
 		}
1677 1677
 
1678
-		$total_pages = ceil( $user_count_result / $n );
1678
+		$total_pages = ceil($user_count_result / $n);
1679 1679
 
1680 1680
 		$users_sql = "SELECT ID FROM $wpdb->users ORDER BY ID ASC LIMIT %d OFFSET %d";
1681 1681
 		$answers_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_user_answer' AND user_id = %d GROUP BY comment_post_ID ";
1682 1682
 		$grades_sql = "SELECT comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_type = 'sensei_user_grade' AND user_id = %d GROUP BY comment_post_ID ";
1683 1683
 		$notes_sql = "SELECT comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_type = 'sensei_answer_notes' AND user_id = %d GROUP BY comment_post_ID ";
1684 1684
 
1685
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1685
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1686 1686
 
1687
-		foreach ( $user_ids AS $user_id ) {
1687
+		foreach ($user_ids AS $user_id) {
1688 1688
 
1689 1689
 			$answer_grades = $answer_notes = array();
1690 1690
 
1691 1691
 			// Pre-process the answer grades
1692
-			$_answer_grades = $wpdb->get_results( $wpdb->prepare($grades_sql, $user_id), ARRAY_A );
1693
-			foreach ( $_answer_grades as $answer_grade ) {
1692
+			$_answer_grades = $wpdb->get_results($wpdb->prepare($grades_sql, $user_id), ARRAY_A);
1693
+			foreach ($_answer_grades as $answer_grade) {
1694 1694
 				// This will overwrite existing entries with the newer ones
1695
-				$answer_grades[ $answer_grade['comment_post_ID'] ] = $answer_grade['comment_content'];
1695
+				$answer_grades[$answer_grade['comment_post_ID']] = $answer_grade['comment_content'];
1696 1696
 			}
1697
-			unset( $_answer_grades );
1697
+			unset($_answer_grades);
1698 1698
 
1699 1699
 			// Pre-process the answer notes
1700
-			$_answer_notes = $wpdb->get_results( $wpdb->prepare($notes_sql, $user_id), ARRAY_A );
1701
-			foreach ( $_answer_notes as $answer_note ) {
1700
+			$_answer_notes = $wpdb->get_results($wpdb->prepare($notes_sql, $user_id), ARRAY_A);
1701
+			foreach ($_answer_notes as $answer_note) {
1702 1702
 				// This will overwrite existing entries with the newer ones
1703
-				$answer_notes[ $answer_note['comment_post_ID'] ] = $answer_note['comment_content'];
1703
+				$answer_notes[$answer_note['comment_post_ID']] = $answer_note['comment_content'];
1704 1704
 			}
1705
-			unset( $_answer_notes );
1705
+			unset($_answer_notes);
1706 1706
 
1707 1707
 			// Grab all the questions for the user
1708 1708
 			$sql = $wpdb->prepare($answers_sql, $user_id);
1709
-			$answers = $wpdb->get_results( $sql, ARRAY_A );
1710
-			foreach ( $answers as $answer ) {
1709
+			$answers = $wpdb->get_results($sql, ARRAY_A);
1710
+			foreach ($answers as $answer) {
1711 1711
 
1712 1712
 				// Excape data
1713 1713
 				$answer = wp_slash($answer);
@@ -1717,12 +1717,12 @@  discard block
 block discarded – undo
1717 1717
 				$meta_data = array();
1718 1718
 
1719 1719
 				// Check if the question has been graded, add as meta
1720
-				if ( !empty($answer_grades[ $answer['comment_post_ID'] ]) ) {
1721
-					$meta_data['user_grade'] = $answer_grades[ $answer['comment_post_ID'] ];
1720
+				if ( ! empty($answer_grades[$answer['comment_post_ID']])) {
1721
+					$meta_data['user_grade'] = $answer_grades[$answer['comment_post_ID']];
1722 1722
 				}
1723 1723
 				// Check if there is an answer note, add as meta
1724
-				if ( !empty($answer_notes[ $answer['comment_post_ID'] ]) ) {
1725
-					$meta_data['answer_note'] = $answer_notes[ $answer['comment_post_ID'] ];
1724
+				if ( ! empty($answer_notes[$answer['comment_post_ID']])) {
1725
+					$meta_data['answer_note'] = $answer_notes[$answer['comment_post_ID']];
1726 1726
 				}
1727 1727
 
1728 1728
 				// Wipe the unnessary data from the main comment
@@ -1735,21 +1735,21 @@  discard block
 block discarded – undo
1735 1735
 					);
1736 1736
 				$data = array_merge($answer, $data);
1737 1737
 
1738
-				$rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
1739
-				if ( $rval ) {
1740
-					if ( !empty($meta_data) ) {
1741
-						foreach ( $meta_data as $key => $value ) {
1738
+				$rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
1739
+				if ($rval) {
1740
+					if ( ! empty($meta_data)) {
1741
+						foreach ($meta_data as $key => $value) {
1742 1742
 							// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1743
-							if ( $wpdb->get_var( $wpdb->prepare(
1743
+							if ($wpdb->get_var($wpdb->prepare(
1744 1744
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1745
-									$comment_ID, $key ) ) ) {
1745
+									$comment_ID, $key ))) {
1746 1746
 									continue; // Found the meta data already
1747 1747
 							}
1748
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1748
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1749 1749
 								'comment_id' => $comment_ID,
1750 1750
 								'meta_key' => $key,
1751 1751
 								'meta_value' => $value
1752
-							) );
1752
+							));
1753 1753
 						}
1754 1754
 					}
1755 1755
 				}
@@ -1757,7 +1757,7 @@  discard block
 block discarded – undo
1757 1757
 		}
1758 1758
 		$wpdb->flush();
1759 1759
 
1760
-		if ( $current_page == $total_pages ) {
1760
+		if ($current_page == $total_pages) {
1761 1761
 			return true;
1762 1762
 		} else {
1763 1763
 			return false;
@@ -1774,10 +1774,10 @@  discard block
 block discarded – undo
1774 1774
 		global $wpdb;
1775 1775
 
1776 1776
 		// Update 'sensei_user_answer' entries to use comment_approved = 'log' so they don't appear in counts
1777
-		$wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' " );
1777
+		$wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' ");
1778 1778
 
1779 1779
 		// Mark all old Sensei comment types with comment_approved = 'legacy' so they no longer appear in counts, but can be restored if required
1780
-		$wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'legacy' WHERE comment_type IN ('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_answer_notes', 'sensei_quiz_grade') " );
1780
+		$wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'legacy' WHERE comment_type IN ('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_answer_notes', 'sensei_quiz_grade') ");
1781 1781
 
1782 1782
 		return true;
1783 1783
 	}
@@ -1790,50 +1790,50 @@  discard block
 block discarded – undo
1790 1790
 	 * @param type $offset
1791 1791
 	 * @return boolean
1792 1792
 	 */
1793
-	public function update_comment_course_lesson_comment_counts( $n = 50, $offset = 0 ) {
1793
+	public function update_comment_course_lesson_comment_counts($n = 50, $offset = 0) {
1794 1794
 		global $wpdb;
1795 1795
 
1796
-		$item_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') " );
1796
+		$item_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') ");
1797 1797
 
1798
-		if ( 0 == $item_count_result ) {
1798
+		if (0 == $item_count_result) {
1799 1799
 			return true;
1800 1800
 		}
1801 1801
 
1802 1802
 		// Calculate if this is the last page
1803
-		if ( 0 == $offset ) {
1803
+		if (0 == $offset) {
1804 1804
 			$current_page = 1;
1805 1805
 		} else {
1806
-			$current_page = intval( $offset / $n );
1806
+			$current_page = intval($offset / $n);
1807 1807
 		}
1808 1808
 
1809
-		$total_pages = ceil( $item_count_result / $n );
1809
+		$total_pages = ceil($item_count_result / $n);
1810 1810
 
1811 1811
 		// Recalculate all counts
1812
-		$items = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset ) );
1813
-		foreach ( (array) $items as $post ) {
1812
+		$items = $wpdb->get_results($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset));
1813
+		foreach ((array) $items as $post) {
1814 1814
 			// Code copied from wp_update_comment_count_now()
1815
-			$new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID) );
1816
-			$wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID) );
1815
+			$new = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID));
1816
+			$wpdb->update($wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID));
1817 1817
 
1818
-			clean_post_cache( $post->ID );
1818
+			clean_post_cache($post->ID);
1819 1819
 		}
1820 1820
 
1821
-		if ( $current_page == $total_pages ) {
1821
+		if ($current_page == $total_pages) {
1822 1822
 			return true;
1823 1823
 		} else {
1824 1824
 			return false;
1825 1825
 		}
1826 1826
 	}
1827 1827
 
1828
-	public function remove_legacy_comments () {
1828
+	public function remove_legacy_comments() {
1829 1829
 		global $wpdb;
1830 1830
 
1831
-		$result = $wpdb->delete( $wpdb->comments, array( 'comment_approved' => 'legacy' ) );
1831
+		$result = $wpdb->delete($wpdb->comments, array('comment_approved' => 'legacy'));
1832 1832
 
1833 1833
 		return true;
1834 1834
 	}
1835 1835
 
1836
-	public function index_comment_status_field () {
1836
+	public function index_comment_status_field() {
1837 1837
 		global $wpdb;
1838 1838
 
1839 1839
 		$wpdb->query("ALTER TABLE `$wpdb->comments` ADD INDEX `comment_type` ( `comment_type` )");
@@ -1852,7 +1852,7 @@  discard block
 block discarded – undo
1852 1852
      * @since 1.8.0
1853 1853
      * @return bool;
1854 1854
      */
1855
-    public  function enhance_teacher_role ( ) {
1855
+    public  function enhance_teacher_role( ) {
1856 1856
 
1857 1857
         require_once('class-sensei-teacher.php');
1858 1858
         $teacher = new Sensei_Teacher();
Please login to merge, or discard this patch.
includes/class-sensei-lesson.php 3 patches
Braces   +28 added lines, -16 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 Lessons Class
@@ -378,8 +381,7 @@  discard block
 block discarded – undo
378 381
 		$quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
379 382
 		if( 0 < count( $quiz_questions ) ) {
380 383
 			update_post_meta( $post_id, '_quiz_has_questions', '1' );
381
-		}
382
-		else {
384
+		} else {
383 385
 			delete_post_meta( $post_id, '_quiz_has_questions' );
384 386
 		}
385 387
 
@@ -390,7 +392,9 @@  discard block
 block discarded – undo
390 392
 
391 393
 	public function get_submitted_setting_value( $field = false ) {
392 394
 
393
-		if( ! $field ) return;
395
+		if( ! $field ) {
396
+			return;
397
+		}
394 398
 
395 399
 		$value = false;
396 400
 
@@ -1507,7 +1511,7 @@  discard block
 block discarded – undo
1507 1511
 
1508 1512
             $field_name = 'answer_feedback_boolean';
1509 1513
 
1510
-        }elseif( 'multiple-choice' == $question_type ){
1514
+        } elseif( 'multiple-choice' == $question_type ){
1511 1515
 
1512 1516
             $field_name = 'answer_feedback_multiple_choice';
1513 1517
 
@@ -1603,7 +1607,9 @@  discard block
 block discarded – undo
1603 1607
 
1604 1608
 		$html = '';
1605 1609
 
1606
-		if( ! $lesson_id && ! $quiz_id ) return $html;
1610
+		if( ! $lesson_id && ! $quiz_id ) {
1611
+			return $html;
1612
+		}
1607 1613
 
1608 1614
 		$settings = $this->get_quiz_settings( $quiz_id );
1609 1615
 
@@ -2258,11 +2264,11 @@  discard block
 block discarded – undo
2258 2264
 
2259 2265
             $answer_feedback = $data[ 'answer_feedback_boolean' ];
2260 2266
 
2261
-		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2267
+		} elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2262 2268
 
2263 2269
             $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2264 2270
 
2265
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2271
+        } elseif( isset( $data[ 'answer_feedback' ] )  ){
2266 2272
 
2267 2273
             $answer_feedback = $data[ 'answer_feedback' ];
2268 2274
 
@@ -2275,8 +2281,7 @@  discard block
 block discarded – undo
2275 2281
 		// Handle the extended question text
2276 2282
 		if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) {
2277 2283
 			$post_content = $data[ 'question_description' ];
2278
-		}
2279
-		else {
2284
+		} else {
2280 2285
 			$post_content = '';
2281 2286
 		}
2282 2287
 		// Question Query Arguments
@@ -2484,8 +2489,7 @@  discard block
 block discarded – undo
2484 2489
 				'key' => '_lesson_course',
2485 2490
 				'value' => $course_id,
2486 2491
 			);
2487
-		}
2488
-		else {
2492
+		} else {
2489 2493
 			// Simple check for connection to a Course
2490 2494
 			$post_args['meta_query'][] = array(
2491 2495
 				'key' => '_lesson_course',
@@ -2613,9 +2617,13 @@  discard block
 block discarded – undo
2613 2617
 				// Fetch each question in the order in which they were asked
2614 2618
 				$questions = array();
2615 2619
 				foreach( $selected_questions as $question_id ) {
2616
-					if( ! $question_id ) continue;
2620
+					if( ! $question_id ) {
2621
+						continue;
2622
+					}
2617 2623
 					$question = get_post( $question_id );
2618
-					if( ! isset( $question ) || ! isset( $question->ID ) ) continue;
2624
+					if( ! isset( $question ) || ! isset( $question->ID ) ) {
2625
+						continue;
2626
+					}
2619 2627
 					$questions[] = $question;
2620 2628
 				}
2621 2629
 
@@ -2628,7 +2636,9 @@  discard block
 block discarded – undo
2628 2636
 
2629 2637
 				// Set array of questions that already exist so we can prevent duplicates from appearing
2630 2638
 				foreach( $questions_array as $question ) {
2631
-					if( 'question' != $question->post_type ) continue;
2639
+					if( 'question' != $question->post_type ) {
2640
+						continue;
2641
+					}
2632 2642
 					$existing_questions[] = $question->ID;
2633 2643
 				}
2634 2644
 
@@ -2668,7 +2678,9 @@  discard block
 block discarded – undo
2668 2678
 
2669 2679
 						// Add selected questions to existing questions array to prevent duplicates from being added
2670 2680
 						foreach( $questions_array as $cat_question ) {
2671
-							if( in_array( $cat_question->ID, $existing_questions ) ) continue;
2681
+							if( in_array( $cat_question->ID, $existing_questions ) ) {
2682
+								continue;
2683
+							}
2672 2684
 							$existing_questions[] = $cat_question->ID;
2673 2685
 						}
2674 2686
 					}
Please login to merge, or discard this patch.
Indentation   +1071 added lines, -1071 removed lines patch added patch discarded remove patch
@@ -21,12 +21,12 @@  discard block
 block discarded – undo
21 21
 	 */
22 22
 	public function __construct () {
23 23
 
24
-        $this->token = 'lesson';
24
+		$this->token = 'lesson';
25 25
 
26 26
 		// Setup meta fields for this post type
27 27
 		$this->meta_fields = array( 'lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed' );
28 28
 
29
-        $this->question_order = '';
29
+		$this->question_order = '';
30 30
 
31 31
 		// Admin actions
32 32
 		if ( is_admin() ) {
@@ -84,18 +84,18 @@  discard block
 block discarded – undo
84 84
 			add_action( 'wp_ajax_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
85 85
 			add_action( 'wp_ajax_nopriv_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
86 86
 
87
-            // output bulk edit fields
88
-            add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
89
-            add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
87
+			// output bulk edit fields
88
+			add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
89
+			add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
90 90
 
91
-            // load quick edit default values
92
-            add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2);
91
+			// load quick edit default values
92
+			add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2);
93 93
 
94
-            // save bulk edit fields
95
-            add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) );
94
+			// save bulk edit fields
95
+			add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) );
96 96
 
97
-            // flush rewrite rules when saving a lesson
98
-            add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) );
97
+			// flush rewrite rules when saving a lesson
98
+			add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) );
99 99
 
100 100
 		} else {
101 101
 			// Frontend actions
@@ -189,8 +189,8 @@  discard block
 block discarded – undo
189 189
 		$post_args = array(	'post_type' 		=> 'lesson',
190 190
 							'posts_per_page' 		=> -1,
191 191
 							'orderby'         	=> 'title',
192
-    						'order'           	=> 'ASC',
193
-    						'exclude' 			=> $post->ID,
192
+							'order'           	=> 'ASC',
193
+							'exclude' 			=> $post->ID,
194 194
 							'suppress_filters' 	=> 0
195 195
 							);
196 196
 		$posts_array = get_posts( $post_args );
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 
227 227
 		$checked = '';
228 228
 		if ( isset( $lesson_preview ) && ( '' != $lesson_preview ) ) {
229
-	 	    $checked = checked( 'preview', $lesson_preview, false );
229
+	 		$checked = checked( 'preview', $lesson_preview, false );
230 230
 	 	} // End If Statement
231 231
 
232 232
 	 	$html .= '<label for="lesson_preview">';
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 
277 277
 	/**
278
-     * Update the lesson quiz and all the post meta
278
+	 * Update the lesson quiz and all the post meta
279 279
 	 *
280 280
 	 * @access public
281 281
 	 * @return integer|boolean $post_id or false
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 		}
297 297
 
298 298
 		// Temporarily disable the filter
299
-        remove_action( 'save_post', array( $this, 'quiz_update' ) );
299
+		remove_action( 'save_post', array( $this, 'quiz_update' ) );
300 300
 		// Save the Quiz
301 301
 		$quiz_id = $this->lesson_quizzes( $post_id, 'any');
302 302
 
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
 
312 312
 		// Setup Query Arguments
313 313
 		$post_type_args = array(	'post_content' => $post_content,
314
-  		    						'post_status' => $post_status,
315
-  		    						'post_title' => $post_title,
316
-  		    						'post_type' => 'quiz',
317
-                                    'post_parent' => $post_id,
318
-  		    						);
314
+  									'post_status' => $post_status,
315
+  									'post_title' => $post_title,
316
+  									'post_type' => 'quiz',
317
+									'post_parent' => $post_id,
318
+  									);
319 319
 
320 320
 		$settings = $this->get_quiz_settings();
321 321
 
@@ -323,48 +323,48 @@  discard block
 block discarded – undo
323 323
 		if ( 0 < $quiz_id ) {
324 324
 			// Update the Quiz
325 325
 			$post_type_args[ 'ID' ] = $quiz_id;
326
-		    wp_update_post($post_type_args);
327
-
328
-		    // Update the post meta data
329
-		    update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
330
-
331
-		    foreach( $settings as $field ) {
332
-		    	if( 'random_question_order' != $field['id'] ) {
333
-			    	$value = $this->get_submitted_setting_value( $field );
334
-			    	if( isset( $value ) ) {
335
-			    		update_post_meta( $quiz_id, '_' . $field['id'], $value );
336
-			    	}
337
-			    }
338
-		    }
339
-
340
-		    // Set the post terms for quiz-type
341
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
326
+			wp_update_post($post_type_args);
327
+
328
+			// Update the post meta data
329
+			update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
330
+
331
+			foreach( $settings as $field ) {
332
+				if( 'random_question_order' != $field['id'] ) {
333
+					$value = $this->get_submitted_setting_value( $field );
334
+					if( isset( $value ) ) {
335
+						update_post_meta( $quiz_id, '_' . $field['id'], $value );
336
+					}
337
+				}
338
+			}
339
+
340
+			// Set the post terms for quiz-type
341
+			wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
342 342
 		} else {
343 343
 			// Create the Quiz
344
-		    $quiz_id = wp_insert_post($post_type_args);
345
-
346
-		    // Add the post meta data WP will add it if it doesn't exist
347
-            update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
348
-
349
-		    foreach( $settings as $field ) {
350
-		    	if( 'random_question_order' != $field['id'] ) {
351
-
352
-                    //ignore values not posted to avoid
353
-                    // overwriting with empty or default values
354
-                    // when the values are posted from bulk edit or quick edit
355
-                    if( !isset( $_POST[ $field['id'] ] ) ){
356
-                        continue;
357
-                    }
358
-
359
-			    	$value = $this->get_submitted_setting_value( $field );
360
-			    	if( isset( $value ) ) {
361
-			    		add_post_meta( $quiz_id, '_' . $field['id'], $value );
362
-			    	}
363
-			    }
364
-		    }
365
-
366
-		    // Set the post terms for quiz-type
367
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
344
+			$quiz_id = wp_insert_post($post_type_args);
345
+
346
+			// Add the post meta data WP will add it if it doesn't exist
347
+			update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
348
+
349
+			foreach( $settings as $field ) {
350
+				if( 'random_question_order' != $field['id'] ) {
351
+
352
+					//ignore values not posted to avoid
353
+					// overwriting with empty or default values
354
+					// when the values are posted from bulk edit or quick edit
355
+					if( !isset( $_POST[ $field['id'] ] ) ){
356
+						continue;
357
+					}
358
+
359
+					$value = $this->get_submitted_setting_value( $field );
360
+					if( isset( $value ) ) {
361
+						add_post_meta( $quiz_id, '_' . $field['id'], $value );
362
+					}
363
+				}
364
+			}
365
+
366
+			// Set the post terms for quiz-type
367
+			wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
368 368
 		} // End If Statement
369 369
 
370 370
 		// Add default lesson order meta value
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 		}
387 387
 
388 388
 		// Restore the previously disabled filter
389
-        add_action( 'save_post', array( $this, 'quiz_update' ) );
389
+		add_action( 'save_post', array( $this, 'quiz_update' ) );
390 390
 
391 391
 	} // End post_updated()
392 392
 
@@ -426,22 +426,22 @@  discard block
 block discarded – undo
426 426
 		// Get the meta key.
427 427
 		$meta_key = '_' . $post_key;
428 428
 
429
-        //ignore fields are not posted
429
+		//ignore fields are not posted
430 430
 
431
-        if( !isset( $_POST[ $post_key ] ) ){
431
+		if( !isset( $_POST[ $post_key ] ) ){
432 432
 
433
-            // except for lesson preview checkbox field
434
-            if( 'lesson_preview' == $post_key ){
433
+			// except for lesson preview checkbox field
434
+			if( 'lesson_preview' == $post_key ){
435 435
 
436
-                $_POST[ $post_key ] = '';
436
+				$_POST[ $post_key ] = '';
437 437
 
438
-            } else {
438
+			} else {
439 439
 
440
-                return false;
440
+				return false;
441 441
 
442
-            }
442
+			}
443 443
 
444
-        }
444
+		}
445 445
 
446 446
 		// Get the posted data and sanitize it for use as an HTML class.
447 447
 		if ( 'lesson_video_embed' == $post_key) {
@@ -450,10 +450,10 @@  discard block
 block discarded – undo
450 450
 			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
451 451
 		} // End If Statement
452 452
 
453
-        // update field with the new value
454
-        if( -1 != $new_meta_value  ){
455
-            return update_post_meta( $post_id, $meta_key, $new_meta_value );
456
-        }
453
+		// update field with the new value
454
+		if( -1 != $new_meta_value  ){
455
+			return update_post_meta( $post_id, $meta_key, $new_meta_value );
456
+		}
457 457
 
458 458
 	} // End save_post_meta()
459 459
 
@@ -478,9 +478,9 @@  discard block
 block discarded – undo
478 478
 		$post_args = array(	'post_type' 		=> 'course',
479 479
 							'posts_per_page' 		=> -1,
480 480
 							'orderby'         	=> 'title',
481
-    						'order'           	=> 'ASC',
482
-    						'post_status'      	=> 'any',
483
-    						'suppress_filters' 	=> 0,
481
+							'order'           	=> 'ASC',
482
+							'post_status'      	=> 'any',
483
+							'suppress_filters' 	=> 0,
484 484
 							);
485 485
 		$posts_array = get_posts( $post_args );
486 486
 		// Buid the HTML to Output
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
 		// Nonce
489 489
 		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
490 490
 
491
-        // Select the course for the lesson
492
-        $drop_down_args = array(
493
-            'name'=>'lesson_course',
494
-            'id' => 'lesson-course-options'
495
-        );
491
+		// Select the course for the lesson
492
+		$drop_down_args = array(
493
+			'name'=>'lesson_course',
494
+			'id' => 'lesson-course-options'
495
+		);
496 496
 
497
-        $courses = WooThemes_Sensei_Course::get_all_courses();
498
-        $courses_options = array();
499
-        foreach( $courses as $course ){
500
-            $courses_options[ $course->ID ] = get_the_title( $course ) ;
501
-        }
502
-        $html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args );
497
+		$courses = WooThemes_Sensei_Course::get_all_courses();
498
+		$courses_options = array();
499
+		foreach( $courses as $course ){
500
+			$courses_options[ $course->ID ] = get_the_title( $course ) ;
501
+		}
502
+		$html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args );
503 503
 
504
-        // Course Actions Panel
504
+		// Course Actions Panel
505 505
 		if ( current_user_can( 'publish_courses' )) {
506 506
 				$html .= '<div id="lesson-course-actions">';
507 507
 					$html .= '<p>';
@@ -527,16 +527,16 @@  discard block
 block discarded – undo
527 527
 							} // End For Loop
528 528
 						$html .= '</select>' . "\n";
529 529
 						// Course Product
530
-                        if ( Sensei_WC::is_woocommerce_active() ) {
530
+						if ( Sensei_WC::is_woocommerce_active() ) {
531 531
 	  						// Get the Products
532 532
 							$select_course_woocommerce_product = get_post_meta( $post_item->ID, '_course_woocommerce_product', true );
533 533
 
534 534
 							$product_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
535 535
 													'posts_per_page' 		=> -1,
536 536
 													'orderby'         	=> 'title',
537
-	    											'order'           	=> 'DESC',
538
-	    											'post_status'		=> array( 'publish', 'private', 'draft' ),
539
-	    											'tax_query'			=> array(
537
+													'order'           	=> 'DESC',
538
+													'post_status'		=> array( 'publish', 'private', 'draft' ),
539
+													'tax_query'			=> array(
540 540
 														array(
541 541
 															'taxonomy'	=> 'product_type',
542 542
 															'field'		=> 'slug',
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
 															'operator'	=> 'NOT IN'
545 545
 														)
546 546
 													),
547
-	    											'suppress_filters' 	=> 0
547
+													'suppress_filters' 	=> 0
548 548
 													);
549 549
 							$products_array = get_posts( $product_args );
550 550
 							$html .= '<label>' . __( 'WooCommerce Product' , 'woothemes-sensei' ) . '</label> ';
@@ -872,58 +872,58 @@  discard block
 block discarded – undo
872 872
 					$html .= '<tr class="question-quick-edit ' . esc_attr( $edit_class ) . '">';
873 873
 						$html .= '<td colspan="5">';
874 874
 							$html .= '<span class="hidden question_original_counter">' . $question_counter . '</span>';
875
-					    	$html .= '<div class="question_required_fields">';
876
-
877
-						    	// Question title
878
-						    	$html .= '<div>';
879
-							    	$html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> ';
880
-							    	$html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />';
881
-						    	$html .= '</div>';
882
-
883
-						    	// Question description
884
-						    	$html .= '<div>';
885
-							    	$html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
886
-						    	$html .= '</div>';
887
-							    	$html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>';
888
-
889
-						    	// Question grade
890
-						    	$html .= '<div>';
891
-							    	$html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> ';
892
-							    	$html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />';
893
-						    	$html .= '</div>';
894
-
895
-						    	// Random order
896
-						    	if( $question_type == 'multiple-choice' ) {
897
-						    		$html .= '<div>';
898
-						    			$html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
899
-						    		$html .= '</div>';
900
-						    	}
901
-
902
-						    	// Question media
903
-						    	$html .= '<div>';
904
-							    	$html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
905
-							    	$html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>';
906
-							    	$html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
907
-							    	$html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>';
908
-							    	$html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>';
909
-							    	$html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />';
910
-						    	$html .= '</div>';
911
-
912
-						    $html .= '</div>';
913
-
914
-						    $html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter );
915
-
916
-						    $html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />';
875
+							$html .= '<div class="question_required_fields">';
876
+
877
+								// Question title
878
+								$html .= '<div>';
879
+									$html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> ';
880
+									$html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />';
881
+								$html .= '</div>';
882
+
883
+								// Question description
884
+								$html .= '<div>';
885
+									$html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
886
+								$html .= '</div>';
887
+									$html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>';
888
+
889
+								// Question grade
890
+								$html .= '<div>';
891
+									$html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> ';
892
+									$html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />';
893
+								$html .= '</div>';
894
+
895
+								// Random order
896
+								if( $question_type == 'multiple-choice' ) {
897
+									$html .= '<div>';
898
+										$html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
899
+									$html .= '</div>';
900
+								}
901
+
902
+								// Question media
903
+								$html .= '<div>';
904
+									$html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
905
+									$html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>';
906
+									$html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
907
+									$html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>';
908
+									$html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>';
909
+									$html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />';
910
+								$html .= '</div>';
911
+
912
+							$html .= '</div>';
913
+
914
+							$html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter );
915
+
916
+							$html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />';
917 917
 							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" />';
918 918
 
919 919
 							if( 'quiz' == $context ) {
920
-					    		$html .= '<div class="update-question">';
921
-						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> ';
922
-						    		$html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>';
923
-					    		$html .= '</div>';
924
-					    	}
920
+								$html .= '<div class="update-question">';
921
+									$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> ';
922
+									$html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>';
923
+								$html .= '</div>';
924
+							}
925 925
 
926
-			    		$html .= '</td>';
926
+						$html .= '</td>';
927 927
 					$html .= '</tr>';
928 928
 				}
929 929
 
@@ -944,20 +944,20 @@  discard block
 block discarded – undo
944 944
 			$question_cats = get_terms( 'question-category', array( 'hide_empty' => false ) );
945 945
 
946 946
 			if( 'quiz' == $context ) {
947
-	    		$html .= '<h2 class="nav-tab-wrapper add-question-tabs">';
948
-	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question'  , 'woothemes-sensei' ) . '</a>';
949
-	    			$html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions'  , 'woothemes-sensei' ) . '</a>';
950
-                    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats )  && ! Sensei()->teacher->is_admin_teacher() ) {
951
-	    				$html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions'  , 'woothemes-sensei' ) . '</a>';
952
-	    			}
953
-	    		$html .= '</h2>';
954
-	    	}
947
+				$html .= '<h2 class="nav-tab-wrapper add-question-tabs">';
948
+					$html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question'  , 'woothemes-sensei' ) . '</a>';
949
+					$html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions'  , 'woothemes-sensei' ) . '</a>';
950
+					if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats )  && ! Sensei()->teacher->is_admin_teacher() ) {
951
+						$html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions'  , 'woothemes-sensei' ) . '</a>';
952
+					}
953
+				$html .= '</h2>';
954
+			}
955 955
 
956
-	    	$html .= '<div class="tab-content" id="tab-new-content">';
956
+			$html .= '<div class="tab-content" id="tab-new-content">';
957 957
 
958
-	    		if( 'quiz' == $context ) {
959
-	    			$html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
960
-	    		}
958
+				if( 'quiz' == $context ) {
959
+					$html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
960
+				}
961 961
 
962 962
 				$html .= '<div class="question">';
963 963
 					$html .= '<div class="question_required_fields">';
@@ -999,18 +999,18 @@  discard block
 block discarded – undo
999 999
 
1000 1000
 						// Random order
1001 1001
 						$html .= '<p class="add_question_random_order">';
1002
-			    			$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
1003
-			    		$html .= '</p>';
1002
+							$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
1003
+						$html .= '</p>';
1004 1004
 
1005
-			    		// Question media
1005
+						// Question media
1006 1006
 						$html .= '<p>';
1007
-					    	$html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
1008
-					    	$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>';
1009
-					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
1010
-					    	$html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>';
1011
-					    	$html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>';
1012
-					    	$html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />';
1013
-				    	$html .= '</p>';
1007
+							$html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
1008
+							$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>';
1009
+							$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
1010
+							$html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>';
1011
+							$html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>';
1012
+							$html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />';
1013
+						$html .= '</p>';
1014 1014
 
1015 1015
 					$html .= '</div>';
1016 1016
 				$html .= '</div>';
@@ -1021,19 +1021,19 @@  discard block
 block discarded – undo
1021 1021
 
1022 1022
 				if( 'quiz' == $context ) {
1023 1023
 					$html .= '<div class="add-question">';
1024
-			    		$html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>';
1025
-		    		$html .= '</div>';
1026
-		    	}
1024
+						$html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>';
1025
+					$html .= '</div>';
1026
+				}
1027 1027
 
1028
-		    $html .= '</div>';
1028
+			$html .= '</div>';
1029 1029
 
1030
-		    if( 'quiz' == $context ) {
1030
+			if( 'quiz' == $context ) {
1031 1031
 
1032
-			    $html .= '<div class="tab-content hidden" id="tab-existing-content">';
1032
+				$html .= '<div class="tab-content hidden" id="tab-existing-content">';
1033 1033
 
1034
-			    	$html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
1034
+					$html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
1035 1035
 
1036
-			    	$html .= '<div id="existing-filters" class="alignleft actions">
1036
+					$html .= '<div id="existing-filters" class="alignleft actions">
1037 1037
 			    				<select id="existing-status">
1038 1038
 			    					<option value="all">' . __( 'All', 'woothemes-sensei' ) . '</option>
1039 1039
 			    					<option value="unused">' . __( 'Unused', 'woothemes-sensei' ) . '</option>
@@ -1041,23 +1041,23 @@  discard block
 block discarded – undo
1041 1041
 			    				</select>
1042 1042
 			    				<select id="existing-type">
1043 1043
 			    					<option value="">' . __( 'All Types', 'woothemes-sensei' ) . '</option>';
1044
-							    	foreach ( $question_types as $type => $label ) {
1044
+									foreach ( $question_types as $type => $label ) {
1045 1045
 										$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>';
1046 1046
 									}
1047
-    				$html .= '</select>
1047
+					$html .= '</select>
1048 1048
     							<select id="existing-category">
1049 1049
 			    					<option value="">' . __( 'All Categories', 'woothemes-sensei' ) . '</option>';
1050
-				    				foreach( $question_cats as $cat ) {
1050
+									foreach( $question_cats as $cat ) {
1051 1051
 										$html .= '<option value="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat->name ) . '</option>';
1052 1052
 									}
1053
-    				$html .= '</select>
1053
+					$html .= '</select>
1054 1054
     							<input type="text" id="existing-search" placeholder="' . __( 'Search', 'woothemes-sensei' ) . '" />
1055 1055
     							<a class="button" id="existing-filter-button">' . __( 'Filter', 'woothemes-sensei' ) . '</a>
1056 1056
 			    			</div>';
1057 1057
 
1058
-			    	$html .= '<table id="existing-table" class="widefat">';
1058
+					$html .= '<table id="existing-table" class="widefat">';
1059 1059
 
1060
-			    		$html .= '<thead>
1060
+						$html .= '<thead>
1061 1061
 									    <tr>
1062 1062
 									        <th scope="col" class="column-cb check-column"><input type="checkbox" /></th>
1063 1063
 									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
@@ -1085,28 +1085,28 @@  discard block
 block discarded – undo
1085 1085
 
1086 1086
 						$html .= '</tbody>';
1087 1087
 
1088
-			    	$html .= '</table>';
1088
+					$html .= '</table>';
1089 1089
 
1090
-			    	$next_class = '';
1091
-			    	if( $questions['count'] <= 10 ) {
1092
-			    		$next_class = 'hidden';
1093
-			    	}
1090
+					$next_class = '';
1091
+					if( $questions['count'] <= 10 ) {
1092
+						$next_class = 'hidden';
1093
+					}
1094 1094
 
1095
-			    	$html .= '<div id="existing-pagination">';
1096
-			    		$html .= '<input type="hidden" id="existing-page" value="1" />';
1097
-			    		$html .= '<a class="prev no-paging">&larr; ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' &rarr;</a>';
1098
-			    	$html .= '</div>';
1095
+					$html .= '<div id="existing-pagination">';
1096
+						$html .= '<input type="hidden" id="existing-page" value="1" />';
1097
+						$html .= '<a class="prev no-paging">&larr; ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' &rarr;</a>';
1098
+					$html .= '</div>';
1099 1099
 
1100
-			    	$html .= '<div class="existing-actions">';
1101
-			    		$html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1102
-			    	$html .= '</div>';
1100
+					$html .= '<div class="existing-actions">';
1101
+						$html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1102
+					$html .= '</div>';
1103 1103
 
1104
-			    $html .= '</div>';
1104
+				$html .= '</div>';
1105 1105
 
1106
-			    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
1107
-				    $html .= '<div class="tab-content hidden" id="tab-multiple-content">';
1106
+				if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
1107
+					$html .= '<div class="tab-content hidden" id="tab-multiple-content">';
1108 1108
 
1109
-				    	$html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>';
1109
+						$html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>';
1110 1110
 
1111 1111
 						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">' . "\n";
1112 1112
 						$html .= '<option value="">' . __( 'Select a Question Category', 'woothemes-sensei' ) . '</option>' . "\n";
@@ -1119,7 +1119,7 @@  discard block
 block discarded – undo
1119 1119
 
1120 1120
 						$html .= '<a title="' . esc_attr( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '" class="add_multiple_save button button-primary button-highlighted">' . esc_html( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1121 1121
 
1122
-				    $html .= '</div>';
1122
+					$html .= '</div>';
1123 1123
 				}
1124 1124
 			}
1125 1125
 
@@ -1192,14 +1192,14 @@  discard block
 block discarded – undo
1192 1192
 
1193 1193
 		$qry = new WP_Query( $args );
1194 1194
 
1195
-        /**
1196
-         * Filter existing questions query
1197
-         *
1198
-         * @since 1.8.0
1199
-         *
1200
-         * @param WP_Query $wp_query
1201
-         */
1202
-        $qry = apply_filters( 'sensei_existing_questions_query_results', $qry );
1195
+		/**
1196
+		 * Filter existing questions query
1197
+		 *
1198
+		 * @since 1.8.0
1199
+		 *
1200
+		 * @param WP_Query $wp_query
1201
+		 */
1202
+		$qry = apply_filters( 'sensei_existing_questions_query_results', $qry );
1203 1203
 
1204 1204
 		$questions['questions'] = $qry->posts;
1205 1205
 		$questions['count'] = intval( $qry->found_posts );
@@ -1214,14 +1214,14 @@  discard block
 block discarded – undo
1214 1214
 
1215 1215
 		if( ! $question_id ) {
1216 1216
 
1217
-            return;
1217
+			return;
1218 1218
 
1219
-        }
1219
+		}
1220 1220
 
1221 1221
 		$existing_class = '';
1222 1222
 		if( $row % 2 ) {
1223
-            $existing_class = 'alternate';
1224
-        }
1223
+			$existing_class = 'alternate';
1224
+		}
1225 1225
 
1226 1226
 		$question_type = Sensei()->question->get_question_type( $question_id );
1227 1227
 
@@ -1355,67 +1355,67 @@  discard block
 block discarded – undo
1355 1355
 							}
1356 1356
 						}
1357 1357
 
1358
-				    	// Calculate total wrong answers available (defaults to 4)
1359
-				    	$total_wrong = 0;
1360
-				    	if( $question_id ) {
1361
-				    		$total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true );
1362
-				    	}
1363
-				    	if( 0 == intval( $total_wrong ) ) {
1364
-				    		$total_wrong = 1;
1365
-				    	}
1358
+						// Calculate total wrong answers available (defaults to 4)
1359
+						$total_wrong = 0;
1360
+						if( $question_id ) {
1361
+							$total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true );
1362
+						}
1363
+						if( 0 == intval( $total_wrong ) ) {
1364
+							$total_wrong = 1;
1365
+						}
1366 1366
 
1367
-                        // Setup Wrong Answer HTML
1368
-                        foreach ( $wrong_answers as $i => $answer ){
1367
+						// Setup Wrong Answer HTML
1368
+						foreach ( $wrong_answers as $i => $answer ){
1369 1369
 
1370
-                            $answer_id = $this->get_answer_id( $answer );
1371
-                            $wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
1372
-                            $wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
1373
-                            $wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1374
-                            if( $question_id ) {
1370
+							$answer_id = $this->get_answer_id( $answer );
1371
+							$wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
1372
+							$wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
1373
+							$wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1374
+							if( $question_id ) {
1375 1375
 
1376
-                                $answers[ $answer_id ] = $wrong_answer;
1376
+								$answers[ $answer_id ] = $wrong_answer;
1377 1377
 
1378
-                            } else {
1378
+							} else {
1379 1379
 
1380
-                                $answers[] = $wrong_answer;
1380
+								$answers[] = $wrong_answer;
1381 1381
 
1382
-                            }
1382
+							}
1383 1383
 
1384
-                        } // end for each
1384
+						} // end for each
1385 1385
 
1386
-				    	$answers_sorted = $answers;
1387
-				    	if( $question_id && count( $answer_order ) > 0 ) {
1388
-				    		$answers_sorted = array();
1389
-				    		foreach( $answer_order as $answer_id ) {
1390
-				    			if( isset( $answers[ $answer_id ] ) ) {
1391
-				    				$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1392
-				    				unset( $answers[ $answer_id ] );
1393
-				    			}
1394
-				    		}
1386
+						$answers_sorted = $answers;
1387
+						if( $question_id && count( $answer_order ) > 0 ) {
1388
+							$answers_sorted = array();
1389
+							foreach( $answer_order as $answer_id ) {
1390
+								if( isset( $answers[ $answer_id ] ) ) {
1391
+									$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1392
+									unset( $answers[ $answer_id ] );
1393
+								}
1394
+							}
1395 1395
 
1396
-				    		if( count( $answers ) > 0 ) {
1397
-						    	foreach( $answers as $id => $answer ) {
1398
-						    		$answers_sorted[ $id ] = $answer;
1399
-						    	}
1400
-						    }
1401
-				    	}
1396
+							if( count( $answers ) > 0 ) {
1397
+								foreach( $answers as $id => $answer ) {
1398
+									$answers_sorted[ $id ] = $answer;
1399
+								}
1400
+							}
1401
+						}
1402 1402
 
1403 1403
 						foreach( $answers_sorted as $id => $answer ) {
1404
-				    		$html .= $answer;
1405
-				    	}
1404
+							$html .= $answer;
1405
+						}
1406 1406
 
1407
-				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />';
1408
-				    	$html .= '<span class="hidden right_answer_count">' . $total_right . '</span>';
1409
-				    	$html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>';
1407
+						$html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />';
1408
+						$html .= '<span class="hidden right_answer_count">' . $total_right . '</span>';
1409
+						$html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>';
1410 1410
 
1411
-				    	$html .= '<div class="add_answer_options">';
1412
-					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>';
1413
-					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>';
1414
-				    	$html .= '</div>';
1411
+						$html .= '<div class="add_answer_options">';
1412
+							$html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>';
1413
+							$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>';
1414
+						$html .= '</div>';
1415 1415
 
1416
-                        $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' );
1416
+						$html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' );
1417 1417
 
1418
-			    	$html .= '</div>';
1418
+					$html .= '</div>';
1419 1419
 				break;
1420 1420
 				case 'boolean':
1421 1421
 					$html .= '<div class="question_boolean_fields ' . $question_class . '">';
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
 						$html .= '<label for="question_' . $question_id . '_boolean_true"><input id="question_' . $question_id . '_boolean_true" type="radio" name="' . $field_name . '" value="true" '. checked( $right_answer, 'true', false ) . ' /> ' . __( 'True', 'woothemes-sensei' ) . '</label>';
1429 1429
 						$html .= '<label for="question_' . $question_id . '_boolean_false"><input id="question_' . $question_id . '_boolean_false" type="radio" name="' . $field_name . '" value="false" '. checked( $right_answer, 'false', false ) . ' /> ' . __( 'False', 'woothemes-sensei' ) . '</label>';
1430 1430
 
1431
-                    $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' );
1431
+					$html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' );
1432 1432
 
1433 1433
 					$html .= '</div>';
1434 1434
 				break;
@@ -1503,17 +1503,17 @@  discard block
 block discarded – undo
1503 1503
 
1504 1504
 	public function quiz_panel_question_feedback( $question_counter = 0, $question_id = 0, $question_type = '' ) {
1505 1505
 
1506
-        // default field name
1507
-        $field_name = 'answer_feedback';
1508
-        if( 'boolean' == $question_type ){
1506
+		// default field name
1507
+		$field_name = 'answer_feedback';
1508
+		if( 'boolean' == $question_type ){
1509 1509
 
1510
-            $field_name = 'answer_feedback_boolean';
1510
+			$field_name = 'answer_feedback_boolean';
1511 1511
 
1512
-        }elseif( 'multiple-choice' == $question_type ){
1512
+		}elseif( 'multiple-choice' == $question_type ){
1513 1513
 
1514
-            $field_name = 'answer_feedback_multiple_choice';
1514
+			$field_name = 'answer_feedback_multiple_choice';
1515 1515
 
1516
-        }// end if
1516
+		}// end if
1517 1517
 
1518 1518
 		if( $question_counter ) {
1519 1519
 			$field_name = 'answer_' . $question_counter . '_feedback';
@@ -1718,15 +1718,15 @@  discard block
 block discarded – undo
1718 1718
 			$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
1719 1719
 
1720 1720
 			// Load the lessons script
1721
-            wp_enqueue_media();
1721
+			wp_enqueue_media();
1722 1722
 			wp_enqueue_script( 'sensei-lesson-metadata', Sensei()->plugin_url . 'assets/js/lesson-metadata' . $suffix . '.js', array( 'jquery', 'sensei-core-select2' ,'jquery-ui-sortable' ), Sensei()->version, true );
1723 1723
 			wp_enqueue_script( 'sensei-lesson-chosen', Sensei()->plugin_url . 'assets/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1724 1724
 			wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'sensei-lesson-chosen' ), Sensei()->version, true );
1725 1725
 
1726
-            // Load the bulk edit screen script
1727
-            if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) {
1728
-                wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true);
1729
-            }
1726
+			// Load the bulk edit screen script
1727
+			if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) {
1728
+				wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true);
1729
+			}
1730 1730
 
1731 1731
 			// Localise script
1732 1732
 			$translation_strings = array( 'right_colon' => __( 'Right:', 'woothemes-sensei' ), 'wrong_colon' => __( 'Wrong:', 'woothemes-sensei' ), 'add_file' => __( 'Add file', 'woothemes-sensei' ), 'change_file' => __( 'Change file', 'woothemes-sensei' ), 'confirm_remove' => __( 'Are you sure you want to remove this question?', 'woothemes-sensei' ), 'confirm_remove_multiple' => __( 'Are you sure you want to remove these questions?', 'woothemes-sensei' ), 'too_many_for_cat' => __( 'You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei' ) );
@@ -1827,7 +1827,7 @@  discard block
 block discarded – undo
1827 1827
 			$nonce = esc_html( $_POST['lesson_add_course_nonce'] );
1828 1828
 		} // End If Statement
1829 1829
 		if ( ! wp_verify_nonce( $nonce, 'lesson_add_course_nonce' )
1830
-            || ! current_user_can( 'edit_lessons' ) ) {
1830
+			|| ! current_user_can( 'edit_lessons' ) ) {
1831 1831
 			die('');
1832 1832
 		} // End If Statement
1833 1833
 		// Parse POST data
@@ -1856,7 +1856,7 @@  discard block
 block discarded – undo
1856 1856
 			$nonce = esc_html( $_POST['lesson_update_question_nonce'] );
1857 1857
 		} // End If Statement
1858 1858
 		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_nonce' )
1859
-            ||  ! current_user_can( 'edit_questions' )) {
1859
+			||  ! current_user_can( 'edit_questions' )) {
1860 1860
 
1861 1861
 			die('');
1862 1862
 
@@ -1909,7 +1909,7 @@  discard block
 block discarded – undo
1909 1909
 		} // End If Statement
1910 1910
 
1911 1911
 		if( ! wp_verify_nonce( $nonce, 'lesson_add_multiple_questions_nonce' )
1912
-            || ! current_user_can( 'edit_lessons' ) ) {
1912
+			|| ! current_user_can( 'edit_lessons' ) ) {
1913 1913
 			die( $return );
1914 1914
 		} // End If Statement
1915 1915
 
@@ -1965,7 +1965,7 @@  discard block
 block discarded – undo
1965 1965
 		} // End If Statement
1966 1966
 
1967 1967
 		if( ! wp_verify_nonce( $nonce, 'lesson_remove_multiple_questions_nonce' )
1968
-        || ! current_user_can( 'edit_lessons' ) ) {
1968
+		|| ! current_user_can( 'edit_lessons' ) ) {
1969 1969
 			die('');
1970 1970
 		} // End If Statement
1971 1971
 
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
 		} // End If Statement
2013 2013
 
2014 2014
 		if( ! wp_verify_nonce( $nonce, 'lesson_add_existing_questions_nonce' )
2015
-        || ! current_user_can( 'edit_lessons' ) ) {
2015
+		|| ! current_user_can( 'edit_lessons' ) ) {
2016 2016
 			die('');
2017 2017
 		} // End If Statement
2018 2018
 
@@ -2037,12 +2037,12 @@  discard block
 block discarded – undo
2037 2037
 
2038 2038
 					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2039 2039
 					if( ! in_array( $quiz_id, $quizzes ) ) {
2040
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2040
+						add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2041 2041
 						$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2042 2042
 						update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2043
-			    	}
2043
+					}
2044 2044
 
2045
-			    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2045
+					add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2046 2046
 					$question_type = Sensei()->question->get_question_type( $question_id );
2047 2047
 
2048 2048
 					$return .= $this->quiz_panel_question( $question_type, $question_count, $question_id );
@@ -2064,7 +2064,7 @@  discard block
 block discarded – undo
2064 2064
 		} // End If Statement
2065 2065
 
2066 2066
 		if ( ! wp_verify_nonce( $nonce, 'lesson_update_grade_type_nonce' )
2067
-        || ! current_user_can( 'edit_lessons' ) ) {
2067
+		|| ! current_user_can( 'edit_lessons' ) ) {
2068 2068
 
2069 2069
 			die('');
2070 2070
 
@@ -2084,8 +2084,8 @@  discard block
 block discarded – undo
2084 2084
 			$nonce = esc_html( $_POST['lesson_update_question_order_nonce'] );
2085 2085
 		} // End If Statement
2086 2086
 
2087
-        if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_nonce' )
2088
-            ||! current_user_can( 'edit_lessons' ) ) {
2087
+		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_nonce' )
2088
+			||! current_user_can( 'edit_lessons' ) ) {
2089 2089
 			die('');
2090 2090
 		} // End If Statement
2091 2091
 
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
 			$nonce = esc_html( $_POST['lesson_update_question_order_random_nonce'] );
2112 2112
 		} // End If Statement
2113 2113
 		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_random_nonce' )
2114
-            || ! current_user_can( 'edit_lessons' ) ) {
2114
+			|| ! current_user_can( 'edit_lessons' ) ) {
2115 2115
 
2116 2116
 			die('');
2117 2117
 
@@ -2161,34 +2161,34 @@  discard block
 block discarded – undo
2161 2161
 		$post_content = $course_content;
2162 2162
 		// Course Query Arguments
2163 2163
 		$post_type_args = array(	'post_content' => $post_content,
2164
-  		    						'post_status' => $post_status,
2165
-  		    						'post_title' => $post_title,
2166
-  		    						'post_type' => $post_type
2167
-  		    						);
2164
+  									'post_status' => $post_status,
2165
+  									'post_title' => $post_title,
2166
+  									'post_type' => $post_type
2167
+  									);
2168 2168
   		// Only save if there is a valid title
2169 2169
   		if ( $post_title != '' ) {
2170
-  		    // Check for prerequisite courses & product id
2171
-  		    $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2172
-  		    $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2173
-  		    $course_category_id = absint( $data[ 'course_category' ] );
2174
-  		    if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2175
-  		    // Insert or Update the Lesson Quiz
2176
-		    if ( 0 < $course_id ) {
2177
-		    	$post_type_args[ 'ID' ] = $course_id;
2178
-		    	$course_id = wp_update_post($post_type_args);
2179
-		    	update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2180
-		    	update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2181
-		    	if ( 0 < $course_category_id ) {
2182
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2183
-		    	} // End If Statement
2184
-		    } else {
2185
-		    	$course_id = wp_insert_post($post_type_args);
2186
-		    	add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2187
-		    	add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2188
-		    	if ( 0 < $course_category_id ) {
2189
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2190
-		    	} // End If Statement
2191
-		    } // End If Statement
2170
+  			// Check for prerequisite courses & product id
2171
+  			$course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2172
+  			$course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2173
+  			$course_category_id = absint( $data[ 'course_category' ] );
2174
+  			if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2175
+  			// Insert or Update the Lesson Quiz
2176
+			if ( 0 < $course_id ) {
2177
+				$post_type_args[ 'ID' ] = $course_id;
2178
+				$course_id = wp_update_post($post_type_args);
2179
+				update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2180
+				update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2181
+				if ( 0 < $course_category_id ) {
2182
+					wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2183
+				} // End If Statement
2184
+			} else {
2185
+				$course_id = wp_insert_post($post_type_args);
2186
+				add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2187
+				add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2188
+				if ( 0 < $course_category_id ) {
2189
+					wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2190
+				} // End If Statement
2191
+			} // End If Statement
2192 2192
 		} // End If Statement
2193 2193
   		// Check that the insert or update saved by testing the post id
2194 2194
   		if ( 0 < $course_id ) {
@@ -2279,17 +2279,17 @@  discard block
 block discarded – undo
2279 2279
 		$answer_feedback = '';
2280 2280
 		if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) {
2281 2281
 
2282
-            $answer_feedback = $data[ 'answer_feedback_boolean' ];
2282
+			$answer_feedback = $data[ 'answer_feedback_boolean' ];
2283 2283
 
2284 2284
 		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2285 2285
 
2286
-            $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2286
+			$answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2287 2287
 
2288
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2288
+		}elseif( isset( $data[ 'answer_feedback' ] )  ){
2289 2289
 
2290
-            $answer_feedback = $data[ 'answer_feedback' ];
2290
+			$answer_feedback = $data[ 'answer_feedback' ];
2291 2291
 
2292
-        } // End If Statement
2292
+		} // End If Statement
2293 2293
 
2294 2294
 		$post_title = $question_text;
2295 2295
 		$post_author = $data[ 'post_author' ];
@@ -2304,10 +2304,10 @@  discard block
 block discarded – undo
2304 2304
 		}
2305 2305
 		// Question Query Arguments
2306 2306
 		$post_type_args = array(	'post_content' => $post_content,
2307
-  		    						'post_status' => $post_status,
2308
-  		    						'post_title' => $post_title,
2309
-  		    						'post_type' => $post_type
2310
-  		    						);
2307
+  									'post_status' => $post_status,
2308
+  									'post_title' => $post_title,
2309
+  									'post_type' => $post_type
2310
+  									);
2311 2311
 
2312 2312
   		// Remove empty values and reindex the array
2313 2313
   		if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) {
@@ -2343,14 +2343,14 @@  discard block
 block discarded – undo
2343 2343
   		if ( $post_title != '' ) {
2344 2344
 
2345 2345
   			// Get Quiz ID for the question
2346
-  		    $quiz_id = $data['quiz_id'];
2346
+  			$quiz_id = $data['quiz_id'];
2347 2347
 
2348
-  		    // Get question media
2348
+  			// Get question media
2349 2349
 			$question_media = $data['question_media'];
2350 2350
 
2351
-  		    // Get answer order
2352
-  		    $answer_order = '';
2353
-  		    if( isset( $data['answer_order'] ) ) {
2351
+  			// Get answer order
2352
+  			$answer_order = '';
2353
+  			if( isset( $data['answer_order'] ) ) {
2354 2354
 				$answer_order = $data['answer_order'];
2355 2355
 			}
2356 2356
 
@@ -2360,38 +2360,38 @@  discard block
 block discarded – undo
2360 2360
 				$random_order = $data['random_order'];
2361 2361
 			}
2362 2362
 
2363
-  		    // Insert or Update the question
2364
-  		    if ( 0 < $question_id ) {
2365
-
2366
-  		    	$post_type_args[ 'ID' ] = $question_id;
2367
-		    	$question_id = wp_update_post( $post_type_args );
2368
-
2369
-		    	// Update poast meta
2370
-		    	if( 'quiz' == $context ) {
2371
-		    		$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2372
-		    		if( ! in_array( $quiz_id, $quizzes ) ) {
2373
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2374
-			    	}
2375
-		    	}
2376
-
2377
-		    	update_post_meta( $question_id, '_question_grade', $question_grade );
2378
-		    	update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2379
-		    	update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2380
-		    	update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2381
-		    	update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2382
-		    	update_post_meta( $question_id, '_question_media', $question_media );
2383
-		    	update_post_meta( $question_id, '_answer_order', $answer_order );
2384
-		    	update_post_meta( $question_id, '_random_order', $random_order );
2385
-
2386
-		    	if( 'quiz' != $context ) {
2387
-		    		wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2388
-		    	}
2363
+  			// Insert or Update the question
2364
+  			if ( 0 < $question_id ) {
2365
+
2366
+  				$post_type_args[ 'ID' ] = $question_id;
2367
+				$question_id = wp_update_post( $post_type_args );
2368
+
2369
+				// Update poast meta
2370
+				if( 'quiz' == $context ) {
2371
+					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2372
+					if( ! in_array( $quiz_id, $quizzes ) ) {
2373
+						add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2374
+					}
2375
+				}
2376
+
2377
+				update_post_meta( $question_id, '_question_grade', $question_grade );
2378
+				update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2379
+				update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2380
+				update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2381
+				update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2382
+				update_post_meta( $question_id, '_question_media', $question_media );
2383
+				update_post_meta( $question_id, '_answer_order', $answer_order );
2384
+				update_post_meta( $question_id, '_random_order', $random_order );
2385
+
2386
+				if( 'quiz' != $context ) {
2387
+					wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2388
+				}
2389 2389
 				// Don't store empty value, no point
2390 2390
 				if ( !empty($answer_feedback) ) {
2391 2391
 					update_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2392 2392
 				}
2393 2393
 
2394
-		    } else {
2394
+			} else {
2395 2395
 				$question_id = wp_insert_post( $post_type_args );
2396 2396
 				$question_count = intval( $data['question_count'] );
2397 2397
 				++$question_count;
@@ -2404,29 +2404,29 @@  discard block
 block discarded – undo
2404 2404
 				}
2405 2405
 
2406 2406
 				if( isset( $question_grade ) ) {
2407
-		    		add_post_meta( $question_id, '_question_grade', $question_grade );
2408
-		    	}
2409
-		    	add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2410
-		    	add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2411
-		    	add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2412
-		    	add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2413
-		    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2414
-		    	add_post_meta( $question_id, '_question_media', $question_media );
2415
-		    	add_post_meta( $question_id, '_answer_order', $answer_order );
2416
-		    	add_post_meta( $question_id, '_random_order', $random_order );
2407
+					add_post_meta( $question_id, '_question_grade', $question_grade );
2408
+				}
2409
+				add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2410
+				add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2411
+				add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2412
+				add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2413
+				add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2414
+				add_post_meta( $question_id, '_question_media', $question_media );
2415
+				add_post_meta( $question_id, '_answer_order', $answer_order );
2416
+				add_post_meta( $question_id, '_random_order', $random_order );
2417 2417
 				// Don't store empty value, no point
2418 2418
 				if ( !empty($answer_feedback) ) {
2419 2419
 					add_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2420 2420
 				}
2421 2421
 
2422
-		    	// Set the post terms for question-type
2423
-			    wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2422
+				// Set the post terms for question-type
2423
+				wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2424 2424
 
2425
-			    if( $question_category ) {
2426
-	    			wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2427
-	    		}
2425
+				if( $question_category ) {
2426
+					wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2427
+				}
2428 2428
 
2429
-		    } // End If Statement
2429
+			} // End If Statement
2430 2430
 		} // End If Statement
2431 2431
   		// Check that the insert or update saved by testing the post id
2432 2432
   		if ( 0 < $question_id ) {
@@ -2475,7 +2475,7 @@  discard block
 block discarded – undo
2475 2475
 	public function lesson_complexities() {
2476 2476
 
2477 2477
 		// V2 - make filter for this array
2478
-        $lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2478
+		$lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2479 2479
 									'std' => __( 'Standard', 'woothemes-sensei' ),
2480 2480
 									'hard' => __( 'Hard', 'woothemes-sensei' )
2481 2481
 									);
@@ -2542,14 +2542,14 @@  discard block
 block discarded – undo
2542 2542
 		$post_args = array(	'post_type' 		=> 'quiz',
2543 2543
 							'posts_per_page' 		=> 1,
2544 2544
 							'orderby'         	=> 'title',
2545
-    						'order'           	=> 'DESC',
2546
-    						'post_parent'      	=> $lesson_id,
2547
-    						'post_status'		=> $post_status,
2545
+							'order'           	=> 'DESC',
2546
+							'post_parent'      	=> $lesson_id,
2547
+							'post_status'		=> $post_status,
2548 2548
 							'suppress_filters' 	=> 0,
2549 2549
 							'fields'            => $fields
2550 2550
 							);
2551 2551
 		$posts_array = get_posts( $post_args );
2552
-        $quiz_id = array_shift($posts_array);
2552
+		$quiz_id = array_shift($posts_array);
2553 2553
 
2554 2554
 		return $quiz_id;
2555 2555
 	} // End lesson_quizzes()
@@ -2557,34 +2557,34 @@  discard block
 block discarded – undo
2557 2557
 
2558 2558
 	/**
2559 2559
 	 * Fetches all the questions for a quiz depending on certain conditions.
2560
-     *
2561
-     * Determine which questions should be shown depending on:
2562
-     * - admin/teacher selected questions to be shown
2563
-     * - questions shown to a user previously (saved as asked questions)
2564
-     * - limit number of questions lesson setting
2565 2560
 	 *
2566
-     * @since 1.0
2561
+	 * Determine which questions should be shown depending on:
2562
+	 * - admin/teacher selected questions to be shown
2563
+	 * - questions shown to a user previously (saved as asked questions)
2564
+	 * - limit number of questions lesson setting
2565
+	 *
2566
+	 * @since 1.0
2567 2567
 	 * @param int $quiz_id (default: 0)
2568 2568
 	 * @param string $post_status (default: 'publish')
2569 2569
 	 * @param string $orderby (default: 'meta_value_num title')
2570 2570
 	 * @param string $order (default: 'ASC')
2571
-     *
2571
+	 *
2572 2572
 	 * @return array $questions { $question type WP_Post }
2573 2573
 	 */
2574 2574
 	public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) {
2575 2575
 
2576 2576
 		$quiz_id = (string) $quiz_id;
2577
-        $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2577
+		$quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2578 2578
 
2579
-        // setup the user id
2580
-        if( is_admin() ) {
2581
-            $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2582
-        } else {
2583
-            $user_id = get_current_user_id();
2584
-        }
2579
+		// setup the user id
2580
+		if( is_admin() ) {
2581
+			$user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2582
+		} else {
2583
+			$user_id = get_current_user_id();
2584
+		}
2585 2585
 
2586
-        // get the users current status on the lesson
2587
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2586
+		// get the users current status on the lesson
2587
+		$user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2588 2588
 
2589 2589
 		// Set the default question order if it has not already been set for this quiz
2590 2590
 		$this->set_default_question_order( $quiz_id );
@@ -2614,14 +2614,14 @@  discard block
 block discarded – undo
2614 2614
 			'suppress_filters' 	=> 0
2615 2615
 		);
2616 2616
 
2617
-        //query the questions
2617
+		//query the questions
2618 2618
 		$questions_query = new WP_Query( $question_query_args );
2619 2619
 
2620
-        // Set return array to initially include all items
2621
-        $questions = $questions_query->posts;
2620
+		// Set return array to initially include all items
2621
+		$questions = $questions_query->posts;
2622 2622
 
2623
-        // set the questions array that will be manipulated within this function
2624
-        $questions_array = $questions_query->posts;
2623
+		// set the questions array that will be manipulated within this function
2624
+		$questions_array = $questions_query->posts;
2625 2625
 
2626 2626
 		// If viewing quiz on frontend or in grading then only single questions must be shown
2627 2627
 		$selected_questions = false;
@@ -2734,36 +2734,36 @@  discard block
 block discarded – undo
2734 2734
 			}
2735 2735
 		}
2736 2736
 
2737
-        // Save the questions that will be asked for the current user
2738
-        // this happens only once per user/quiz, unless the user resets the quiz
2739
-        if( ! is_admin() ){
2737
+		// Save the questions that will be asked for the current user
2738
+		// this happens only once per user/quiz, unless the user resets the quiz
2739
+		if( ! is_admin() ){
2740 2740
 
2741
-            if( $user_lesson_status ) {
2741
+			if( $user_lesson_status ) {
2742 2742
 
2743
-                $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2744
-                if ( empty($questions_asked) && $user_lesson_status) {
2743
+				$questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2744
+				if ( empty($questions_asked) && $user_lesson_status) {
2745 2745
 
2746
-                    $questions_asked = array();
2747
-                    foreach ($questions as $question) {
2746
+					$questions_asked = array();
2747
+					foreach ($questions as $question) {
2748 2748
 
2749
-                        $questions_asked[] = $question->ID;
2749
+						$questions_asked[] = $question->ID;
2750 2750
 
2751
-                    }
2751
+					}
2752 2752
 
2753
-                    // save the questions asked id
2754
-                    $questions_asked_csv = implode(',', $questions_asked);
2755
-                    update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv);
2753
+					// save the questions asked id
2754
+					$questions_asked_csv = implode(',', $questions_asked);
2755
+					update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv);
2756 2756
 
2757
-                }
2758
-            }
2759
-        }
2757
+				}
2758
+			}
2759
+		}
2760 2760
 
2761
-        /**
2762
-         * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions
2763
-         *
2764
-         * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2765
-         * @since 1.8.0
2766
-         */
2761
+		/**
2762
+		 * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions
2763
+		 *
2764
+		 * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2765
+		 * @since 1.8.0
2766
+		 */
2767 2767
 		return apply_filters( 'sensei_lesson_quiz_questions', $questions,  $quiz_id  );
2768 2768
 
2769 2769
 	} // End lesson_quiz_questions()
@@ -2867,7 +2867,7 @@  discard block
 block discarded – undo
2867 2867
  			// Display Image Placeholder if none
2868 2868
 			if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) {
2869 2869
 
2870
-                $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2870
+				$img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2871 2871
 
2872 2872
 			} // End If Statement
2873 2873
 
@@ -2879,418 +2879,418 @@  discard block
 block discarded – undo
2879 2879
 
2880 2880
 	} // End lesson_image()
2881 2881
 
2882
-    /**
2883
-     * Ooutpu the lesson image
2884
-     *
2885
-     * @since 1.9.0
2886
-     * @param integer $lesson_id
2887
-     */
2888
-    public static function the_lesson_image( $lesson_id = 0 ){
2882
+	/**
2883
+	 * Ooutpu the lesson image
2884
+	 *
2885
+	 * @since 1.9.0
2886
+	 * @param integer $lesson_id
2887
+	 */
2888
+	public static function the_lesson_image( $lesson_id = 0 ){
2889 2889
 
2890
-        echo Sensei()->lesson->lesson_image( $lesson_id );
2890
+		echo Sensei()->lesson->lesson_image( $lesson_id );
2891 2891
 
2892
-    }
2892
+	}
2893 2893
 
2894 2894
 	/**
2895 2895
 	 * Returns the the lesson excerpt.
2896 2896
 	 *
2897 2897
 	 * @param WP_Post $lesson
2898
-     * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2898
+	 * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2899 2899
 	 * @return string
2900 2900
 	 */
2901 2901
 	public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) {
2902 2902
 		$html = '';
2903 2903
 		if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) {
2904 2904
 
2905
-            $excerpt =  $lesson->post_excerpt;
2905
+			$excerpt =  $lesson->post_excerpt;
2906 2906
 
2907
-            // if $add_p_tags true wrap with <p> else return the excerpt as is
2908
-            $html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2907
+			// if $add_p_tags true wrap with <p> else return the excerpt as is
2908
+			$html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2909 2909
 
2910 2910
 		}
2911 2911
 		return apply_filters( 'sensei_lesson_excerpt', $html );
2912 2912
 
2913 2913
 	} // End lesson_excerpt()
2914 2914
 
2915
-    /**
2916
-     * Returns the course for a given lesson
2917
-     *
2918
-     * @since 1.7.4
2919
-     * @access public
2920
-     *
2921
-     * @param int $lesson_id
2922
-     * @return int|bool $course_id or bool when nothing is found.
2923
-     */
2924
-     public function get_course_id( $lesson_id ){
2925
-
2926
-         if( ! isset( $lesson_id ) || empty( $lesson_id )
2927
-         ||  'lesson' != get_post_type( $lesson_id ) ){
2928
-             return false;
2929
-         }
2930
-
2931
-         $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2932
-
2933
-         // make sure the course id is valid
2934
-         if( empty( $lesson_course_id )
2935
-             || is_array( $lesson_course_id )
2936
-             || intval( $lesson_course_id ) < 1
2937
-             || 'course' != get_post_type( $lesson_course_id ) ){
2938
-
2939
-             return false;
2940
-
2941
-         }
2942
-
2943
-         return $lesson_course_id;
2944
-
2945
-     }// en get_course_id
2946
-
2947
-    /**
2948
-     * Add the admin all lessons screen edit options.
2949
-     *
2950
-     * The fields in this function work for both quick and bulk edit. The ID attributes is used
2951
-     * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then
2952
-     * name attribute is will be used by the quick edit and submitted via standard POST. This
2953
-     * will use this classes save_post_meta function to save the new field data.
2954
-     *
2955
-     * @hooked quick_edit_custom_box
2956
-     * @hooked bulk_edit_custom_box
2957
-     *
2958
-     * @since 1.8.0
2959
-     *
2960
-     * @param string $column_name
2961
-     * @param string $post_type
2962
-     * @return void
2963
-     */
2964
-    public function all_lessons_edit_fields( $column_name, $post_type ) {
2965
-
2966
-        // only show these options ont he lesson post type edit screen
2967
-        if( 'lesson' != $post_type || 'lesson-course' != $column_name
2968
-            || ! current_user_can( 'edit_lessons' ) ) {
2969
-            return;
2970
-        }
2971
-
2972
-        ?>
2915
+	/**
2916
+	 * Returns the course for a given lesson
2917
+	 *
2918
+	 * @since 1.7.4
2919
+	 * @access public
2920
+	 *
2921
+	 * @param int $lesson_id
2922
+	 * @return int|bool $course_id or bool when nothing is found.
2923
+	 */
2924
+	 public function get_course_id( $lesson_id ){
2925
+
2926
+		 if( ! isset( $lesson_id ) || empty( $lesson_id )
2927
+		 ||  'lesson' != get_post_type( $lesson_id ) ){
2928
+			 return false;
2929
+		 }
2930
+
2931
+		 $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2932
+
2933
+		 // make sure the course id is valid
2934
+		 if( empty( $lesson_course_id )
2935
+			 || is_array( $lesson_course_id )
2936
+			 || intval( $lesson_course_id ) < 1
2937
+			 || 'course' != get_post_type( $lesson_course_id ) ){
2938
+
2939
+			 return false;
2940
+
2941
+		 }
2942
+
2943
+		 return $lesson_course_id;
2944
+
2945
+	 }// en get_course_id
2946
+
2947
+	/**
2948
+	 * Add the admin all lessons screen edit options.
2949
+	 *
2950
+	 * The fields in this function work for both quick and bulk edit. The ID attributes is used
2951
+	 * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then
2952
+	 * name attribute is will be used by the quick edit and submitted via standard POST. This
2953
+	 * will use this classes save_post_meta function to save the new field data.
2954
+	 *
2955
+	 * @hooked quick_edit_custom_box
2956
+	 * @hooked bulk_edit_custom_box
2957
+	 *
2958
+	 * @since 1.8.0
2959
+	 *
2960
+	 * @param string $column_name
2961
+	 * @param string $post_type
2962
+	 * @return void
2963
+	 */
2964
+	public function all_lessons_edit_fields( $column_name, $post_type ) {
2965
+
2966
+		// only show these options ont he lesson post type edit screen
2967
+		if( 'lesson' != $post_type || 'lesson-course' != $column_name
2968
+			|| ! current_user_can( 'edit_lessons' ) ) {
2969
+			return;
2970
+		}
2971
+
2972
+		?>
2973 2973
         <fieldset class="sensei-edit-field-set inline-edit-lesson">
2974 2974
             <div class="sensei-inline-edit-col column-<?php echo $column_name ?>">
2975 2975
                     <?php
2976
-                    echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2977
-                    // create a nonce field to be  used as a security measure when saving the data
2978
-                    wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2979
-                    wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2980
-
2981
-                    // unchanged option - we need this in because
2982
-                    // the default option in bulk edit should not be empty. If it is
2983
-                    // the user will erase data they didn't want to touch.
2984
-                    $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2985
-
2986
-                    //
2987
-                    //course selection
2988
-                    //
2989
-                    $courses =  WooThemes_Sensei_Course::get_all_courses();
2990
-                    $course_options = array();
2991
-                    if ( count( $courses ) > 0 ) {
2992
-                        foreach ($courses as $course ){
2993
-                            $course_options[ $course->ID ] = get_the_title( $course->ID );
2994
-                        }
2995
-                    }
2996
-                    //pre-append the no change option
2997
-                    $course_options['-1']=  $no_change_text;
2998
-                    $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2999
-                    $course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
3000
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
3001
-
3002
-                    //
3003
-                    // lesson complexity selection
3004
-                    //
3005
-                    $lesson_complexities =  $this->lesson_complexities();
3006
-                    //pre-append the no change option
3007
-                    $lesson_complexities['-1']=  $no_change_text;
3008
-                    $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
3009
-                    $complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
3010
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
3011
-
3012
-                    ?>
2976
+					echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2977
+					// create a nonce field to be  used as a security measure when saving the data
2978
+					wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2979
+					wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2980
+
2981
+					// unchanged option - we need this in because
2982
+					// the default option in bulk edit should not be empty. If it is
2983
+					// the user will erase data they didn't want to touch.
2984
+					$no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2985
+
2986
+					//
2987
+					//course selection
2988
+					//
2989
+					$courses =  WooThemes_Sensei_Course::get_all_courses();
2990
+					$course_options = array();
2991
+					if ( count( $courses ) > 0 ) {
2992
+						foreach ($courses as $course ){
2993
+							$course_options[ $course->ID ] = get_the_title( $course->ID );
2994
+						}
2995
+					}
2996
+					//pre-append the no change option
2997
+					$course_options['-1']=  $no_change_text;
2998
+					$course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2999
+					$course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
3000
+					echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
3001
+
3002
+					//
3003
+					// lesson complexity selection
3004
+					//
3005
+					$lesson_complexities =  $this->lesson_complexities();
3006
+					//pre-append the no change option
3007
+					$lesson_complexities['-1']=  $no_change_text;
3008
+					$complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
3009
+					$complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
3010
+					echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
3011
+
3012
+					?>
3013 3013
 
3014 3014
                     <h4><?php _e('Quiz Settings', 'woothemes-sensei'); ?> </h4>
3015 3015
 
3016 3016
                     <?php
3017 3017
 
3018
-                    //
3019
-                    // Lesson require pass to complete
3020
-                    //
3021
-                    $pass_required_options = array(
3022
-                        '-1' => $no_change_text,
3023
-                         '0' => __('No','woothemes'),
3024
-                         '1' => __('Yes','woothemes'),
3025
-                    );
3026
-
3027
-                    $pass_required_select_attributes = array( 'name'=> 'pass_required',
3028
-                                                                'id'=> 'sensei-edit-lesson-pass-required',
3029
-                                                                'class'=>' '   );
3030
-                    $require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3031
-                    echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3032
-
3033
-                    //
3034
-                    // Quiz pass percentage
3035
-                    //
3036
-                    $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3037
-                    echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3038
-
3039
-                    //
3040
-                    // Enable quiz reset button
3041
-                    //
3042
-                    $quiz_reset_select__options = array(
3043
-                        '-1' => $no_change_text,
3044
-                        '0' => __('No','woothemes'),
3045
-                        '1' => __('Yes','woothemes'),
3046
-                    );
3047
-                    $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3048
-                    $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3049
-                    $quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3050
-                    echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3051
-
3052
-                    ?>
3018
+					//
3019
+					// Lesson require pass to complete
3020
+					//
3021
+					$pass_required_options = array(
3022
+						'-1' => $no_change_text,
3023
+						 '0' => __('No','woothemes'),
3024
+						 '1' => __('Yes','woothemes'),
3025
+					);
3026
+
3027
+					$pass_required_select_attributes = array( 'name'=> 'pass_required',
3028
+																'id'=> 'sensei-edit-lesson-pass-required',
3029
+																'class'=>' '   );
3030
+					$require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3031
+					echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3032
+
3033
+					//
3034
+					// Quiz pass percentage
3035
+					//
3036
+					$quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3037
+					echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3038
+
3039
+					//
3040
+					// Enable quiz reset button
3041
+					//
3042
+					$quiz_reset_select__options = array(
3043
+						'-1' => $no_change_text,
3044
+						'0' => __('No','woothemes'),
3045
+						'1' => __('Yes','woothemes'),
3046
+					);
3047
+					$quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3048
+					$quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3049
+					$quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3050
+					echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3051
+
3052
+					?>
3053 3053
             </div>
3054 3054
         </fieldset>
3055 3055
     <?php
3056
-    }// all_lessons_edit_fields
3057
-
3058
-    /**
3059
-     * Create the html for the edit field
3060
-     *
3061
-     * Wraps the passed in field and title combination with the correct html.
3062
-     *
3063
-     * @since 1.8.0
3064
-     *
3065
-     * @param string $title that will stand to the left of the field.
3066
-     * @param string $field type markup for the field that must be wrapped.
3067
-     * @return string $field_html
3068
-     */
3069
-    public function generate_all_lessons_edit_field( $title  ,$field ){
3070
-
3071
-        $html = '';
3072
-        $html = '<div class="inline-edit-group" >';
3073
-        $html .=  '<span class="title">'. $title .'</span> ';
3074
-        $html .= '<span class="input-text-wrap">';
3075
-        $html .= $field;
3076
-        $html .= '</span>';
3077
-        $html .= '</label></div>';
3078
-
3079
-        return $html ;
3080
-
3081
-    }//end generate_all_lessons_edit_field
3082
-
3083
-    /**
3084
-     * Respond to the ajax call from the bulk edit save function. This comes
3085
-     * from the admin all lesson screen.
3086
-     *
3087
-     * @since 1.8.0
3088
-     * @return void
3089
-     */
3090
-    function save_all_lessons_edit_fields() {
3091
-
3092
-        // verify all the data before attempting to save
3093
-        if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3094
-            ||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3095
-            die();
3096
-        }
3097
-
3098
-        // get our variables
3099
-        $new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3100
-        $new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3101
-        $new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3102
-        $new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3103
-        $new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3104
-        // store the values for all selected posts
3105
-        foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3106
-
3107
-            // get the quiz id needed for the quiz meta
3108
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3109
-
3110
-            // do not save the items if the value is -1 as this
3111
-            // means it was not changed
3112
-
3113
-            // update lesson course
3114
-            if( -1 != $new_course ){
3115
-                update_post_meta( $lesson_id, '_lesson_course', $new_course );
3116
-            }
3117
-            // update lesson complexity
3118
-            if( -1 != $new_complexity ){
3119
-                update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3120
-            }
3121
-
3122
-            // Quiz Related settings
3123
-            if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3124
-
3125
-                // update pass required
3126
-                if (-1 != $new_pass_required) {
3127
-
3128
-                    $checked = $new_pass_required  ? 'on' : '';
3129
-                    update_post_meta($quiz_id, '_pass_required', $checked);
3130
-                    unset( $checked );
3131
-                }
3056
+	}// all_lessons_edit_fields
3057
+
3058
+	/**
3059
+	 * Create the html for the edit field
3060
+	 *
3061
+	 * Wraps the passed in field and title combination with the correct html.
3062
+	 *
3063
+	 * @since 1.8.0
3064
+	 *
3065
+	 * @param string $title that will stand to the left of the field.
3066
+	 * @param string $field type markup for the field that must be wrapped.
3067
+	 * @return string $field_html
3068
+	 */
3069
+	public function generate_all_lessons_edit_field( $title  ,$field ){
3070
+
3071
+		$html = '';
3072
+		$html = '<div class="inline-edit-group" >';
3073
+		$html .=  '<span class="title">'. $title .'</span> ';
3074
+		$html .= '<span class="input-text-wrap">';
3075
+		$html .= $field;
3076
+		$html .= '</span>';
3077
+		$html .= '</label></div>';
3078
+
3079
+		return $html ;
3080
+
3081
+	}//end generate_all_lessons_edit_field
3082
+
3083
+	/**
3084
+	 * Respond to the ajax call from the bulk edit save function. This comes
3085
+	 * from the admin all lesson screen.
3086
+	 *
3087
+	 * @since 1.8.0
3088
+	 * @return void
3089
+	 */
3090
+	function save_all_lessons_edit_fields() {
3132 3091
 
3133
-                // update pass percentage
3134
-                if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3092
+		// verify all the data before attempting to save
3093
+		if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3094
+			||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3095
+			die();
3096
+		}
3135 3097
 
3136
-                        update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3098
+		// get our variables
3099
+		$new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3100
+		$new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3101
+		$new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3102
+		$new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3103
+		$new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3104
+		// store the values for all selected posts
3105
+		foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3137 3106
 
3138
-                }
3107
+			// get the quiz id needed for the quiz meta
3108
+			$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3139 3109
 
3140
-                //
3141
-                // update enable quiz reset
3142
-                //
3143
-                if (-1 != $new_enable_quiz_reset ) {
3110
+			// do not save the items if the value is -1 as this
3111
+			// means it was not changed
3144 3112
 
3145
-                    $checked = $new_enable_quiz_reset ? 'on' : ''  ;
3146
-                    update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3147
-                    unset( $checked );
3113
+			// update lesson course
3114
+			if( -1 != $new_course ){
3115
+				update_post_meta( $lesson_id, '_lesson_course', $new_course );
3116
+			}
3117
+			// update lesson complexity
3118
+			if( -1 != $new_complexity ){
3119
+				update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3120
+			}
3148 3121
 
3149
-                }
3122
+			// Quiz Related settings
3123
+			if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3150 3124
 
3125
+				// update pass required
3126
+				if (-1 != $new_pass_required) {
3151 3127
 
3152
-            } // end if quiz
3128
+					$checked = $new_pass_required  ? 'on' : '';
3129
+					update_post_meta($quiz_id, '_pass_required', $checked);
3130
+					unset( $checked );
3131
+				}
3153 3132
 
3154
-        }// end for each
3133
+				// update pass percentage
3134
+				if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3155 3135
 
3156
-        die();
3136
+						update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3157 3137
 
3158
-    } // end save_all_lessons_edit_fields
3138
+				}
3139
+
3140
+				//
3141
+				// update enable quiz reset
3142
+				//
3143
+				if (-1 != $new_enable_quiz_reset ) {
3159 3144
 
3160
-    /**
3161
-     * Loading the quick edit fields defaults.
3162
-     *
3163
-     * This function will localise the default values along with the script that will
3164
-     * add these values to the inputs.
3165
-     *
3166
-     * NOTE: this function runs for each row in the edit column
3167
-     *
3168
-     * @since 1.8.0
3169
-     * @return void
3170
-     */
3171
-    public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3145
+					$checked = $new_enable_quiz_reset ? 'on' : ''  ;
3146
+					update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3147
+					unset( $checked );
3148
+
3149
+				}
3150
+
3151
+
3152
+			} // end if quiz
3153
+
3154
+		}// end for each
3155
+
3156
+		die();
3157
+
3158
+	} // end save_all_lessons_edit_fields
3159
+
3160
+	/**
3161
+	 * Loading the quick edit fields defaults.
3162
+	 *
3163
+	 * This function will localise the default values along with the script that will
3164
+	 * add these values to the inputs.
3165
+	 *
3166
+	 * NOTE: this function runs for each row in the edit column
3167
+	 *
3168
+	 * @since 1.8.0
3169
+	 * @return void
3170
+	 */
3171
+	public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3172 3172
 
3173
-        if( 'lesson-course' != $column_name ){
3174
-            return;
3175
-        }
3176
-        // load the script
3177
-        $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3178
-        wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3173
+		if( 'lesson-course' != $column_name ){
3174
+			return;
3175
+		}
3176
+		// load the script
3177
+		$suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3178
+		wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3179 3179
 
3180
-        // setup the values for all meta fields
3181
-        $data = array();
3182
-        foreach( $this->meta_fields as $field ){
3180
+		// setup the values for all meta fields
3181
+		$data = array();
3182
+		foreach( $this->meta_fields as $field ){
3183 3183
 
3184
-            $data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3184
+			$data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3185 3185
 
3186
-        }
3187
-        // add quiz meta fields
3188
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3189
-        foreach( Sensei()->quiz->meta_fields as $field ){
3186
+		}
3187
+		// add quiz meta fields
3188
+		$quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3189
+		foreach( Sensei()->quiz->meta_fields as $field ){
3190 3190
 
3191
-            $data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3191
+			$data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3192 3192
 
3193
-        }
3193
+		}
3194 3194
 
3195
-        wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3195
+		wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3196 3196
 
3197
-    }// end quick edit admin defaults
3197
+	}// end quick edit admin defaults
3198 3198
 
3199
-    /**
3200
-     * Filter the classes for lessons on the single course page.
3201
-     *
3202
-     * Adds the nesecary classes depending on the user data
3203
-     *
3204
-     * @since 1.9.0
3205
-     * @param array $classes
3206
-     * @return array $classes
3207
-     */
3208
-    public static function single_course_lessons_classes( $classes ){
3199
+	/**
3200
+	 * Filter the classes for lessons on the single course page.
3201
+	 *
3202
+	 * Adds the nesecary classes depending on the user data
3203
+	 *
3204
+	 * @since 1.9.0
3205
+	 * @param array $classes
3206
+	 * @return array $classes
3207
+	 */
3208
+	public static function single_course_lessons_classes( $classes ){
3209 3209
 
3210
-        if(  is_singular('course') ){
3210
+		if(  is_singular('course') ){
3211 3211
 
3212
-            global $post;
3213
-            $course_id = $post->ID;
3212
+			global $post;
3213
+			$course_id = $post->ID;
3214 3214
 
3215
-            $lesson_classes = array( 'course', 'post' );
3216
-            if ( is_user_logged_in() ) {
3215
+			$lesson_classes = array( 'course', 'post' );
3216
+			if ( is_user_logged_in() ) {
3217 3217
 
3218
-                // Check if Lesson is complete
3219
-                $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3220
-                if ( $single_lesson_complete ) {
3218
+				// Check if Lesson is complete
3219
+				$single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3220
+				if ( $single_lesson_complete ) {
3221 3221
 
3222
-                    $lesson_classes[] = 'lesson-completed';
3222
+					$lesson_classes[] = 'lesson-completed';
3223 3223
 
3224
-                } // End If Statement
3224
+				} // End If Statement
3225 3225
 
3226
-            } // End If Statement
3226
+			} // End If Statement
3227 3227
 
3228
-            $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3229
-            if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3228
+			$is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3229
+			if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3230 3230
 
3231
-                $lesson_classes[] = 'lesson-preview';
3231
+				$lesson_classes[] = 'lesson-preview';
3232 3232
 
3233
-            }
3233
+			}
3234 3234
 
3235
-            $classes = array_merge( $classes, $lesson_classes  );
3235
+			$classes = array_merge( $classes, $lesson_classes  );
3236 3236
 
3237
-        }
3237
+		}
3238 3238
 
3239
-        return $classes;
3239
+		return $classes;
3240 3240
 
3241
-    }// end single_course_lessons_classes
3241
+	}// end single_course_lessons_classes
3242 3242
 
3243
-    /**
3244
-     * Output the lesson meta for the given lesson
3245
-     *
3246
-     * @since 1.9.0
3247
-     * @param $lesson_id
3248
-     */
3249
-    public static function the_lesson_meta( $lesson_id ){
3243
+	/**
3244
+	 * Output the lesson meta for the given lesson
3245
+	 *
3246
+	 * @since 1.9.0
3247
+	 * @param $lesson_id
3248
+	 */
3249
+	public static function the_lesson_meta( $lesson_id ){
3250 3250
 
3251
-        global $wp_query;
3252
-        $loop_lesson_number = $wp_query->current_post + 1;
3251
+		global $wp_query;
3252
+		$loop_lesson_number = $wp_query->current_post + 1;
3253 3253
 
3254
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
3255
-        $single_lesson_complete = false;
3256
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3254
+		$course_id = Sensei()->lesson->get_course_id( $lesson_id );
3255
+		$single_lesson_complete = false;
3256
+		$is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3257 3257
 
3258
-        // Get Lesson data
3259
-        $complexity_array = Sensei()->lesson->lesson_complexities();
3258
+		// Get Lesson data
3259
+		$complexity_array = Sensei()->lesson->lesson_complexities();
3260 3260
 
3261
-        $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3262
-        if ( '' != $lesson_complexity ) {
3261
+		$lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3262
+		if ( '' != $lesson_complexity ) {
3263 3263
 
3264
-            $lesson_complexity = $complexity_array[$lesson_complexity];
3264
+			$lesson_complexity = $complexity_array[$lesson_complexity];
3265 3265
 
3266
-        }
3267
-        $user_info = get_userdata( absint( get_post()->post_author ) );
3268
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3269
-        $preview_label = '';
3270
-        if ( $is_preview && !$is_user_taking_course ) {
3266
+		}
3267
+		$user_info = get_userdata( absint( get_post()->post_author ) );
3268
+		$is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3269
+		$preview_label = '';
3270
+		if ( $is_preview && !$is_user_taking_course ) {
3271 3271
 
3272
-            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3273
-            $preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3272
+			$preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3273
+			$preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3274 3274
 
3275
-        }
3275
+		}
3276 3276
 
3277 3277
 
3278
-        $count_markup= '';
3279
-        /**
3280
-         * Filter for if you want the $lesson_count to show next to the lesson.
3281
-         *
3282
-         * @since 1.0
3283
-         * @param bool default false.
3284
-         */
3285
-        if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3278
+		$count_markup= '';
3279
+		/**
3280
+		 * Filter for if you want the $lesson_count to show next to the lesson.
3281
+		 *
3282
+		 * @since 1.0
3283
+		 * @param bool default false.
3284
+		 */
3285
+		if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3286 3286
 
3287
-            $count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3287
+			$count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3288 3288
 
3289
-        }
3289
+		}
3290 3290
 
3291
-        $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3291
+		$heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3292 3292
 
3293
-        ?>
3293
+		?>
3294 3294
         <header>
3295 3295
             <h2>
3296 3296
                 <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>"
@@ -3303,40 +3303,40 @@  discard block
 block discarded – undo
3303 3303
 
3304 3304
                 <?php
3305 3305
 
3306
-                $meta_html = '';
3307
-                $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3306
+				$meta_html = '';
3307
+				$user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3308 3308
 
3309
-                $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3310
-                if ( '' != $lesson_length ) {
3309
+				$lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3310
+				if ( '' != $lesson_length ) {
3311 3311
 
3312
-                    $meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3312
+					$meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3313 3313
 
3314
-                }
3314
+				}
3315 3315
 
3316
-                if ( Sensei()->settings->get( 'lesson_author' ) ) {
3316
+				if ( Sensei()->settings->get( 'lesson_author' ) ) {
3317 3317
 
3318
-                    $meta_html .= '<span class="lesson-author">' .  __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
3318
+					$meta_html .= '<span class="lesson-author">' .  __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
3319 3319
 
3320
-                } // End If Statement
3321
-                if ( '' != $lesson_complexity ) {
3320
+				} // End If Statement
3321
+				if ( '' != $lesson_complexity ) {
3322 3322
 
3323
-                    $meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3323
+					$meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3324 3324
 
3325
-                }
3325
+				}
3326 3326
 
3327
-                if ( $single_lesson_complete ) {
3327
+				if ( $single_lesson_complete ) {
3328 3328
 
3329
-                    $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3329
+					$meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3330 3330
 
3331
-                } elseif ( $user_lesson_status ) {
3331
+				} elseif ( $user_lesson_status ) {
3332 3332
 
3333
-                    $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3333
+					$meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3334 3334
 
3335
-                } // End If Statement
3335
+				} // End If Statement
3336 3336
 
3337
-                echo $meta_html;
3337
+				echo $meta_html;
3338 3338
 
3339
-                ?>
3339
+				?>
3340 3340
 
3341 3341
             </p> <!-- lesson meta -->
3342 3342
 
@@ -3344,132 +3344,132 @@  discard block
 block discarded – undo
3344 3344
 
3345 3345
     <?php
3346 3346
 
3347
-    } // end the_lesson_meta
3347
+	} // end the_lesson_meta
3348 3348
 
3349
-    /**
3350
-     * Output the lessons thumbnail
3351
-     *
3352
-     * 1.9.0
3353
-     *
3354
-     * @param $lesson_id
3355
-     */
3356
-    public static function the_lesson_thumbnail( $lesson_id ){
3349
+	/**
3350
+	 * Output the lessons thumbnail
3351
+	 *
3352
+	 * 1.9.0
3353
+	 *
3354
+	 * @param $lesson_id
3355
+	 */
3356
+	public static function the_lesson_thumbnail( $lesson_id ){
3357 3357
 
3358
-        if( empty( $lesson_id ) ){
3358
+		if( empty( $lesson_id ) ){
3359 3359
 
3360
-            $lesson_id = get_the_ID();
3360
+			$lesson_id = get_the_ID();
3361 3361
 
3362
-        }
3362
+		}
3363 3363
 
3364
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3365
-            return;
3366
-        }
3364
+		if( 'lesson' != get_post_type( $lesson_id ) ){
3365
+			return;
3366
+		}
3367 3367
 
3368
-        echo Sensei()->lesson->lesson_image( $lesson_id );
3369
-    }
3368
+		echo Sensei()->lesson->lesson_image( $lesson_id );
3369
+	}
3370 3370
 
3371 3371
 
3372
-    /**
3373
-     * Alter the sensei lesson excerpt.
3374
-     *
3375
-     * @since 1.9.0
3376
-     * @param string $excerpt
3377
-     * @return string $excerpt
3378
-     */
3379
-    public static function alter_the_lesson_excerpt( $excerpt ) {
3372
+	/**
3373
+	 * Alter the sensei lesson excerpt.
3374
+	 *
3375
+	 * @since 1.9.0
3376
+	 * @param string $excerpt
3377
+	 * @return string $excerpt
3378
+	 */
3379
+	public static function alter_the_lesson_excerpt( $excerpt ) {
3380 3380
 
3381
-        if ('lesson' == get_post_type(get_the_ID())){
3381
+		if ('lesson' == get_post_type(get_the_ID())){
3382 3382
 
3383
-            // remove this hooks to avoid an infinite loop.
3384
-            remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3383
+			// remove this hooks to avoid an infinite loop.
3384
+			remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3385 3385
 
3386
-            return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3387
-        }
3386
+			return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3387
+		}
3388 3388
 
3389
-        return $excerpt;
3389
+		return $excerpt;
3390 3390
 
3391
-    }// end the_lesson_excerpt
3391
+	}// end the_lesson_excerpt
3392 3392
 
3393
-    /**
3394
-     * Returns the lesson prerequisite for the given lesson id.
3395
-     *
3396
-     * @since 1.9.0
3397
-     *
3398
-     * @param $current_lesson_id
3399
-     * @return mixed | bool | int $prerequisite_lesson_id or false
3400
-     */
3401
-    public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3393
+	/**
3394
+	 * Returns the lesson prerequisite for the given lesson id.
3395
+	 *
3396
+	 * @since 1.9.0
3397
+	 *
3398
+	 * @param $current_lesson_id
3399
+	 * @return mixed | bool | int $prerequisite_lesson_id or false
3400
+	 */
3401
+	public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3402 3402
 
3403
-        $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3403
+		$prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3404 3404
 
3405
-        // set ti to false if not a valid prerequisite lesson id
3406
-        if(  empty( $prerequisite_lesson_id )
3407
-            || 'lesson' != get_post_type( $prerequisite_lesson_id )
3408
-            || $prerequisite_lesson_id == $current_lesson_id  ) {
3405
+		// set ti to false if not a valid prerequisite lesson id
3406
+		if(  empty( $prerequisite_lesson_id )
3407
+			|| 'lesson' != get_post_type( $prerequisite_lesson_id )
3408
+			|| $prerequisite_lesson_id == $current_lesson_id  ) {
3409 3409
 
3410
-            $prerequisite_lesson_id = false;
3410
+			$prerequisite_lesson_id = false;
3411 3411
 
3412
-        }
3412
+		}
3413 3413
 
3414
-        return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3414
+		return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3415 3415
 
3416
-    }
3416
+	}
3417 3417
 
3418
-    /**
3419
-     * This function requires that you pass in the lesson you would like to check for
3420
-     * a pre-requisite and not the pre-requisite. It will check if the
3421
-     * lesson has a pre-requiste and then check if it is completed.
3422
-     *
3423
-     * @since 1.9.0
3424
-     *
3425
-     * @param $lesson_id
3426
-     * @param $user_id
3427
-     * @return bool
3428
-     */
3429
-    public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3418
+	/**
3419
+	 * This function requires that you pass in the lesson you would like to check for
3420
+	 * a pre-requisite and not the pre-requisite. It will check if the
3421
+	 * lesson has a pre-requiste and then check if it is completed.
3422
+	 *
3423
+	 * @since 1.9.0
3424
+	 *
3425
+	 * @param $lesson_id
3426
+	 * @param $user_id
3427
+	 * @return bool
3428
+	 */
3429
+	public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3430 3430
 
3431
-        if( empty( $lesson_id ) || empty( $user_id )
3432
-        || 'lesson' != get_post_type( $lesson_id )
3433
-        ||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3431
+		if( empty( $lesson_id ) || empty( $user_id )
3432
+		|| 'lesson' != get_post_type( $lesson_id )
3433
+		||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3434 3434
 
3435
-            return false;
3435
+			return false;
3436 3436
 
3437
-        }
3437
+		}
3438 3438
 
3439
-        $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3439
+		$pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3440 3440
 
3441
-        // not a valid pre-requisite so pre-requisite is completed
3442
-        if( 'lesson' != get_post_type( $pre_requisite_id )
3443
-            || ! is_numeric( $pre_requisite_id ) ){
3441
+		// not a valid pre-requisite so pre-requisite is completed
3442
+		if( 'lesson' != get_post_type( $pre_requisite_id )
3443
+			|| ! is_numeric( $pre_requisite_id ) ){
3444 3444
 
3445
-            return true;
3445
+			return true;
3446 3446
 
3447
-        }
3447
+		}
3448 3448
 
3449
-        return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3449
+		return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3450 3450
 
3451
-    }// end is_prerequisite_complete
3451
+	}// end is_prerequisite_complete
3452 3452
 
3453
-    /**
3454
-     * Show the user not taking course message if it is the case
3455
-     *
3456
-     * @since 1.9.0
3457
-     */
3458
-    public  static function user_not_taking_course_message(){
3453
+	/**
3454
+	 * Show the user not taking course message if it is the case
3455
+	 *
3456
+	 * @since 1.9.0
3457
+	 */
3458
+	public  static function user_not_taking_course_message(){
3459 3459
 
3460
-        $lesson_id = get_the_ID();
3460
+		$lesson_id = get_the_ID();
3461 3461
 
3462
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3463
-            return;
3464
-        }
3462
+		if( 'lesson' != get_post_type( $lesson_id ) ){
3463
+			return;
3464
+		}
3465 3465
 
3466
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3467
-        $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3468
-        $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3469
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3466
+		$is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3467
+		$pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3468
+		$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3469
+		$user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3470 3470
 
3471
-        if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3472
-            ?>
3471
+		if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3472
+			?>
3473 3473
 
3474 3474
             <div class="sensei-message alert">
3475 3475
                 <?php echo Sensei()->permissions_message['message']; ?>
@@ -3477,46 +3477,46 @@  discard block
 block discarded – undo
3477 3477
 
3478 3478
             <?php
3479 3479
 
3480
-        }// end if
3480
+		}// end if
3481 3481
 
3482
-    } // end user_not_taking_course_message
3482
+	} // end user_not_taking_course_message
3483 3483
 
3484
-    /**
3485
-     * Outputs the lessons course signup lingk
3486
-     *
3487
-     * This hook runs inside the single lesson page.
3488
-     *
3489
-     * @since 1.9.0
3490
-     */
3491
-    public static function course_signup_link( ){
3484
+	/**
3485
+	 * Outputs the lessons course signup lingk
3486
+	 *
3487
+	 * This hook runs inside the single lesson page.
3488
+	 *
3489
+	 * @since 1.9.0
3490
+	 */
3491
+	public static function course_signup_link( ){
3492 3492
 
3493
-        $course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3493
+		$course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3494 3494
 
3495
-        if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3495
+		if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3496 3496
 
3497
-            return;
3497
+			return;
3498 3498
 
3499
-        }
3500
-        ?>
3499
+		}
3500
+		?>
3501 3501
 
3502 3502
         <section class="course-signup lesson-meta">
3503 3503
 
3504 3504
             <?php
3505
-            $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3505
+			$wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3506 3506
 
3507
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3507
+			if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3508 3508
 
3509
-                global $current_user;
3510
-                if( is_user_logged_in() ) {
3511
-                    wp_get_current_user();
3509
+				global $current_user;
3510
+				if( is_user_logged_in() ) {
3511
+					wp_get_current_user();
3512 3512
 
3513
-                    $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3513
+					$course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3514 3514
 
3515
-                    if( $course_purchased ) {
3515
+					if( $course_purchased ) {
3516 3516
 
3517
-                        $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3518
-                        $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3519
-                        ?>
3517
+						$prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3518
+						$course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3519
+						?>
3520 3520
                             <div class="sensei-message info">
3521 3521
 
3522 3522
                                 <?php  echo sprintf( __( 'Please complete %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); ?>
@@ -3525,27 +3525,27 @@  discard block
 block discarded – undo
3525 3525
 
3526 3526
                     <?php } else {
3527 3527
 
3528
-	                    if( ! Sensei_Utils::user_started_course( $course_id, $current_user->ID )  ){
3528
+						if( ! Sensei_Utils::user_started_course( $course_id, $current_user->ID )  ){
3529 3529
 
3530
-		                    ?>
3530
+							?>
3531 3531
 
3532 3532
 	                        <div class="sensei-message info">
3533 3533
 
3534 3534
 	                            <?php
3535
-	                            $course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3536
-	                                            . '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3537
-	                                            . '">' . __( 'course', 'woothemes-sensei' )
3538
-	                                            . '</a>';
3535
+								$course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3536
+												. '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3537
+												. '">' . __( 'course', 'woothemes-sensei' )
3538
+												. '</a>';
3539 3539
 
3540
-	                            echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3540
+								echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3541 3541
 
3542
-	                            ?>
3542
+								?>
3543 3543
 
3544 3544
 	                        </div>
3545 3545
                     <?php
3546
-	                    }
3547
-                    }
3548
-	                ?>
3546
+						}
3547
+					}
3548
+					?>
3549 3549
 
3550 3550
                 <?php } else { ?>
3551 3551
 
@@ -3559,11 +3559,11 @@  discard block
 block discarded – undo
3559 3559
 
3560 3560
                 <div class="sensei-message alert">
3561 3561
                     <?php
3562
-                    $course_link =  '<a href="'
3563
-                                        . esc_url( get_permalink( $course_id ) )
3564
-                                        . '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3565
-                                        . '">' . __( 'course', 'woothemes-sensei' )
3566
-                                    . '</a>';
3562
+					$course_link =  '<a href="'
3563
+										. esc_url( get_permalink( $course_id ) )
3564
+										. '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3565
+										. '">' . __( 'course', 'woothemes-sensei' )
3566
+									. '</a>';
3567 3567
 
3568 3568
 					if ( Sensei_Utils::is_preview_lesson( get_the_ID( ) ) ) {
3569 3569
 
@@ -3575,7 +3575,7 @@  discard block
 block discarded – undo
3575 3575
 
3576 3576
 					}
3577 3577
 
3578
-                    ?>
3578
+					?>
3579 3579
                 </div>
3580 3580
 
3581 3581
             <?php endif; ?>
@@ -3585,75 +3585,75 @@  discard block
 block discarded – undo
3585 3585
         </section>
3586 3586
 
3587 3587
         <?php
3588
-    }// end course_signup_link
3588
+	}// end course_signup_link
3589 3589
 
3590
-    /**
3591
-     * Show a message telling the user to complete the previous message if they haven't done so yet
3592
-     *
3593
-     * @since 1.9.0
3594
-     */
3595
-    public  static function prerequisite_complete_message(){
3590
+	/**
3591
+	 * Show a message telling the user to complete the previous message if they haven't done so yet
3592
+	 *
3593
+	 * @since 1.9.0
3594
+	 */
3595
+	public  static function prerequisite_complete_message(){
3596 3596
 
3597
-        $lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3598
-        $lesson_has_pre_requisite = $lesson_prerequisite > 0;
3599
-        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3597
+		$lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3598
+		$lesson_has_pre_requisite = $lesson_prerequisite > 0;
3599
+		if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3600 3600
 
3601
-            $prerequisite_lesson_link  = '<a href="' . esc_url( get_permalink( $lesson_prerequisite ) ) . '" title="' . esc_attr(  sprintf( __( 'You must first complete: %1$s', 'woothemes-sensei' ), get_the_title( $lesson_prerequisite ) ) ) . '">' . get_the_title( $lesson_prerequisite ). '</a>';
3602
-            echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3601
+			$prerequisite_lesson_link  = '<a href="' . esc_url( get_permalink( $lesson_prerequisite ) ) . '" title="' . esc_attr(  sprintf( __( 'You must first complete: %1$s', 'woothemes-sensei' ), get_the_title( $lesson_prerequisite ) ) ) . '">' . get_the_title( $lesson_prerequisite ). '</a>';
3602
+			echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3603 3603
 
3604
-        }
3604
+		}
3605 3605
 
3606
-    }
3606
+	}
3607 3607
 
3608
-    /**
3609
-     * Deprecate the sensei_lesson_archive_header hook but keep it
3610
-     * active for backwards compatibility.
3611
-     *
3612
-     * @deprecated since 1.9.0
3613
-     */
3614
-    public static function deprecate_sensei_lesson_archive_header_hook(){
3608
+	/**
3609
+	 * Deprecate the sensei_lesson_archive_header hook but keep it
3610
+	 * active for backwards compatibility.
3611
+	 *
3612
+	 * @deprecated since 1.9.0
3613
+	 */
3614
+	public static function deprecate_sensei_lesson_archive_header_hook(){
3615 3615
 
3616
-        sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3616
+		sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3617 3617
 
3618
-    }
3618
+	}
3619 3619
 
3620
-    /**
3621
-     * Outputs the the lesson archive header.
3622
-     *
3623
-     * @since  1.9.0
3624
-     * @return void
3625
-     */
3626
-    public function the_archive_header( ) {
3620
+	/**
3621
+	 * Outputs the the lesson archive header.
3622
+	 *
3623
+	 * @since  1.9.0
3624
+	 * @return void
3625
+	 */
3626
+	public function the_archive_header( ) {
3627 3627
 
3628
-        $before_html = '<header class="archive-header"><h1>';
3629
-        $after_html = '</h1></header>';
3630
-        $html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3628
+		$before_html = '<header class="archive-header"><h1>';
3629
+		$after_html = '</h1></header>';
3630
+		$html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3631 3631
 
3632
-        echo apply_filters( 'sensei_lesson_archive_title', $html );
3632
+		echo apply_filters( 'sensei_lesson_archive_title', $html );
3633 3633
 
3634
-    } // sensei_course_archive_header()
3634
+	} // sensei_course_archive_header()
3635 3635
 
3636
-    /**
3637
-     * Output the title for the single lesson page
3638
-     *
3639
-     * @global $post
3640
-     * @since 1.9.0
3641
-     */
3642
-    public static function the_title(){
3636
+	/**
3637
+	 * Output the title for the single lesson page
3638
+	 *
3639
+	 * @global $post
3640
+	 * @since 1.9.0
3641
+	 */
3642
+	public static function the_title(){
3643 3643
 
3644
-        global $post;
3644
+		global $post;
3645 3645
 
3646
-        ?>
3646
+		?>
3647 3647
         <header>
3648 3648
 
3649 3649
             <h1>
3650 3650
 
3651 3651
                 <?php
3652
-                /**
3653
-                 * Filter documented in class-sensei-messages.php the_title
3654
-                 */
3655
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3656
-                ?>
3652
+				/**
3653
+				 * Filter documented in class-sensei-messages.php the_title
3654
+				 */
3655
+				echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3656
+				?>
3657 3657
 
3658 3658
             </h1>
3659 3659
 
@@ -3661,75 +3661,75 @@  discard block
 block discarded – undo
3661 3661
 
3662 3662
         <?php
3663 3663
 
3664
-    }//the_title
3664
+	}//the_title
3665 3665
 
3666
-    /**
3667
-     * Flush the rewrite rules for a lesson post type
3668
-     *
3669
-     * @since 1.9.0
3670
-     *
3671
-     * @param $post_id
3672
-     */
3673
-    public static function flush_rewrite_rules( $post_id ){
3666
+	/**
3667
+	 * Flush the rewrite rules for a lesson post type
3668
+	 *
3669
+	 * @since 1.9.0
3670
+	 *
3671
+	 * @param $post_id
3672
+	 */
3673
+	public static function flush_rewrite_rules( $post_id ){
3674 3674
 
3675
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3675
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3676 3676
 
3677
-            return;
3677
+			return;
3678 3678
 
3679
-        }
3679
+		}
3680 3680
 
3681 3681
 
3682
-        if( 'lesson' == get_post_type( $post_id )  ){
3682
+		if( 'lesson' == get_post_type( $post_id )  ){
3683 3683
 
3684
-            Sensei()->initiate_rewrite_rules_flush();
3684
+			Sensei()->initiate_rewrite_rules_flush();
3685 3685
 
3686
-        }
3686
+		}
3687 3687
 
3688
-    }
3688
+	}
3689 3689
 
3690
-    /**
3691
-     * Output the quiz specific buttons and messaging on the single lesson page
3692
-     *
3693
-     *
3694
-     * @since 1.0.0 moved here from frontend class
3695
-     *
3696
-     * @param int $lesson_id
3697
-     * @param int $user_id
3698
-     */
3699
-    public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3690
+	/**
3691
+	 * Output the quiz specific buttons and messaging on the single lesson page
3692
+	 *
3693
+	 *
3694
+	 * @since 1.0.0 moved here from frontend class
3695
+	 *
3696
+	 * @param int $lesson_id
3697
+	 * @param int $user_id
3698
+	 */
3699
+	public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3700 3700
 
3701 3701
 
3702
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3703
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3702
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3703
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3704 3704
 
3705 3705
 
3706
-	    if ( ! sensei_can_user_view_lesson( $lesson_id, $user_id ) ) {
3707
-		    return;
3708
-	    }
3706
+		if ( ! sensei_can_user_view_lesson( $lesson_id, $user_id ) ) {
3707
+			return;
3708
+		}
3709 3709
 
3710
-        $lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3711
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3712
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3713
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3714
-        $show_actions              = is_user_logged_in() ? true : false;
3710
+		$lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3711
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3712
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3713
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3714
+		$show_actions              = is_user_logged_in() ? true : false;
3715 3715
 
3716
-        if( intval( $lesson_prerequisite ) > 0 ) {
3716
+		if( intval( $lesson_prerequisite ) > 0 ) {
3717 3717
 
3718
-            // If the user hasn't completed the prereq then hide the current actions
3719
-            $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3718
+			// If the user hasn't completed the prereq then hide the current actions
3719
+			$show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3720 3720
 
3721
-        }
3721
+		}
3722 3722
 
3723
-        ?>
3723
+		?>
3724 3724
 
3725 3725
         <footer>
3726 3726
 
3727 3727
             <?php
3728
-            if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3728
+			if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3729 3729
 
3730
-                $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3731
-                if( $has_quiz_questions ) {
3732
-                    ?>
3730
+				$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3731
+				if( $has_quiz_questions ) {
3732
+					?>
3733 3733
 
3734 3734
                     <p>
3735 3735
 
@@ -3744,123 +3744,123 @@  discard block
 block discarded – undo
3744 3744
                     </p>
3745 3745
 
3746 3746
                     <?php
3747
-                }
3747
+				}
3748 3748
 
3749
-            } // End If Statement
3749
+			} // End If Statement
3750 3750
 
3751
-            if ( $show_actions && ! $has_user_completed_lesson ) {
3751
+			if ( $show_actions && ! $has_user_completed_lesson ) {
3752 3752
 
3753
-                sensei_complete_lesson_button();
3753
+				sensei_complete_lesson_button();
3754 3754
 
3755
-            } elseif( $show_actions ) {
3755
+			} elseif( $show_actions ) {
3756 3756
 
3757
-                sensei_reset_lesson_button();
3757
+				sensei_reset_lesson_button();
3758 3758
 
3759
-            } // End If Statement
3760
-            ?>
3759
+			} // End If Statement
3760
+			?>
3761 3761
 
3762 3762
         </footer>
3763 3763
 
3764 3764
         <?php
3765
-    } // End sensei_lesson_quiz_meta()
3765
+	} // End sensei_lesson_quiz_meta()
3766 3766
 
3767
-    /**
3768
-     * Show the lesson comments. This should be used in the loop.
3769
-     *
3770
-     * @since 1.9.0
3771
-     */
3772
-    public static function output_comments(){
3767
+	/**
3768
+	 * Show the lesson comments. This should be used in the loop.
3769
+	 *
3770
+	 * @since 1.9.0
3771
+	 */
3772
+	public static function output_comments(){
3773 3773
 
3774
-        if( ! is_user_logged_in() ){
3775
-            return;
3776
-        }
3774
+		if( ! is_user_logged_in() ){
3775
+			return;
3776
+		}
3777 3777
 
3778
-        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3779
-        $course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3780
-        $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3781
-        $user_taking_course = Sensei_Utils::user_started_course($course_id );
3778
+		$pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3779
+		$course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3780
+		$allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3781
+		$user_taking_course = Sensei_Utils::user_started_course($course_id );
3782 3782
 
3783
-        $lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3783
+		$lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3784 3784
 
3785
-        if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3785
+		if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3786 3786
 
3787
-            comments_template();
3787
+			comments_template();
3788 3788
 
3789
-        } // End If Statement
3789
+		} // End If Statement
3790 3790
 
3791
-    } //output_comments
3791
+	} //output_comments
3792 3792
 
3793
-    /**
3794
-     * Display the leeson quiz status if it should be shown
3795
-     *
3796
-     * @param int $lesson_id defaults to the global lesson id
3797
-     * @param int $user_id defaults to the current user id
3798
-     *
3799
-     * @since 1.9.0
3800
-     */
3801
-    public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3793
+	/**
3794
+	 * Display the leeson quiz status if it should be shown
3795
+	 *
3796
+	 * @param int $lesson_id defaults to the global lesson id
3797
+	 * @param int $user_id defaults to the current user id
3798
+	 *
3799
+	 * @since 1.9.0
3800
+	 */
3801
+	public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3802 3802
 
3803
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3804
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3805
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3806
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3807
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3803
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3804
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3805
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3806
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3807
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3808 3808
 
3809 3809
 
3810
-        if ( $quiz_id && is_user_logged_in()
3811
-            && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3810
+		if ( $quiz_id && is_user_logged_in()
3811
+			&& Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3812 3812
 
3813
-            $no_quiz_count = 0;
3814
-            $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3813
+			$no_quiz_count = 0;
3814
+			$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3815 3815
 
3816
-            // Display lesson quiz status message
3817
-            if ( $has_user_completed_lesson || $has_quiz_questions ) {
3818
-                $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3819
-                echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3820
-                if( $has_quiz_questions ) {
3821
-                   // echo $status['extra'];
3822
-                } // End If Statement
3823
-            } // End If Statement
3816
+			// Display lesson quiz status message
3817
+			if ( $has_user_completed_lesson || $has_quiz_questions ) {
3818
+				$status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3819
+				echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3820
+				if( $has_quiz_questions ) {
3821
+				   // echo $status['extra'];
3822
+				} // End If Statement
3823
+			} // End If Statement
3824 3824
 
3825
-        }
3825
+		}
3826 3826
 
3827
-    }
3827
+	}
3828 3828
 
3829
-    /**
3830
-     * On the lesson archive limit the number of words the show up if the access settings are enabled
3831
-     *
3832
-     * @since 1.9.0
3833
-     * @param $content
3834
-     * @return string
3835
-     */
3836
-    public static function limit_archive_content ( $content ){
3829
+	/**
3830
+	 * On the lesson archive limit the number of words the show up if the access settings are enabled
3831
+	 *
3832
+	 * @since 1.9.0
3833
+	 * @param $content
3834
+	 * @return string
3835
+	 */
3836
+	public static function limit_archive_content ( $content ){
3837 3837
 
3838
-        if( is_archive('lesson') && Sensei()->settings->get('access_permission') ){
3838
+		if( is_archive('lesson') && Sensei()->settings->get('access_permission') ){
3839 3839
 
3840
-            return wp_trim_words( $content, $num_words = 30, $more = '…' );
3841
-        }
3840
+			return wp_trim_words( $content, $num_words = 30, $more = '…' );
3841
+		}
3842 3842
 
3843
-        return $content;
3843
+		return $content;
3844 3844
 
3845
-    } // end limit_archive_content
3845
+	} // end limit_archive_content
3846 3846
 
3847
-    /**
3848
-     * Returns all publised lesson ID's
3849
-     *
3850
-     * @since 1.9.0
3851
-     * @return array
3852
-     */
3853
-    public static function get_all_lesson_ids(){
3847
+	/**
3848
+	 * Returns all publised lesson ID's
3849
+	 *
3850
+	 * @since 1.9.0
3851
+	 * @return array
3852
+	 */
3853
+	public static function get_all_lesson_ids(){
3854 3854
 
3855
-        return get_posts( array(
3856
-            'post_type'=>'lesson',
3857
-            'fields'=>'ids',
3858
-            'post_status' => 'publish',
3859
-            'numberposts' => 4000, // legacy support
3860
-            'post_per_page' => 4000
3861
-        ));
3855
+		return get_posts( array(
3856
+			'post_type'=>'lesson',
3857
+			'fields'=>'ids',
3858
+			'post_status' => 'publish',
3859
+			'numberposts' => 4000, // legacy support
3860
+			'post_per_page' => 4000
3861
+		));
3862 3862
 
3863
-    }
3863
+	}
3864 3864
 
3865 3865
 } // End Class
3866 3866
 
Please login to merge, or discard this patch.
Spacing   +1100 added lines, -1100 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 Lessons Class
@@ -19,83 +19,83 @@  discard block
 block discarded – undo
19 19
 	 * Constructor.
20 20
 	 * @since  1.0.0
21 21
 	 */
22
-	public function __construct () {
22
+	public function __construct() {
23 23
 
24 24
         $this->token = 'lesson';
25 25
 
26 26
 		// Setup meta fields for this post type
27
-		$this->meta_fields = array( 'lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed' );
27
+		$this->meta_fields = array('lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed');
28 28
 
29 29
         $this->question_order = '';
30 30
 
31 31
 		// Admin actions
32
-		if ( is_admin() ) {
32
+		if (is_admin()) {
33 33
 
34 34
 			// Metabox functions
35
-			add_action( 'admin_menu', array( $this, 'meta_box_setup' ), 20 );
36
-			add_action( 'save_post', array( $this, 'meta_box_save' ) );
37
-			add_action( 'save_post', array( $this, 'quiz_update' ) );
35
+			add_action('admin_menu', array($this, 'meta_box_setup'), 20);
36
+			add_action('save_post', array($this, 'meta_box_save'));
37
+			add_action('save_post', array($this, 'quiz_update'));
38 38
 
39 39
 			// Custom Write Panel Columns
40
-			add_filter( 'manage_edit-lesson_columns', array( $this, 'add_column_headings' ), 10, 1 );
41
-			add_action( 'manage_posts_custom_column', array( $this, 'add_column_data' ), 10, 2 );
40
+			add_filter('manage_edit-lesson_columns', array($this, 'add_column_headings'), 10, 1);
41
+			add_action('manage_posts_custom_column', array($this, 'add_column_data'), 10, 2);
42 42
 
43 43
 			// Add/Update question
44
-			add_action( 'wp_ajax_lesson_update_question', array( $this, 'lesson_update_question' ) );
45
-			add_action( 'wp_ajax_nopriv_lesson_update_question', array( $this, 'lesson_update_question' ) );
44
+			add_action('wp_ajax_lesson_update_question', array($this, 'lesson_update_question'));
45
+			add_action('wp_ajax_nopriv_lesson_update_question', array($this, 'lesson_update_question'));
46 46
 
47 47
 			// Add course
48
-			add_action( 'wp_ajax_lesson_add_course', array( $this, 'lesson_add_course' ) );
49
-			add_action( 'wp_ajax_nopriv_lesson_add_course', array( $this, 'lesson_add_course' ) );
48
+			add_action('wp_ajax_lesson_add_course', array($this, 'lesson_add_course'));
49
+			add_action('wp_ajax_nopriv_lesson_add_course', array($this, 'lesson_add_course'));
50 50
 
51 51
 			// Update grade type
52
-			add_action( 'wp_ajax_lesson_update_grade_type', array( $this, 'lesson_update_grade_type' ) );
53
-			add_action( 'wp_ajax_nopriv_lesson_update_grade_type', array( $this, 'lesson_update_grade_type' ) );
52
+			add_action('wp_ajax_lesson_update_grade_type', array($this, 'lesson_update_grade_type'));
53
+			add_action('wp_ajax_nopriv_lesson_update_grade_type', array($this, 'lesson_update_grade_type'));
54 54
 
55 55
 			// Update question order
56
-			add_action( 'wp_ajax_lesson_update_question_order', array( $this, 'lesson_update_question_order' ) );
57
-			add_action( 'wp_ajax_nopriv_lesson_update_question_order', array( $this, 'lesson_update_question_order' ) );
56
+			add_action('wp_ajax_lesson_update_question_order', array($this, 'lesson_update_question_order'));
57
+			add_action('wp_ajax_nopriv_lesson_update_question_order', array($this, 'lesson_update_question_order'));
58 58
 
59 59
 			//Update question order
60
-			add_action( 'wp_ajax_lesson_update_question_order_random', array( $this, 'lesson_update_question_order_random' ) );
61
-			add_action( 'wp_ajax_nopriv_lesson_update_question_order_random', array( $this, 'lesson_update_question_order_random' ) );
60
+			add_action('wp_ajax_lesson_update_question_order_random', array($this, 'lesson_update_question_order_random'));
61
+			add_action('wp_ajax_nopriv_lesson_update_question_order_random', array($this, 'lesson_update_question_order_random'));
62 62
 
63 63
 			// Get answer ID
64
-			add_action( 'wp_ajax_question_get_answer_id', array( $this, 'question_get_answer_id' ) );
65
-			add_action( 'wp_ajax_nopriv_question_get_answer_id', array( $this, 'question_get_answer_id' ) );
64
+			add_action('wp_ajax_question_get_answer_id', array($this, 'question_get_answer_id'));
65
+			add_action('wp_ajax_nopriv_question_get_answer_id', array($this, 'question_get_answer_id'));
66 66
 
67 67
 			// Add multiple questions
68
-			add_action( 'wp_ajax_lesson_add_multiple_questions', array( $this, 'lesson_add_multiple_questions' ) );
69
-			add_action( 'wp_ajax_nopriv_lesson_add_multiple_questions', array( $this, 'lesson_add_multiple_questions' ) );
68
+			add_action('wp_ajax_lesson_add_multiple_questions', array($this, 'lesson_add_multiple_questions'));
69
+			add_action('wp_ajax_nopriv_lesson_add_multiple_questions', array($this, 'lesson_add_multiple_questions'));
70 70
 
71 71
 			// Remove multiple questions
72
-			add_action( 'wp_ajax_lesson_remove_multiple_questions', array( $this, 'lesson_remove_multiple_questions' ) );
73
-			add_action( 'wp_ajax_nopriv_lesson_remove_multiple_questions', array( $this, 'lesson_remove_multiple_questions' ) );
72
+			add_action('wp_ajax_lesson_remove_multiple_questions', array($this, 'lesson_remove_multiple_questions'));
73
+			add_action('wp_ajax_nopriv_lesson_remove_multiple_questions', array($this, 'lesson_remove_multiple_questions'));
74 74
 
75 75
 			// Get question category limit
76
-			add_action( 'wp_ajax_get_question_category_limit', array( $this, 'get_question_category_limit' ) );
77
-			add_action( 'wp_ajax_nopriv_get_question_category_limit', array( $this, 'get_question_category_limit' ) );
76
+			add_action('wp_ajax_get_question_category_limit', array($this, 'get_question_category_limit'));
77
+			add_action('wp_ajax_nopriv_get_question_category_limit', array($this, 'get_question_category_limit'));
78 78
 
79 79
 			// Add existing questions
80
-			add_action( 'wp_ajax_lesson_add_existing_questions', array( $this, 'lesson_add_existing_questions' ) );
81
-			add_action( 'wp_ajax_nopriv_lesson_add_existing_questions', array( $this, 'lesson_add_existing_questions' ) );
80
+			add_action('wp_ajax_lesson_add_existing_questions', array($this, 'lesson_add_existing_questions'));
81
+			add_action('wp_ajax_nopriv_lesson_add_existing_questions', array($this, 'lesson_add_existing_questions'));
82 82
 
83 83
 			// Filter existing questions
84
-			add_action( 'wp_ajax_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
85
-			add_action( 'wp_ajax_nopriv_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
84
+			add_action('wp_ajax_filter_existing_questions', array($this, 'quiz_panel_filter_existing_questions'));
85
+			add_action('wp_ajax_nopriv_filter_existing_questions', array($this, 'quiz_panel_filter_existing_questions'));
86 86
 
87 87
             // output bulk edit fields
88
-            add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
89
-            add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
88
+            add_action('bulk_edit_custom_box', array($this, 'all_lessons_edit_fields'), 10, 2);
89
+            add_action('quick_edit_custom_box', array($this, 'all_lessons_edit_fields'), 10, 2);
90 90
 
91 91
             // load quick edit default values
92
-            add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2);
92
+            add_action('manage_lesson_posts_custom_column', array($this, 'set_quick_edit_admin_defaults'), 11, 2);
93 93
 
94 94
             // save bulk edit fields
95
-            add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) );
95
+            add_action('wp_ajax_save_bulk_edit_book', array($this, 'save_all_lessons_edit_fields'));
96 96
 
97 97
             // flush rewrite rules when saving a lesson
98
-            add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) );
98
+            add_action('save_post', array(__CLASS__, 'flush_rewrite_rules'));
99 99
 
100 100
 		} else {
101 101
 			// Frontend actions
@@ -108,34 +108,34 @@  discard block
 block discarded – undo
108 108
 	 * @access public
109 109
 	 * @return void
110 110
 	 */
111
-	public function meta_box_setup () {
111
+	public function meta_box_setup() {
112 112
 
113 113
 		// Add Meta Box for Prerequisite Lesson
114
-		add_meta_box( 'lesson-prerequisite', __( 'Lesson Prerequisite', 'woothemes-sensei' ), array( $this, 'lesson_prerequisite_meta_box_content' ), $this->token, 'side', 'default' );
114
+		add_meta_box('lesson-prerequisite', __('Lesson Prerequisite', 'woothemes-sensei'), array($this, 'lesson_prerequisite_meta_box_content'), $this->token, 'side', 'default');
115 115
 
116 116
 		// Add Meta Box for Lesson Course
117
-		add_meta_box( 'lesson-course', __( 'Lesson Course', 'woothemes-sensei' ), array( $this, 'lesson_course_meta_box_content' ), $this->token, 'side', 'default' );
117
+		add_meta_box('lesson-course', __('Lesson Course', 'woothemes-sensei'), array($this, 'lesson_course_meta_box_content'), $this->token, 'side', 'default');
118 118
 
119 119
 		// Add Meta Box for Lesson Preview
120
-		add_meta_box( 'lesson-preview', __( 'Lesson Preview', 'woothemes-sensei' ), array( $this, 'lesson_preview_meta_box_content' ), $this->token, 'side', 'default' );
120
+		add_meta_box('lesson-preview', __('Lesson Preview', 'woothemes-sensei'), array($this, 'lesson_preview_meta_box_content'), $this->token, 'side', 'default');
121 121
 
122 122
 		// Add Meta Box for Lesson Information
123
-		add_meta_box( 'lesson-info', __( 'Lesson Information', 'woothemes-sensei' ), array( $this, 'lesson_info_meta_box_content' ), $this->token, 'normal', 'default' );
123
+		add_meta_box('lesson-info', __('Lesson Information', 'woothemes-sensei'), array($this, 'lesson_info_meta_box_content'), $this->token, 'normal', 'default');
124 124
 
125 125
 		// Add Meta Box for Quiz Settings
126
-		add_meta_box( 'lesson-quiz-settings', __( 'Quiz Settings', 'woothemes-sensei' ), array( $this, 'lesson_quiz_settings_meta_box_content' ), $this->token, 'normal', 'default' );
126
+		add_meta_box('lesson-quiz-settings', __('Quiz Settings', 'woothemes-sensei'), array($this, 'lesson_quiz_settings_meta_box_content'), $this->token, 'normal', 'default');
127 127
 
128 128
 		// Add Meta Box for Lesson Quiz Questions
129
-		add_meta_box( 'lesson-quiz', __( 'Quiz Questions', 'woothemes-sensei' ), array( $this, 'lesson_quiz_meta_box_content' ), $this->token, 'normal', 'default' );
129
+		add_meta_box('lesson-quiz', __('Quiz Questions', 'woothemes-sensei'), array($this, 'lesson_quiz_meta_box_content'), $this->token, 'normal', 'default');
130 130
 
131 131
 		// Remove "Custom Settings" meta box.
132
-		remove_meta_box( 'woothemes-settings', $this->token, 'normal' );
132
+		remove_meta_box('woothemes-settings', $this->token, 'normal');
133 133
 
134 134
 		// Add JS scripts
135
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
135
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
136 136
 
137 137
 		// Add CSS
138
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
138
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_styles'));
139 139
 
140 140
 	} // End meta_box_setup()
141 141
 
@@ -146,30 +146,30 @@  discard block
 block discarded – undo
146 146
 	 * @access public
147 147
 	 * @return void
148 148
 	 */
149
-	public function lesson_info_meta_box_content () {
149
+	public function lesson_info_meta_box_content() {
150 150
 		global $post;
151 151
 
152
-		$lesson_length = get_post_meta( $post->ID, '_lesson_length', true );
153
-		$lesson_complexity = get_post_meta( $post->ID, '_lesson_complexity', true );
152
+		$lesson_length = get_post_meta($post->ID, '_lesson_length', true);
153
+		$lesson_complexity = get_post_meta($post->ID, '_lesson_complexity', true);
154 154
 		$complexity_array = $this->lesson_complexities();
155
-		$lesson_video_embed = get_post_meta( $post->ID, '_lesson_video_embed', true );
155
+		$lesson_video_embed = get_post_meta($post->ID, '_lesson_video_embed', true);
156 156
 
157 157
 		$html = '';
158 158
 		// Lesson Length
159
-		$html .= '<p><label for="lesson_length">' . __( 'Lesson Length in minutes', 'woothemes-sensei' ) . ': </label>';
160
-		$html .= '<input type="number" id="lesson-length" name="lesson_length" class="small-text" value="' . esc_attr( $lesson_length ) . '" /></p>' . "\n";
159
+		$html .= '<p><label for="lesson_length">'.__('Lesson Length in minutes', 'woothemes-sensei').': </label>';
160
+		$html .= '<input type="number" id="lesson-length" name="lesson_length" class="small-text" value="'.esc_attr($lesson_length).'" /></p>'."\n";
161 161
 		// Lesson Complexity
162
-		$html .= '<p><label for="lesson_complexity">' . __( 'Lesson Complexity', 'woothemes-sensei' ) . ': </label>';
162
+		$html .= '<p><label for="lesson_complexity">'.__('Lesson Complexity', 'woothemes-sensei').': </label>';
163 163
 		$html .= '<select id="lesson-complexity-options" name="lesson_complexity" class="chosen_select lesson-complexity-select">';
164
-			$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
165
-			foreach ($complexity_array as $key => $value){
166
-				$html .= '<option value="' . esc_attr( $key ) . '"' . selected( $key, $lesson_complexity, false ) . '>' . esc_html( $value ) . '</option>' . "\n";
164
+			$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
165
+			foreach ($complexity_array as $key => $value) {
166
+				$html .= '<option value="'.esc_attr($key).'"'.selected($key, $lesson_complexity, false).'>'.esc_html($value).'</option>'."\n";
167 167
 			} // End For Loop
168
-		$html .= '</select></p>' . "\n";
168
+		$html .= '</select></p>'."\n";
169 169
 
170
-		$html .= '<p><label for="lesson_video_embed">' . __( 'Video Embed Code', 'woothemes-sensei' ) . ':</label><br/>' . "\n";
171
-		$html .= '<textarea rows="5" cols="50" name="lesson_video_embed" tabindex="6" id="course-video-embed">' . $lesson_video_embed . '</textarea></p>' . "\n";
172
-		$html .= '<p>' .  __( 'Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei' ) . '</p>';
170
+		$html .= '<p><label for="lesson_video_embed">'.__('Video Embed Code', 'woothemes-sensei').':</label><br/>'."\n";
171
+		$html .= '<textarea rows="5" cols="50" name="lesson_video_embed" tabindex="6" id="course-video-embed">'.$lesson_video_embed.'</textarea></p>'."\n";
172
+		$html .= '<p>'.__('Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei').'</p>';
173 173
 
174 174
 		echo $html;
175 175
 
@@ -181,31 +181,31 @@  discard block
 block discarded – undo
181 181
 	 * @access public
182 182
 	 * @return void
183 183
 	 */
184
-	public function lesson_prerequisite_meta_box_content () {
184
+	public function lesson_prerequisite_meta_box_content() {
185 185
 		global $post;
186 186
 		// Get existing post meta
187
-		$select_lesson_prerequisite = get_post_meta( $post->ID, '_lesson_prerequisite', true );
187
+		$select_lesson_prerequisite = get_post_meta($post->ID, '_lesson_prerequisite', true);
188 188
 		// Get the Lesson Posts
189
-		$post_args = array(	'post_type' 		=> 'lesson',
189
+		$post_args = array('post_type' 		=> 'lesson',
190 190
 							'posts_per_page' 		=> -1,
191 191
 							'orderby'         	=> 'title',
192 192
     						'order'           	=> 'ASC',
193 193
     						'exclude' 			=> $post->ID,
194 194
 							'suppress_filters' 	=> 0
195 195
 							);
196
-		$posts_array = get_posts( $post_args );
196
+		$posts_array = get_posts($post_args);
197 197
 		// Build the HTML to Output
198 198
 		$html = '';
199
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
200
-		if ( count( $posts_array ) > 0 ) {
201
-			$html .= '<select id="lesson-prerequisite-options" name="lesson_prerequisite" class="chosen_select widefat">' . "\n";
202
-			$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
203
-				foreach ($posts_array as $post_item){
204
-					$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_lesson_prerequisite, false ) . '>' . esc_html( $post_item->post_title ) . '</option>' . "\n";
199
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
200
+		if (count($posts_array) > 0) {
201
+			$html .= '<select id="lesson-prerequisite-options" name="lesson_prerequisite" class="chosen_select widefat">'."\n";
202
+			$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
203
+				foreach ($posts_array as $post_item) {
204
+					$html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_lesson_prerequisite, false).'>'.esc_html($post_item->post_title).'</option>'."\n";
205 205
 				} // End For Loop
206
-			$html .= '</select>' . "\n";
206
+			$html .= '</select>'."\n";
207 207
 		} else {
208
-			$html .= '<p>' . esc_html( __( 'No lessons exist yet. Please add some first.', 'woothemes-sensei' ) ) . '</p>';
208
+			$html .= '<p>'.esc_html(__('No lessons exist yet. Please add some first.', 'woothemes-sensei')).'</p>';
209 209
 		} // End If Statement
210 210
 		// Output the HTML
211 211
 		echo $html;
@@ -217,20 +217,20 @@  discard block
 block discarded – undo
217 217
 	 * @access public
218 218
 	 * @return void
219 219
 	 */
220
-	public function lesson_preview_meta_box_content () {
220
+	public function lesson_preview_meta_box_content() {
221 221
 		global $post;
222 222
 		// Get existing post meta
223
-		$lesson_preview = get_post_meta( $post->ID, '_lesson_preview', true );
223
+		$lesson_preview = get_post_meta($post->ID, '_lesson_preview', true);
224 224
 		$html = '';
225
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
225
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
226 226
 
227 227
 		$checked = '';
228
-		if ( isset( $lesson_preview ) && ( '' != $lesson_preview ) ) {
229
-	 	    $checked = checked( 'preview', $lesson_preview, false );
228
+		if (isset($lesson_preview) && ('' != $lesson_preview)) {
229
+	 	    $checked = checked('preview', $lesson_preview, false);
230 230
 	 	} // End If Statement
231 231
 
232 232
 	 	$html .= '<label for="lesson_preview">';
233
-	 	$html .= '<input type="checkbox" id="lesson_preview" name="lesson_preview" value="preview" ' . $checked . '>&nbsp;' . __( 'Allow this lesson to be viewed without purchase/login', 'woothemes-sensei' ) . '<br>';
233
+	 	$html .= '<input type="checkbox" id="lesson_preview" name="lesson_preview" value="preview" '.$checked.'>&nbsp;'.__('Allow this lesson to be viewed without purchase/login', 'woothemes-sensei').'<br>';
234 234
 
235 235
 		// Output the HTML
236 236
 		echo $html;
@@ -243,32 +243,32 @@  discard block
 block discarded – undo
243 243
 	 * @param int $post_id
244 244
 	 * @return integer $post_id
245 245
 	 */
246
-	public function meta_box_save ( $post_id ) {
246
+	public function meta_box_save($post_id) {
247 247
 
248 248
 		// Verify the nonce before proceeding.
249
-		if ( ( get_post_type( $post_id ) != $this->token ) || !isset(   $_POST[ 'woo_' . $this->token . '_nonce'] )  || ! wp_verify_nonce( $_POST[ 'woo_' . $this->token . '_nonce' ], 'sensei-save-post-meta' ) ) {
249
+		if ((get_post_type($post_id) != $this->token) || ! isset($_POST['woo_'.$this->token.'_nonce']) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_nonce'], 'sensei-save-post-meta')) {
250 250
 			return $post_id;
251 251
 		} // End If Statement
252 252
 		// Get the post type object.
253
-		$post_type = get_post_type_object( get_post_type( $post_id ) );
253
+		$post_type = get_post_type_object(get_post_type($post_id));
254 254
 		// Check if the current user has permission to edit the post.
255
-		if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) {
255
+		if ( ! current_user_can($post_type->cap->edit_post, $post_id)) {
256 256
 			return $post_id;
257 257
 		} // End If Statement
258 258
 		// Check if the current post type is a page
259
-		if ( 'page' == $_POST[ 'post_type' ] ) {
260
-			if ( ! current_user_can( 'edit_page', $post_id ) ) {
259
+		if ('page' == $_POST['post_type']) {
260
+			if ( ! current_user_can('edit_page', $post_id)) {
261 261
 				return $post_id;
262 262
 			} // End If Statement
263 263
 		} else {
264
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
264
+			if ( ! current_user_can('edit_post', $post_id)) {
265 265
 				return $post_id;
266 266
 			} // End If Statement
267 267
 		} // End If Statement
268 268
 		// Save the post meta data fields
269
-		if ( isset($this->meta_fields) && is_array($this->meta_fields) ) {
270
-			foreach ( $this->meta_fields as $meta_key ) {
271
-				$this->save_post_meta( $meta_key, $post_id );
269
+		if (isset($this->meta_fields) && is_array($this->meta_fields)) {
270
+			foreach ($this->meta_fields as $meta_key) {
271
+				$this->save_post_meta($meta_key, $post_id);
272 272
 			} // End For Loop
273 273
 		} // End If Statement
274 274
 	} // End meta_box_save()
@@ -280,37 +280,37 @@  discard block
 block discarded – undo
280 280
 	 * @access public
281 281
 	 * @return integer|boolean $post_id or false
282 282
 	 */
283
-	public function quiz_update( $post_id ) {
283
+	public function quiz_update($post_id) {
284 284
 		global $post;
285 285
 		// Verify the nonce before proceeding.
286
-		if ( ( 'lesson' != get_post_type( $post_id ) )|| !isset(   $_POST[ 'woo_' . $this->token . '_nonce'] )  || ! wp_verify_nonce( $_POST[ 'woo_' . $this->token . '_nonce' ], 'sensei-save-post-meta') ) {
287
-			if ( isset($post->ID) ) {
286
+		if (('lesson' != get_post_type($post_id)) || ! isset($_POST['woo_'.$this->token.'_nonce']) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_nonce'], 'sensei-save-post-meta')) {
287
+			if (isset($post->ID)) {
288 288
 				return $post->ID;
289 289
 			} else {
290 290
 				return false;
291 291
 			} // End If Statement
292 292
 		} // End If Statement
293 293
 
294
-		if( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
294
+		if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
295 295
 			return false;
296 296
 		}
297 297
 
298 298
 		// Temporarily disable the filter
299
-        remove_action( 'save_post', array( $this, 'quiz_update' ) );
299
+        remove_action('save_post', array($this, 'quiz_update'));
300 300
 		// Save the Quiz
301
-		$quiz_id = $this->lesson_quizzes( $post_id, 'any');
301
+		$quiz_id = $this->lesson_quizzes($post_id, 'any');
302 302
 
303 303
 		 // Sanitize and setup the post data
304
-		$_POST = stripslashes_deep( $_POST );
305
-		if ( isset( $_POST[ 'quiz_id' ] ) && ( 0 < absint( $_POST[ 'quiz_id' ] ) ) ) {
306
-			$quiz_id = absint( $_POST[ 'quiz_id' ] );
304
+		$_POST = stripslashes_deep($_POST);
305
+		if (isset($_POST['quiz_id']) && (0 < absint($_POST['quiz_id']))) {
306
+			$quiz_id = absint($_POST['quiz_id']);
307 307
 		} // End If Statement
308
-		$post_title = esc_html( $_POST[ 'post_title' ] );
309
-		$post_status = esc_html( $_POST[ 'post_status' ] );
308
+		$post_title = esc_html($_POST['post_title']);
309
+		$post_status = esc_html($_POST['post_status']);
310 310
 		$post_content = '';
311 311
 
312 312
 		// Setup Query Arguments
313
-		$post_type_args = array(	'post_content' => $post_content,
313
+		$post_type_args = array('post_content' => $post_content,
314 314
   		    						'post_status' => $post_status,
315 315
   		    						'post_title' => $post_title,
316 316
   		    						'post_type' => 'quiz',
@@ -320,84 +320,84 @@  discard block
 block discarded – undo
320 320
 		$settings = $this->get_quiz_settings();
321 321
 
322 322
   		// Update or Insert the Lesson Quiz
323
-		if ( 0 < $quiz_id ) {
323
+		if (0 < $quiz_id) {
324 324
 			// Update the Quiz
325
-			$post_type_args[ 'ID' ] = $quiz_id;
325
+			$post_type_args['ID'] = $quiz_id;
326 326
 		    wp_update_post($post_type_args);
327 327
 
328 328
 		    // Update the post meta data
329
-		    update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
329
+		    update_post_meta($quiz_id, '_quiz_lesson', $post_id);
330 330
 
331
-		    foreach( $settings as $field ) {
332
-		    	if( 'random_question_order' != $field['id'] ) {
333
-			    	$value = $this->get_submitted_setting_value( $field );
334
-			    	if( isset( $value ) ) {
335
-			    		update_post_meta( $quiz_id, '_' . $field['id'], $value );
331
+		    foreach ($settings as $field) {
332
+		    	if ('random_question_order' != $field['id']) {
333
+			    	$value = $this->get_submitted_setting_value($field);
334
+			    	if (isset($value)) {
335
+			    		update_post_meta($quiz_id, '_'.$field['id'], $value);
336 336
 			    	}
337 337
 			    }
338 338
 		    }
339 339
 
340 340
 		    // Set the post terms for quiz-type
341
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
341
+		    wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type');
342 342
 		} else {
343 343
 			// Create the Quiz
344 344
 		    $quiz_id = wp_insert_post($post_type_args);
345 345
 
346 346
 		    // Add the post meta data WP will add it if it doesn't exist
347
-            update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
347
+            update_post_meta($quiz_id, '_quiz_lesson', $post_id);
348 348
 
349
-		    foreach( $settings as $field ) {
350
-		    	if( 'random_question_order' != $field['id'] ) {
349
+		    foreach ($settings as $field) {
350
+		    	if ('random_question_order' != $field['id']) {
351 351
 
352 352
                     //ignore values not posted to avoid
353 353
                     // overwriting with empty or default values
354 354
                     // when the values are posted from bulk edit or quick edit
355
-                    if( !isset( $_POST[ $field['id'] ] ) ){
355
+                    if ( ! isset($_POST[$field['id']])) {
356 356
                         continue;
357 357
                     }
358 358
 
359
-			    	$value = $this->get_submitted_setting_value( $field );
360
-			    	if( isset( $value ) ) {
361
-			    		add_post_meta( $quiz_id, '_' . $field['id'], $value );
359
+			    	$value = $this->get_submitted_setting_value($field);
360
+			    	if (isset($value)) {
361
+			    		add_post_meta($quiz_id, '_'.$field['id'], $value);
362 362
 			    	}
363 363
 			    }
364 364
 		    }
365 365
 
366 366
 		    // Set the post terms for quiz-type
367
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
367
+		    wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type');
368 368
 		} // End If Statement
369 369
 
370 370
 		// Add default lesson order meta value
371
-		$course_id = get_post_meta( $post_id, '_lesson_course', true );
372
-		if( $course_id ) {
373
-			if( ! get_post_meta( $post_id, '_order_' . $course_id, true ) ) {
374
-				update_post_meta( $post_id, '_order_' . $course_id, 0 );
371
+		$course_id = get_post_meta($post_id, '_lesson_course', true);
372
+		if ($course_id) {
373
+			if ( ! get_post_meta($post_id, '_order_'.$course_id, true)) {
374
+				update_post_meta($post_id, '_order_'.$course_id, 0);
375 375
 			}
376 376
 		}
377 377
 		// Add reference back to the Quiz
378
-		update_post_meta( $post_id, '_lesson_quiz', $quiz_id );
378
+		update_post_meta($post_id, '_lesson_quiz', $quiz_id);
379 379
 		// Mark if the Lesson Quiz has questions
380
-		$quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
381
-		if( 0 < count( $quiz_questions ) ) {
382
-			update_post_meta( $post_id, '_quiz_has_questions', '1' );
380
+		$quiz_questions = Sensei()->lesson->lesson_quiz_questions($quiz_id);
381
+		if (0 < count($quiz_questions)) {
382
+			update_post_meta($post_id, '_quiz_has_questions', '1');
383 383
 		}
384 384
 		else {
385
-			delete_post_meta( $post_id, '_quiz_has_questions' );
385
+			delete_post_meta($post_id, '_quiz_has_questions');
386 386
 		}
387 387
 
388 388
 		// Restore the previously disabled filter
389
-        add_action( 'save_post', array( $this, 'quiz_update' ) );
389
+        add_action('save_post', array($this, 'quiz_update'));
390 390
 
391 391
 	} // End post_updated()
392 392
 
393
-	public function get_submitted_setting_value( $field = false ) {
393
+	public function get_submitted_setting_value($field = false) {
394 394
 
395
-		if( ! $field ) return;
395
+		if ( ! $field) return;
396 396
 
397 397
 		$value = false;
398 398
 
399
-		if( 'quiz_grade_type' == $field['id'] ) {
400
-			if( isset( $_POST[ $field['id'] ] ) && 'on' == $_POST[ $field['id'] ] ) {
399
+		if ('quiz_grade_type' == $field['id']) {
400
+			if (isset($_POST[$field['id']]) && 'on' == $_POST[$field['id']]) {
401 401
 				$value = 'auto';
402 402
 			} else {
403 403
 				$value = 'manual';
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
 			return $value;
406 406
 		}
407 407
 
408
-		if ( isset( $_POST[ $field['id'] ] ) ) {
409
-			$value = $_POST[ $field['id'] ];
408
+		if (isset($_POST[$field['id']])) {
409
+			$value = $_POST[$field['id']];
410 410
 		} else {
411 411
 			$value = $field['default'];
412 412
 		}
@@ -422,18 +422,18 @@  discard block
 block discarded – undo
422 422
 	 * @param int $post_id (default: 0)
423 423
 	 * @return int|bool meta id or saved status
424 424
 	 */
425
-	private function save_post_meta( $post_key = '', $post_id = 0 ) {
425
+	private function save_post_meta($post_key = '', $post_id = 0) {
426 426
 		// Get the meta key.
427
-		$meta_key = '_' . $post_key;
427
+		$meta_key = '_'.$post_key;
428 428
 
429 429
         //ignore fields are not posted
430 430
 
431
-        if( !isset( $_POST[ $post_key ] ) ){
431
+        if ( ! isset($_POST[$post_key])) {
432 432
 
433 433
             // except for lesson preview checkbox field
434
-            if( 'lesson_preview' == $post_key ){
434
+            if ('lesson_preview' == $post_key) {
435 435
 
436
-                $_POST[ $post_key ] = '';
436
+                $_POST[$post_key] = '';
437 437
 
438 438
             } else {
439 439
 
@@ -444,15 +444,15 @@  discard block
 block discarded – undo
444 444
         }
445 445
 
446 446
 		// Get the posted data and sanitize it for use as an HTML class.
447
-		if ( 'lesson_video_embed' == $post_key) {
448
-			$new_meta_value = esc_html( $_POST[$post_key] );
447
+		if ('lesson_video_embed' == $post_key) {
448
+			$new_meta_value = esc_html($_POST[$post_key]);
449 449
 		} else {
450
-			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
450
+			$new_meta_value = (isset($_POST[$post_key]) ? sanitize_html_class($_POST[$post_key]) : '');
451 451
 		} // End If Statement
452 452
 
453 453
         // update field with the new value
454
-        if( -1 != $new_meta_value  ){
455
-            return update_post_meta( $post_id, $meta_key, $new_meta_value );
454
+        if ( -1 != $new_meta_value  ) {
455
+            return update_post_meta($post_id, $meta_key, $new_meta_value);
456 456
         }
457 457
 
458 458
 	} // End save_post_meta()
@@ -463,30 +463,30 @@  discard block
 block discarded – undo
463 463
 	 * @access public
464 464
 	 * @return void
465 465
 	 */
466
-	public function lesson_course_meta_box_content () {
466
+	public function lesson_course_meta_box_content() {
467 467
 		global $post;
468 468
 		// Setup Lesson Meta Data
469 469
 		$selected_lesson_course = 0;
470
-		if ( 0 < $post->ID ) {
471
-			$selected_lesson_course = get_post_meta( $post->ID, '_lesson_course', true );
470
+		if (0 < $post->ID) {
471
+			$selected_lesson_course = get_post_meta($post->ID, '_lesson_course', true);
472 472
 		} // End If Statement
473 473
 		// Handle preselected course
474
-		if ( isset( $_GET[ 'course_id' ] ) && ( 0 < absint( $_GET[ 'course_id' ] ) ) ) {
475
-			$selected_lesson_course = absint( $_GET[ 'course_id' ] );
474
+		if (isset($_GET['course_id']) && (0 < absint($_GET['course_id']))) {
475
+			$selected_lesson_course = absint($_GET['course_id']);
476 476
 		} // End If Statement
477 477
 		// Get the Lesson Posts
478
-		$post_args = array(	'post_type' 		=> 'course',
478
+		$post_args = array('post_type' 		=> 'course',
479 479
 							'posts_per_page' 		=> -1,
480 480
 							'orderby'         	=> 'title',
481 481
     						'order'           	=> 'ASC',
482 482
     						'post_status'      	=> 'any',
483 483
     						'suppress_filters' 	=> 0,
484 484
 							);
485
-		$posts_array = get_posts( $post_args );
485
+		$posts_array = get_posts($post_args);
486 486
 		// Buid the HTML to Output
487 487
 		$html = '';
488 488
 		// Nonce
489
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
489
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
490 490
 
491 491
         // Select the course for the lesson
492 492
         $drop_down_args = array(
@@ -496,67 +496,67 @@  discard block
 block discarded – undo
496 496
 
497 497
         $courses = WooThemes_Sensei_Course::get_all_courses();
498 498
         $courses_options = array();
499
-        foreach( $courses as $course ){
500
-            $courses_options[ $course->ID ] = get_the_title( $course ) ;
499
+        foreach ($courses as $course) {
500
+            $courses_options[$course->ID] = get_the_title($course);
501 501
         }
502
-        $html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args );
502
+        $html .= Sensei_Utils::generate_drop_down($selected_lesson_course, $courses_options, $drop_down_args);
503 503
 
504 504
         // Course Actions Panel
505
-		if ( current_user_can( 'publish_courses' )) {
505
+		if (current_user_can('publish_courses')) {
506 506
 				$html .= '<div id="lesson-course-actions">';
507 507
 					$html .= '<p>';
508 508
 						// Add a course action link
509
-						$html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ ' . __('Add New Course', 'woothemes-sensei' ) . '</a>';
509
+						$html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ '.__('Add New Course', 'woothemes-sensei').'</a>';
510 510
 					$html .= '</p>';
511 511
 				$html .= '</div>';
512 512
 				// Add a course input fields
513 513
 				$html .= '<div id="lesson-course-details" class="hidden">';
514 514
 					$html .= '<p>';
515 515
 						// Course Title input
516
-						$html .= '<label>' . __( 'Course Title' , 'woothemes-sensei' ) . '</label> ';
516
+						$html .= '<label>'.__('Course Title', 'woothemes-sensei').'</label> ';
517 517
 	  					$html .= '<input type="text" id="course-title" name="course_title" value="" size="25" class="widefat" />';
518 518
 	  					// Course Description input
519
-	  					$html .= '<label>' . __( 'Description' , 'woothemes-sensei' ) . '</label> ';
519
+	  					$html .= '<label>'.__('Description', 'woothemes-sensei').'</label> ';
520 520
 	  					$html .= '<textarea rows="10" cols="40" id="course-content" name="course_content" value="" size="300" class="widefat"></textarea>';
521 521
 	  					// Course Prerequisite
522
-	  					$html .= '<label>' . __( 'Course Prerequisite' , 'woothemes-sensei' ) . '</label> ';
523
-	  					$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n";
524
-							$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
525
-							foreach ($posts_array as $post_item){
526
-								$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '">' . esc_html( $post_item->post_title ) . '</option>' . "\n";
522
+	  					$html .= '<label>'.__('Course Prerequisite', 'woothemes-sensei').'</label> ';
523
+	  					$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">'."\n";
524
+							$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
525
+							foreach ($posts_array as $post_item) {
526
+								$html .= '<option value="'.esc_attr(absint($post_item->ID)).'">'.esc_html($post_item->post_title).'</option>'."\n";
527 527
 							} // End For Loop
528
-						$html .= '</select>' . "\n";
528
+						$html .= '</select>'."\n";
529 529
 						// Course Product
530
-                        if ( Sensei_WC::is_woocommerce_active() ) {
530
+                        if (Sensei_WC::is_woocommerce_active()) {
531 531
 	  						// Get the Products
532
-							$select_course_woocommerce_product = get_post_meta( $post_item->ID, '_course_woocommerce_product', true );
532
+							$select_course_woocommerce_product = get_post_meta($post_item->ID, '_course_woocommerce_product', true);
533 533
 
534
-							$product_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
534
+							$product_args = array('post_type' 		=> array('product', 'product_variation'),
535 535
 													'posts_per_page' 		=> -1,
536 536
 													'orderby'         	=> 'title',
537 537
 	    											'order'           	=> 'DESC',
538
-	    											'post_status'		=> array( 'publish', 'private', 'draft' ),
538
+	    											'post_status'		=> array('publish', 'private', 'draft'),
539 539
 	    											'tax_query'			=> array(
540 540
 														array(
541 541
 															'taxonomy'	=> 'product_type',
542 542
 															'field'		=> 'slug',
543
-															'terms'		=> array( 'variable', 'grouped' ),
543
+															'terms'		=> array('variable', 'grouped'),
544 544
 															'operator'	=> 'NOT IN'
545 545
 														)
546 546
 													),
547 547
 	    											'suppress_filters' 	=> 0
548 548
 													);
549
-							$products_array = get_posts( $product_args );
550
-							$html .= '<label>' . __( 'WooCommerce Product' , 'woothemes-sensei' ) . '</label> ';
551
-	  						$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n";
552
-								$html .= '<option value="-">' . __( 'None', 'woothemes-sensei' ) . '</option>';
549
+							$products_array = get_posts($product_args);
550
+							$html .= '<label>'.__('WooCommerce Product', 'woothemes-sensei').'</label> ';
551
+	  						$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">'."\n";
552
+								$html .= '<option value="-">'.__('None', 'woothemes-sensei').'</option>';
553 553
 								$prev_parent_id = 0;
554
-								foreach ($products_array as $products_item){
554
+								foreach ($products_array as $products_item) {
555 555
 
556
-									if ( 'product_variation' == $products_item->post_type ) {
557
-										$product_object = get_product( $products_item->ID );
558
-										$parent_id = wp_get_post_parent_id( $products_item->ID );
559
-										$product_name = ucwords( woocommerce_get_formatted_variation( $product_object->variation_data, true ) );
556
+									if ('product_variation' == $products_item->post_type) {
557
+										$product_object = get_product($products_item->ID);
558
+										$parent_id = wp_get_post_parent_id($products_item->ID);
559
+										$product_name = ucwords(woocommerce_get_formatted_variation($product_object->variation_data, true));
560 560
 									} else {
561 561
 										$parent_id = false;
562 562
 										$prev_parent_id = 0;
@@ -564,32 +564,32 @@  discard block
 block discarded – undo
564 564
 									}
565 565
 
566 566
 									// Show variations in groups
567
-									if( $parent_id && $parent_id != $prev_parent_id ) {
568
-										if( 0 != $prev_parent_id ) {
567
+									if ($parent_id && $parent_id != $prev_parent_id) {
568
+										if (0 != $prev_parent_id) {
569 569
 											$html .= '</optgroup>';
570 570
 										}
571
-										$html .= '<optgroup label="' . get_the_title( $parent_id ) . '">';
571
+										$html .= '<optgroup label="'.get_the_title($parent_id).'">';
572 572
 										$prev_parent_id = $parent_id;
573
-									} elseif( ! $parent_id && 0 == $prev_parent_id ) {
573
+									} elseif ( ! $parent_id && 0 == $prev_parent_id) {
574 574
 										$html .= '</optgroup>';
575 575
 									}
576 576
 
577
-									$html .= '<option value="' . esc_attr( absint( $products_item->ID ) ) . '">' . esc_html( $products_item->post_title ) . '</option>' . "\n";
577
+									$html .= '<option value="'.esc_attr(absint($products_item->ID)).'">'.esc_html($products_item->post_title).'</option>'."\n";
578 578
 								} // End For Loop
579
-							$html .= '</select>' . "\n";
579
+							$html .= '</select>'."\n";
580 580
 						} else {
581 581
 							// Default
582 582
 							$html .= '<input type="hidden" name="course_woocommerce_product" id="course-woocommerce-product-options" value="-" />';
583 583
 						}
584 584
 						// Course Category
585
-	  					$html .= '<label>' . __( 'Course Category' , 'woothemes-sensei' ) . '</label> ';
586
-	  					$cat_args = array( 'echo' => false, 'hierarchical' => true, 'show_option_none' => __( 'None', 'woothemes-sensei' ), 'taxonomy' => 'course-category', 'orderby' => 'name', 'id' => 'course-category-options', 'name' => 'course_category', 'class' => 'widefat' );
587
-						$html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args)) . "\n";
585
+	  					$html .= '<label>'.__('Course Category', 'woothemes-sensei').'</label> ';
586
+	  					$cat_args = array('echo' => false, 'hierarchical' => true, 'show_option_none' => __('None', 'woothemes-sensei'), 'taxonomy' => 'course-category', 'orderby' => 'name', 'id' => 'course-category-options', 'name' => 'course_category', 'class' => 'widefat');
587
+						$html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args))."\n";
588 588
 	  					// Save the course action button
589
-	  					$html .= '<a title="' . esc_attr( __( 'Save Course', 'woothemes-sensei' ) ) . '" href="#add-course-metadata" class="lesson_course_save button button-highlighted">' . esc_html( __( 'Add Course', 'woothemes-sensei' ) ) . '</a>';
589
+	  					$html .= '<a title="'.esc_attr(__('Save Course', 'woothemes-sensei')).'" href="#add-course-metadata" class="lesson_course_save button button-highlighted">'.esc_html(__('Add Course', 'woothemes-sensei')).'</a>';
590 590
 						$html .= '&nbsp;&nbsp;&nbsp;';
591 591
 						// Cancel action link
592
-						$html .= '<a href="#course-add-cancel" class="lesson_course_cancel">' . __( 'Cancel', 'woothemes-sensei' ) . '</a>';
592
+						$html .= '<a href="#course-add-cancel" class="lesson_course_cancel">'.__('Cancel', 'woothemes-sensei').'</a>';
593 593
 					$html .= '</p>';
594 594
 				$html .= '</div>';
595 595
 			} // End If Statement
@@ -598,20 +598,20 @@  discard block
 block discarded – undo
598 598
 		echo $html;
599 599
 	} // End lesson_course_meta_box_content()
600 600
 
601
-	public function quiz_panel( $quiz_id = 0 ) {
601
+	public function quiz_panel($quiz_id = 0) {
602 602
 
603
-		$html = wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
603
+		$html = wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
604 604
 		$html .= '<div id="add-quiz-main">';
605
-			if ( 0 == $quiz_id ) {
605
+			if (0 == $quiz_id) {
606 606
 				$html .= '<p>';
607 607
 					// Default message and Add a Quiz button
608
-					$html .= esc_html( __( 'Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei' ) );
608
+					$html .= esc_html(__('Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei'));
609 609
 				$html .= '</p>';
610 610
 			}
611 611
 
612 612
 			// Quiz Panel CSS Class
613 613
 			$quiz_class = '';
614
-			if ( 0 == $quiz_id ) {
614
+			if (0 == $quiz_id) {
615 615
 				$quiz_class = ' class="hidden"';
616 616
 			} // End If Statement
617 617
 			// Build the HTML to Output
@@ -619,15 +619,15 @@  discard block
 block discarded – undo
619 619
 
620 620
 			// Setup Questions Query
621 621
 			$questions = array();
622
-			if ( 0 < $quiz_id ) {
623
-				$questions = $this->lesson_quiz_questions( $quiz_id );
622
+			if (0 < $quiz_id) {
623
+				$questions = $this->lesson_quiz_questions($quiz_id);
624 624
 			} // End If Statement
625 625
 
626 626
 			$question_count = 0;
627
-			foreach( $questions as $question ) {
627
+			foreach ($questions as $question) {
628 628
 
629
-				if( $question->post_type == 'multiple_question' ) {
630
-					$question_number = get_post_meta( $question->ID, 'number', true );
629
+				if ($question->post_type == 'multiple_question') {
630
+					$question_number = get_post_meta($question->ID, 'number', true);
631 631
 					$question_count += $question_number;
632 632
 				} else {
633 633
 					++$question_count;
@@ -636,68 +636,68 @@  discard block
 block discarded – undo
636 636
 			}
637 637
 
638 638
 			// Inner DIV
639
-			$html .= '<div id="add-quiz-metadata"' . $quiz_class . '>';
639
+			$html .= '<div id="add-quiz-metadata"'.$quiz_class.'>';
640 640
 
641 641
 				// Quiz ID
642
-				$html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="' . esc_attr( $quiz_id ) . '" />';
642
+				$html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="'.esc_attr($quiz_id).'" />';
643 643
 
644 644
 				// Default Message
645
-				if ( 0 == $quiz_id ) {
645
+				if (0 == $quiz_id) {
646 646
 					$html .= '<p class="save-note">';
647
-						$html .= esc_html( __( 'Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei' ) );
647
+						$html .= esc_html(__('Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei'));
648 648
 					$html .= '</p>';
649 649
 				} // End If Statement
650 650
 
651 651
 			$html .= '</div>';
652 652
 
653 653
 			// Question Container DIV
654
-			$html .= '<div id="add-question-main"' . $quiz_class . '>';
654
+			$html .= '<div id="add-question-main"'.$quiz_class.'>';
655 655
 				// Inner DIV
656 656
 				$html .= '<div id="add-question-metadata">';
657 657
 
658 658
 					// Count of questions
659
-					$html .= '<input type="hidden" name="question_counter" id="question_counter" value="' . esc_attr( $question_count ) . '" />';
659
+					$html .= '<input type="hidden" name="question_counter" id="question_counter" value="'.esc_attr($question_count).'" />';
660 660
 					// Table headers
661 661
 					$html .= '<table class="widefat" id="sortable-questions">
662 662
 								<thead>
663 663
 								    <tr>
664 664
 								        <th class="question-count-column">#</th>
665
-								        <th>' . __( 'Question', 'woothemes-sensei' ) . '</th>
666
-								        <th style="width:45px;">' . __( 'Grade', 'woothemes-sensei' ) . '</th>
667
-								        <th style="width:125px;">' . __( 'Type', 'woothemes-sensei' ) . '</th>
668
-								        <th style="width:125px;">' . __( 'Action', 'woothemes-sensei' ) . '</th>
665
+								        <th>' . __('Question', 'woothemes-sensei').'</th>
666
+								        <th style="width:45px;">' . __('Grade', 'woothemes-sensei').'</th>
667
+								        <th style="width:125px;">' . __('Type', 'woothemes-sensei').'</th>
668
+								        <th style="width:125px;">' . __('Action', 'woothemes-sensei').'</th>
669 669
 								    </tr>
670 670
 								</thead>
671 671
 								<tfoot>
672 672
 								    <tr>
673 673
 									    <th class="question-count-column">#</th>
674
-									    <th>' . __( 'Question', 'woothemes-sensei' ) . '</th>
675
-									    <th>' . __( 'Grade', 'woothemes-sensei' ) . '</th>
676
-									    <th>' . __( 'Type', 'woothemes-sensei' ) . '</th>
677
-									    <th>' . __( 'Action', 'woothemes-sensei' ) . '</th>
674
+									    <th>' . __('Question', 'woothemes-sensei').'</th>
675
+									    <th>' . __('Grade', 'woothemes-sensei').'</th>
676
+									    <th>' . __('Type', 'woothemes-sensei').'</th>
677
+									    <th>' . __('Action', 'woothemes-sensei').'</th>
678 678
 								    </tr>
679 679
 								</tfoot>';
680 680
 
681 681
 					$message_class = '';
682
-					if ( 0 < $question_count ) { $message_class = 'hidden'; }
682
+					if (0 < $question_count) { $message_class = 'hidden'; }
683 683
 
684
-					$html .= '<tbody id="no-questions-message" class="' . esc_attr( $message_class ) . '">';
684
+					$html .= '<tbody id="no-questions-message" class="'.esc_attr($message_class).'">';
685 685
 						$html .= '<tr>';
686
-							$html .= '<td colspan="5">' . __( 'There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei' ) . '</td>';
686
+							$html .= '<td colspan="5">'.__('There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei').'</td>';
687 687
 						$html .= '</tr>';
688 688
 					$html .= '</tbody>';
689 689
 
690
-					if( 0 < $question_count ) {
691
-						$html .= $this->quiz_panel_questions( $questions );
690
+					if (0 < $question_count) {
691
+						$html .= $this->quiz_panel_questions($questions);
692 692
 					}
693 693
 
694 694
 					$html .= '</table>';
695 695
 
696
-					if( ! isset( $this->question_order ) ) {
696
+					if ( ! isset($this->question_order)) {
697 697
 						$this->question_order = '';
698 698
 					}
699 699
 
700
-					$html .= '<input type="hidden" id="question-order" name="question-order" value="' . $this->question_order . '" />';
700
+					$html .= '<input type="hidden" id="question-order" name="question-order" value="'.$this->question_order.'" />';
701 701
 
702 702
 				$html .= '</div>';
703 703
 
@@ -716,47 +716,47 @@  discard block
 block discarded – undo
716 716
 
717 717
 	}
718 718
 
719
-	public function quiz_panel_questions( $questions = array() ) {
719
+	public function quiz_panel_questions($questions = array()) {
720 720
 		global $quiz_questions;
721 721
 
722 722
 		$quiz_questions = $questions;
723 723
 
724 724
 		$html = '';
725 725
 
726
-		if( count( $questions ) > 0 ) {
726
+		if (count($questions) > 0) {
727 727
 
728 728
 			$question_class = '';
729 729
 			$question_counter = 1;
730 730
 
731
-			foreach ( $questions as $question ) {
731
+			foreach ($questions as $question) {
732 732
 
733 733
 				$question_id = $question->ID;
734 734
 
735
-				$question_type = Sensei()->question->get_question_type( $question_id );
735
+				$question_type = Sensei()->question->get_question_type($question_id);
736 736
 
737 737
 				$multiple_data = array();
738 738
 				$question_increment = 1;
739
-				if( 'multiple_question' == $question->post_type ) {
739
+				if ('multiple_question' == $question->post_type) {
740 740
 					$question_type = 'category';
741 741
 
742
-					$question_category = get_post_meta( $question->ID, 'category', true );
743
-					$question_cat = get_term( $question_category, 'question-category' );
742
+					$question_category = get_post_meta($question->ID, 'category', true);
743
+					$question_cat = get_term($question_category, 'question-category');
744 744
 
745
-					$question_number = get_post_meta( $question->ID, 'number', true );
745
+					$question_number = get_post_meta($question->ID, 'number', true);
746 746
 					$question_increment = $question_number;
747 747
 
748
-					$multiple_data = array( $question_cat->name, $question_number );
748
+					$multiple_data = array($question_cat->name, $question_number);
749 749
 				}
750 750
 
751
-				if( ! $question_type ) {
751
+				if ( ! $question_type) {
752 752
 					$question_type = 'multiple-choice';
753 753
 				}
754 754
 
755 755
 				// Row with question and actions
756
-				$html .= $this->quiz_panel_question( $question_type, $question_counter, $question_id, 'quiz', $multiple_data );
756
+				$html .= $this->quiz_panel_question($question_type, $question_counter, $question_id, 'quiz', $multiple_data);
757 757
 				$question_counter += $question_increment;
758 758
 
759
-				if( isset( $this->question_order ) && strlen( $this->question_order ) > 0 ) { $this->question_order .= ','; }
759
+				if (isset($this->question_order) && strlen($this->question_order) > 0) { $this->question_order .= ','; }
760 760
 				$this->question_order .= $question_id;
761 761
 			} // End For Loop
762 762
 		}
@@ -765,161 +765,161 @@  discard block
 block discarded – undo
765 765
 
766 766
 	}
767 767
 
768
-	public function quiz_panel_question( $question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array() ) {
769
-		global $row_counter,  $quiz_questions;
768
+	public function quiz_panel_question($question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array()) {
769
+		global $row_counter, $quiz_questions;
770 770
 
771 771
 		$html = '';
772 772
 
773 773
 		$question_class = '';
774
-		if( 'quiz' == $context ) {
775
-			if( ! $row_counter || ! isset( $row_counter ) ) {
774
+		if ('quiz' == $context) {
775
+			if ( ! $row_counter || ! isset($row_counter)) {
776 776
 				$row_counter = 1;
777 777
 			}
778
-			if( $row_counter % 2 ) { $question_class = 'alternate'; }
778
+			if ($row_counter % 2) { $question_class = 'alternate'; }
779 779
 			++$row_counter;
780 780
 		}
781 781
 
782
-		if( $question_id ) {
782
+		if ($question_id) {
783 783
 
784
-			if( $question_type != 'category' ) {
784
+			if ($question_type != 'category') {
785 785
 
786
-				$question_grade = Sensei()->question->get_question_grade( $question_id );
786
+				$question_grade = Sensei()->question->get_question_grade($question_id);
787 787
 
788
-				$question_media = get_post_meta( $question_id, '_question_media', true );
788
+				$question_media = get_post_meta($question_id, '_question_media', true);
789 789
 				$question_media_type = $question_media_thumb = $question_media_link = $question_media_title = '';
790 790
 				$question_media_thumb_class = $question_media_link_class = $question_media_delete_class = 'hidden';
791
-				$question_media_add_button = __( 'Add file', 'woothemes-sensei' );
792
-				if( 0 < intval( $question_media ) ) {
793
-					$mimetype = get_post_mime_type( $question_media );
794
-					if( $mimetype ) {
795
-						$mimetype_array = explode( '/', $mimetype);
796
-						if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) {
791
+				$question_media_add_button = __('Add file', 'woothemes-sensei');
792
+				if (0 < intval($question_media)) {
793
+					$mimetype = get_post_mime_type($question_media);
794
+					if ($mimetype) {
795
+						$mimetype_array = explode('/', $mimetype);
796
+						if (isset($mimetype_array[0]) && $mimetype_array[0]) {
797 797
 							$question_media_delete_class = '';
798 798
 							$question_media_type = $mimetype_array[0];
799
-							if( 'image' == $question_media_type ) {
800
-								$question_media_thumb = wp_get_attachment_thumb_url( $question_media );
801
-								if( $question_media_thumb ) {
799
+							if ('image' == $question_media_type) {
800
+								$question_media_thumb = wp_get_attachment_thumb_url($question_media);
801
+								if ($question_media_thumb) {
802 802
 									$question_media_thumb_class = '';
803 803
 								}
804 804
 							}
805
-							$question_media_url = wp_get_attachment_url( $question_media );
806
-							if( $question_media_url ) {
807
-								$attachment = get_post( $question_media );
805
+							$question_media_url = wp_get_attachment_url($question_media);
806
+							if ($question_media_url) {
807
+								$attachment = get_post($question_media);
808 808
 								$question_media_title = $attachment->post_title;
809 809
 
810
-								if( ! $question_media_title ) {
811
-									$question_media_filename = basename( $question_media_url );
810
+								if ( ! $question_media_title) {
811
+									$question_media_filename = basename($question_media_url);
812 812
 									$question_media_title = $question_media_filename;
813 813
 								}
814
-								$question_media_link = '<a class="' . $question_media_type . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_title . '</a>';
814
+								$question_media_link = '<a class="'.$question_media_type.'" href="'.esc_url($question_media_url).'" target="_blank">'.$question_media_title.'</a>';
815 815
 								$question_media_link_class = '';
816 816
 							}
817 817
 
818
-							$question_media_add_button = __( 'Change file', 'woothemes-sensei' );
818
+							$question_media_add_button = __('Change file', 'woothemes-sensei');
819 819
 						}
820 820
 					}
821 821
 				}
822 822
 
823
-				$random_order = get_post_meta( $question_id, '_random_order', true );
824
-				if( ! $random_order ) {
823
+				$random_order = get_post_meta($question_id, '_random_order', true);
824
+				if ( ! $random_order) {
825 825
 					$random_order = 'yes';
826 826
 				}
827 827
 
828
-				if( ! $question_type ) { $question_type = 'multiple-choice'; }
828
+				if ( ! $question_type) { $question_type = 'multiple-choice'; }
829 829
 			}
830 830
 
831
-			$html .= '<tbody class="' . $question_class . '">';
831
+			$html .= '<tbody class="'.$question_class.'">';
832 832
 
833
-				if( 'quiz' == $context ) {
833
+				if ('quiz' == $context) {
834 834
 					$html .= '<tr>';
835
-						if( $question_type != 'category' ) {
836
-							$question = get_post( $question_id );
837
-							$html .= '<td class="table-count question-number question-count-column"><span class="number">' . $question_counter . '</span></td>';
838
-							$html .= '<td>' . esc_html( $question->post_title ) . '</td>';
839
-							$html .= '<td class="question-grade-column">' . esc_html( $question_grade ) . '</td>';
840
-							$question_types_filtered = ucwords( str_replace( array( '-', 'boolean' ), array( ' ', __( 'True/False', 'woothemes-sensei' ) ), $question_type ) );
841
-							$html .= '<td>' . esc_html( $question_types_filtered ) . '</td>';
842
-							$html .= '<td><a title="' . esc_attr( __( 'Edit Question', 'woothemes-sensei' ) ) . '" href="#question_' . $question_counter .'" class="question_table_edit">' . esc_html( __( 'Edit', 'woothemes-sensei' ) ) . '</a> <a title="' . esc_attr( __( 'Remove Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_delete">' . esc_html( __( 'Remove', 'woothemes-sensei' ) ) . '</a></td>';
835
+						if ($question_type != 'category') {
836
+							$question = get_post($question_id);
837
+							$html .= '<td class="table-count question-number question-count-column"><span class="number">'.$question_counter.'</span></td>';
838
+							$html .= '<td>'.esc_html($question->post_title).'</td>';
839
+							$html .= '<td class="question-grade-column">'.esc_html($question_grade).'</td>';
840
+							$question_types_filtered = ucwords(str_replace(array('-', 'boolean'), array(' ', __('True/False', 'woothemes-sensei')), $question_type));
841
+							$html .= '<td>'.esc_html($question_types_filtered).'</td>';
842
+							$html .= '<td><a title="'.esc_attr(__('Edit Question', 'woothemes-sensei')).'" href="#question_'.$question_counter.'" class="question_table_edit">'.esc_html(__('Edit', 'woothemes-sensei')).'</a> <a title="'.esc_attr(__('Remove Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_table_delete">'.esc_html(__('Remove', 'woothemes-sensei')).'</a></td>';
843 843
 
844 844
 						} else {
845 845
 
846
-							$end_number = intval( $question_counter ) + intval( $multiple_data[1] ) - 1;
847
-							if( $question_counter == $end_number ) {
846
+							$end_number = intval($question_counter) + intval($multiple_data[1]) - 1;
847
+							if ($question_counter == $end_number) {
848 848
 								$row_numbers = $question_counter;
849 849
 							} else {
850
-								$row_numbers = $question_counter . ' - ' . $end_number;
850
+								$row_numbers = $question_counter.' - '.$end_number;
851 851
 							}
852
-							$row_title = sprintf( __( 'Selected from \'%1$s\' ', 'woothemes-sensei' ), $multiple_data[0] );
852
+							$row_title = sprintf(__('Selected from \'%1$s\' ', 'woothemes-sensei'), $multiple_data[0]);
853 853
 
854
-							$html .= '<td class="table-count question-number question-count-column"><span class="number hidden">' . $question_counter . '</span><span class="hidden total-number">' . $multiple_data[1] . '</span><span class="row-numbers">' . esc_html( $row_numbers ) . '</span></td>';
855
-							$html .= '<td>' . esc_html( $row_title ) . '</td>';
854
+							$html .= '<td class="table-count question-number question-count-column"><span class="number hidden">'.$question_counter.'</span><span class="hidden total-number">'.$multiple_data[1].'</span><span class="row-numbers">'.esc_html($row_numbers).'</span></td>';
855
+							$html .= '<td>'.esc_html($row_title).'</td>';
856 856
 							$html .= '<td class="question-grade-column"></td>';
857
-							$html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" /></td>';
858
-							$html .= '<td><a title="' . esc_attr( __( 'Edit Question', 'woothemes-sensei' ) ) . '" href="#question_' . $question_counter .'" class="question_table_edit" style="visibility:hidden;">' . esc_html( __( 'Edit', 'woothemes-sensei' ) ) . '</a> <a title="' . esc_attr( __( 'Remove Question(s)', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_multiple_delete" rel="' . $question_id . '">' . esc_html( __( 'Remove', 'woothemes-sensei' ) ) . '</a></td>';
857
+							$html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" /></td>';
858
+							$html .= '<td><a title="'.esc_attr(__('Edit Question', 'woothemes-sensei')).'" href="#question_'.$question_counter.'" class="question_table_edit" style="visibility:hidden;">'.esc_html(__('Edit', 'woothemes-sensei')).'</a> <a title="'.esc_attr(__('Remove Question(s)', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_multiple_delete" rel="'.$question_id.'">'.esc_html(__('Remove', 'woothemes-sensei')).'</a></td>';
859 859
 
860 860
 						}
861 861
 					$html .= '</tr>';
862 862
 				}
863 863
 
864
-				if( $question_type != 'category' ) {
864
+				if ($question_type != 'category') {
865 865
 
866 866
 					$edit_class = '';
867
-					if( 'quiz' == $context ) {
867
+					if ('quiz' == $context) {
868 868
 						$edit_class = 'hidden';
869 869
 					}
870 870
 
871
-					$question = get_post( $question_id );
872
-					$html .= '<tr class="question-quick-edit ' . esc_attr( $edit_class ) . '">';
871
+					$question = get_post($question_id);
872
+					$html .= '<tr class="question-quick-edit '.esc_attr($edit_class).'">';
873 873
 						$html .= '<td colspan="5">';
874
-							$html .= '<span class="hidden question_original_counter">' . $question_counter . '</span>';
874
+							$html .= '<span class="hidden question_original_counter">'.$question_counter.'</span>';
875 875
 					    	$html .= '<div class="question_required_fields">';
876 876
 
877 877
 						    	// Question title
878 878
 						    	$html .= '<div>';
879
-							    	$html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> ';
880
-							    	$html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />';
879
+							    	$html .= '<label for="question_'.$question_counter.'">'.__('Question:', 'woothemes-sensei').'</label> ';
880
+							    	$html .= '<input type="text" id="question_'.$question_counter.'" name="question" value="'.esc_attr(htmlspecialchars($question->post_title)).'" size="25" class="widefat" />';
881 881
 						    	$html .= '</div>';
882 882
 
883 883
 						    	// Question description
884 884
 						    	$html .= '<div>';
885
-							    	$html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
885
+							    	$html .= '<label for="question_'.$question_counter.'_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> ';
886 886
 						    	$html .= '</div>';
887
-							    	$html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>';
887
+							    	$html .= '<textarea id="question_'.$question_counter.'_desc" name="question_description" class="widefat" rows="4">'.esc_textarea($question->post_content).'</textarea>';
888 888
 
889 889
 						    	// Question grade
890 890
 						    	$html .= '<div>';
891
-							    	$html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> ';
892
-							    	$html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />';
891
+							    	$html .= '<label for="question_'.$question_counter.'_grade">'.__('Question grade:', 'woothemes-sensei').'</label> ';
892
+							    	$html .= '<input type="number" id="question_'.$question_counter.'_grade" class="question_grade small-text" name="question_grade" min="0" value="'.$question_grade.'" />';
893 893
 						    	$html .= '</div>';
894 894
 
895 895
 						    	// Random order
896
-						    	if( $question_type == 'multiple-choice' ) {
896
+						    	if ($question_type == 'multiple-choice') {
897 897
 						    		$html .= '<div>';
898
-						    			$html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
898
+						    			$html .= '<label for="'.$question_counter.'_random_order"><input type="checkbox" name="random_order" class="random_order" id="'.$question_counter.'_random_order" value="yes" '.checked($random_order, 'yes', false).' /> '.__('Randomise answer order', 'woothemes-sensei').'</label>';
899 899
 						    		$html .= '</div>';
900 900
 						    	}
901 901
 
902 902
 						    	// Question media
903 903
 						    	$html .= '<div>';
904
-							    	$html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
905
-							    	$html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>';
906
-							    	$html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
907
-							    	$html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>';
908
-							    	$html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>';
909
-							    	$html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />';
904
+							    	$html .= '<label for="question_'.$question_counter.'_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>';
905
+							    	$html .= '<button id="question_'.$question_counter.'_media_button" class="upload_media_file_button button-secondary" data-uploader_title="'.__('Add file to question', 'woothemes-sensei').'" data-uploader_button_text="'.__('Add to question', 'woothemes-sensei').'">'.$question_media_add_button.'</button>';
906
+							    	$html .= '<button id="question_'.$question_counter.'_media_button_delete" class="delete_media_file_button button-secondary '.$question_media_delete_class.'">'.__('Delete file', 'woothemes-sensei').'</button><br/>';
907
+							    	$html .= '<span id="question_'.$question_counter.'_media_link" class="question_media_link '.$question_media_link_class.'">'.$question_media_link.'</span>';
908
+							    	$html .= '<br/><img id="question_'.$question_counter.'_media_preview" class="question_media_preview '.$question_media_thumb_class.'" src="'.$question_media_thumb.'" /><br/>';
909
+							    	$html .= '<input type="hidden" id="question_'.$question_counter.'_media" class="question_media" name="question_media" value="'.$question_media.'" />';
910 910
 						    	$html .= '</div>';
911 911
 
912 912
 						    $html .= '</div>';
913 913
 
914
-						    $html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter );
914
+						    $html .= $this->quiz_panel_question_field($question_type, $question_id, $question_counter);
915 915
 
916
-						    $html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />';
917
-							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" />';
916
+						    $html .= '<input type="hidden" id="question_'.$question_counter.'_question_type" class="question_type" name="question_type" value="'.$question_type.'" />';
917
+							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" />';
918 918
 
919
-							if( 'quiz' == $context ) {
919
+							if ('quiz' == $context) {
920 920
 					    		$html .= '<div class="update-question">';
921
-						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> ';
922
-						    		$html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>';
921
+						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="'.esc_attr(__('Cancel', 'woothemes-sensei')).'">'.__('Cancel', 'woothemes-sensei').'</a> ';
922
+						    		$html .= '<a title="'.esc_attr(__('Update Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_table_save button button-highlighted">'.esc_html(__('Update', 'woothemes-sensei')).'</a>';
923 923
 					    		$html .= '</div>';
924 924
 					    	}
925 925
 
@@ -934,79 +934,79 @@  discard block
 block discarded – undo
934 934
 		return $html;
935 935
 	}
936 936
 
937
-	public function quiz_panel_add( $context = 'quiz' ) {
937
+	public function quiz_panel_add($context = 'quiz') {
938 938
 
939 939
 
940 940
 		$html = '<div id="add-new-question">';
941 941
 
942 942
 			$question_types = Sensei()->question->question_types();
943 943
 
944
-			$question_cats = get_terms( 'question-category', array( 'hide_empty' => false ) );
944
+			$question_cats = get_terms('question-category', array('hide_empty' => false));
945 945
 
946
-			if( 'quiz' == $context ) {
946
+			if ('quiz' == $context) {
947 947
 	    		$html .= '<h2 class="nav-tab-wrapper add-question-tabs">';
948
-	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question'  , 'woothemes-sensei' ) . '</a>';
949
-	    			$html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions'  , 'woothemes-sensei' ) . '</a>';
950
-                    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats )  && ! Sensei()->teacher->is_admin_teacher() ) {
951
-	    				$html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions'  , 'woothemes-sensei' ) . '</a>';
948
+	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">'.__('New Question', 'woothemes-sensei').'</a>';
949
+	    			$html .= '<a id="tab-existing" class="nav-tab">'.__('Existing Questions', 'woothemes-sensei').'</a>';
950
+                    if ( ! empty($question_cats) && ! is_wp_error($question_cats) && ! Sensei()->teacher->is_admin_teacher()) {
951
+	    				$html .= '<a id="tab-multiple" class="nav-tab">'.__('Category Questions', 'woothemes-sensei').'</a>';
952 952
 	    			}
953 953
 	    		$html .= '</h2>';
954 954
 	    	}
955 955
 
956 956
 	    	$html .= '<div class="tab-content" id="tab-new-content">';
957 957
 
958
-	    		if( 'quiz' == $context ) {
959
-	    			$html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
958
+	    		if ('quiz' == $context) {
959
+	    			$html .= '<p><em>'.sprintf(__('Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit.php?post_type=question').'">', '</a>').'</em></p>';
960 960
 	    		}
961 961
 
962 962
 				$html .= '<div class="question">';
963 963
 					$html .= '<div class="question_required_fields">';
964 964
 
965 965
 						// Question title
966
-						$html .= '<p><label>' . __( 'Question:'  , 'woothemes-sensei' ) . '</label> ';
966
+						$html .= '<p><label>'.__('Question:', 'woothemes-sensei').'</label> ';
967 967
 	  					$html .= '<input type="text" id="add_question" name="question" value="" size="25" class="widefat" /></p>';
968 968
 
969 969
 						// Question description
970 970
 						$html .= '<p>';
971
-							$html .= '<label for="question_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
971
+							$html .= '<label for="question_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> ';
972 972
 						$html .= '</p>';
973 973
 						$html .= '<textarea id="question_desc" name="question_description" class="widefat" rows="4"></textarea>';
974 974
 
975 975
 	  					// Question type
976
-						$html .= '<p><label>' . __( 'Question Type:' , 'woothemes-sensei' ) . '</label> ';
977
-						$html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">' . "\n";
978
-							foreach ( $question_types as $type => $label ) {
979
-								$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>' . "\n";
976
+						$html .= '<p><label>'.__('Question Type:', 'woothemes-sensei').'</label> ';
977
+						$html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">'."\n";
978
+							foreach ($question_types as $type => $label) {
979
+								$html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>'."\n";
980 980
 							} // End For Loop
981
-						$html .= '</select></p>' . "\n";
981
+						$html .= '</select></p>'."\n";
982 982
 
983 983
 						// Question category
984
-						if( 'quiz' == $context ) {
985
-							if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
986
-								$html .= '<p><label>' . __( 'Question Category:' , 'woothemes-sensei' ) . '</label> ';
987
-								$html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">' . "\n";
988
-								$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>' . "\n";
989
-								foreach( $question_cats as $cat ) {
990
-									$html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>';
984
+						if ('quiz' == $context) {
985
+							if ( ! empty($question_cats) && ! is_wp_error($question_cats)) {
986
+								$html .= '<p><label>'.__('Question Category:', 'woothemes-sensei').'</label> ';
987
+								$html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">'."\n";
988
+								$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'."\n";
989
+								foreach ($question_cats as $cat) {
990
+									$html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>';
991 991
 								} // End For Loop
992
-								$html .= '</select></p>' . "\n";
992
+								$html .= '</select></p>'."\n";
993 993
 							}
994 994
 						}
995 995
 
996 996
 	  					// Question grade
997
-						$html .= '<p><label>' . __( 'Question Grade:'  , 'woothemes-sensei' ) . '</label> ';
998
-						$html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>' . "\n";
997
+						$html .= '<p><label>'.__('Question Grade:', 'woothemes-sensei').'</label> ';
998
+						$html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>'."\n";
999 999
 
1000 1000
 						// Random order
1001 1001
 						$html .= '<p class="add_question_random_order">';
1002
-			    			$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
1002
+			    			$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> '.__('Randomise answer order', 'woothemes-sensei').'</label>';
1003 1003
 			    		$html .= '</p>';
1004 1004
 
1005 1005
 			    		// Question media
1006 1006
 						$html .= '<p>';
1007
-					    	$html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
1008
-					    	$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>';
1009
-					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
1007
+					    	$html .= '<label for="question_add_new_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>';
1008
+					    	$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="'.__('Add file to question', 'woothemes-sensei').'" data-uploader_button_text="'.__('Add to question', 'woothemes-sensei').'">'.__('Add file', 'woothemes-sensei').'</button>';
1009
+					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">'.__('Delete file', 'woothemes-sensei').'</button><br/>';
1010 1010
 					    	$html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>';
1011 1011
 					    	$html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>';
1012 1012
 					    	$html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />';
@@ -1015,44 +1015,44 @@  discard block
 block discarded – undo
1015 1015
 					$html .= '</div>';
1016 1016
 				$html .= '</div>';
1017 1017
 
1018
-				foreach ( $question_types as $type => $label ) {
1019
-					$html .= $this->quiz_panel_question_field( $type );
1018
+				foreach ($question_types as $type => $label) {
1019
+					$html .= $this->quiz_panel_question_field($type);
1020 1020
 				}
1021 1021
 
1022
-				if( 'quiz' == $context ) {
1022
+				if ('quiz' == $context) {
1023 1023
 					$html .= '<div class="add-question">';
1024
-			    		$html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>';
1024
+			    		$html .= '<a title="'.esc_attr(__('Add Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">'.esc_html(__('Add Question', 'woothemes-sensei')).'</a>';
1025 1025
 		    		$html .= '</div>';
1026 1026
 		    	}
1027 1027
 
1028 1028
 		    $html .= '</div>';
1029 1029
 
1030
-		    if( 'quiz' == $context ) {
1030
+		    if ('quiz' == $context) {
1031 1031
 
1032 1032
 			    $html .= '<div class="tab-content hidden" id="tab-existing-content">';
1033 1033
 
1034
-			    	$html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
1034
+			    	$html .= '<p><em>'.sprintf(__('Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit.php?post_type=question').'">', '</a>').'</em></p>';
1035 1035
 
1036 1036
 			    	$html .= '<div id="existing-filters" class="alignleft actions">
1037 1037
 			    				<select id="existing-status">
1038
-			    					<option value="all">' . __( 'All', 'woothemes-sensei' ) . '</option>
1039
-			    					<option value="unused">' . __( 'Unused', 'woothemes-sensei' ) . '</option>
1040
-			    					<option value="used">' . __( 'Used', 'woothemes-sensei' ) . '</option>
1038
+			    					<option value="all">' . __('All', 'woothemes-sensei').'</option>
1039
+			    					<option value="unused">' . __('Unused', 'woothemes-sensei').'</option>
1040
+			    					<option value="used">' . __('Used', 'woothemes-sensei').'</option>
1041 1041
 			    				</select>
1042 1042
 			    				<select id="existing-type">
1043
-			    					<option value="">' . __( 'All Types', 'woothemes-sensei' ) . '</option>';
1044
-							    	foreach ( $question_types as $type => $label ) {
1045
-										$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>';
1043
+			    					<option value="">' . __('All Types', 'woothemes-sensei').'</option>';
1044
+							    	foreach ($question_types as $type => $label) {
1045
+										$html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>';
1046 1046
 									}
1047 1047
     				$html .= '</select>
1048 1048
     							<select id="existing-category">
1049
-			    					<option value="">' . __( 'All Categories', 'woothemes-sensei' ) . '</option>';
1050
-				    				foreach( $question_cats as $cat ) {
1051
-										$html .= '<option value="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat->name ) . '</option>';
1049
+			    					<option value="">' . __('All Categories', 'woothemes-sensei').'</option>';
1050
+				    				foreach ($question_cats as $cat) {
1051
+										$html .= '<option value="'.esc_attr($cat->slug).'">'.esc_html($cat->name).'</option>';
1052 1052
 									}
1053 1053
     				$html .= '</select>
1054
-    							<input type="text" id="existing-search" placeholder="' . __( 'Search', 'woothemes-sensei' ) . '" />
1055
-    							<a class="button" id="existing-filter-button">' . __( 'Filter', 'woothemes-sensei' ) . '</a>
1054
+    							<input type="text" id="existing-search" placeholder="' . __('Search', 'woothemes-sensei').'" />
1055
+    							<a class="button" id="existing-filter-button">' . __('Filter', 'woothemes-sensei').'</a>
1056 1056
 			    			</div>';
1057 1057
 
1058 1058
 			    	$html .= '<table id="existing-table" class="widefat">';
@@ -1060,17 +1060,17 @@  discard block
 block discarded – undo
1060 1060
 			    		$html .= '<thead>
1061 1061
 									    <tr>
1062 1062
 									        <th scope="col" class="column-cb check-column"><input type="checkbox" /></th>
1063
-									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
1064
-									        <th scope="col">' . __( 'Type', 'woothemes-sensei' ) . '</th>
1065
-									        <th scope="col">' . __( 'Category', 'woothemes-sensei' ) . '</th>
1063
+									        <th scope="col">' . __('Question', 'woothemes-sensei').'</th>
1064
+									        <th scope="col">' . __('Type', 'woothemes-sensei').'</th>
1065
+									        <th scope="col">' . __('Category', 'woothemes-sensei').'</th>
1066 1066
 									    </tr>
1067 1067
 									</thead>
1068 1068
 									<tfoot>
1069 1069
 									    <tr>
1070 1070
 										    <th scope="col" class="check-column"><input type="checkbox" /></th>
1071
-									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
1072
-									        <th scope="col">' . __( 'Type', 'woothemes-sensei' ) . '</th>
1073
-									        <th scope="col">' . __( 'Category', 'woothemes-sensei' ) . '</th>
1071
+									        <th scope="col">' . __('Question', 'woothemes-sensei').'</th>
1072
+									        <th scope="col">' . __('Type', 'woothemes-sensei').'</th>
1073
+									        <th scope="col">' . __('Category', 'woothemes-sensei').'</th>
1074 1074
 									    </tr>
1075 1075
 									</tfoot>';
1076 1076
 						$html .= '<tbody id="existing-questions">';
@@ -1078,8 +1078,8 @@  discard block
 block discarded – undo
1078 1078
 						$questions = $this->quiz_panel_get_existing_questions();
1079 1079
 
1080 1080
 						$row = 1;
1081
-						foreach( $questions['questions'] as $question ) {
1082
-							$html .= $this->quiz_panel_add_existing_question( $question->ID, $row );
1081
+						foreach ($questions['questions'] as $question) {
1082
+							$html .= $this->quiz_panel_add_existing_question($question->ID, $row);
1083 1083
 							++$row;
1084 1084
 						}
1085 1085
 
@@ -1088,36 +1088,36 @@  discard block
 block discarded – undo
1088 1088
 			    	$html .= '</table>';
1089 1089
 
1090 1090
 			    	$next_class = '';
1091
-			    	if( $questions['count'] <= 10 ) {
1091
+			    	if ($questions['count'] <= 10) {
1092 1092
 			    		$next_class = 'hidden';
1093 1093
 			    	}
1094 1094
 
1095 1095
 			    	$html .= '<div id="existing-pagination">';
1096 1096
 			    		$html .= '<input type="hidden" id="existing-page" value="1" />';
1097
-			    		$html .= '<a class="prev no-paging">&larr; ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' &rarr;</a>';
1097
+			    		$html .= '<a class="prev no-paging">&larr; '.__('Previous', 'woothemes-sensei').'</a> <a class="next '.esc_attr($next_class).'">'.__('Next', 'woothemes-sensei').' &rarr;</a>';
1098 1098
 			    	$html .= '</div>';
1099 1099
 
1100 1100
 			    	$html .= '<div class="existing-actions">';
1101
-			    		$html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1101
+			    		$html .= '<a title="'.esc_attr(__('Add Selected Question(s)', 'woothemes-sensei')).'" class="add_existing_save button button-primary button-highlighted">'.esc_html(__('Add Selected Question(s)', 'woothemes-sensei')).'</a></p>';
1102 1102
 			    	$html .= '</div>';
1103 1103
 
1104 1104
 			    $html .= '</div>';
1105 1105
 
1106
-			    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
1106
+			    if ( ! empty($question_cats) && ! is_wp_error($question_cats)) {
1107 1107
 				    $html .= '<div class="tab-content hidden" id="tab-multiple-content">';
1108 1108
 
1109
-				    	$html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>';
1109
+				    	$html .= '<p><em>'.sprintf(__('Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit-tags.php?taxonomy=question-category&post_type=question').'">', '</a>').'</em></p>';
1110 1110
 
1111
-						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">' . "\n";
1112
-						$html .= '<option value="">' . __( 'Select a Question Category', 'woothemes-sensei' ) . '</option>' . "\n";
1113
-						foreach( $question_cats as $cat ) {
1114
-							$html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>';
1111
+						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">'."\n";
1112
+						$html .= '<option value="">'.__('Select a Question Category', 'woothemes-sensei').'</option>'."\n";
1113
+						foreach ($question_cats as $cat) {
1114
+							$html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>';
1115 1115
 						} // End For Loop
1116
-						$html .= '</select></p>' . "\n";
1116
+						$html .= '</select></p>'."\n";
1117 1117
 
1118
-						$html .= '<p>' . __( 'Number of questions:', 'woothemes-sensei' ) . ' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>';
1118
+						$html .= '<p>'.__('Number of questions:', 'woothemes-sensei').' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>';
1119 1119
 
1120
-						$html .= '<a title="' . esc_attr( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '" class="add_multiple_save button button-primary button-highlighted">' . esc_html( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1120
+						$html .= '<a title="'.esc_attr(__('Add Question(s)', 'woothemes-sensei')).'" class="add_multiple_save button button-primary button-highlighted">'.esc_html(__('Add Question(s)', 'woothemes-sensei')).'</a></p>';
1121 1121
 
1122 1122
 				    $html .= '</div>';
1123 1123
 				}
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 		return $html;
1129 1129
 	}
1130 1130
 
1131
-	public function quiz_panel_get_existing_questions( $question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1 ) {
1131
+	public function quiz_panel_get_existing_questions($question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1) {
1132 1132
 
1133 1133
 		$args = array(
1134 1134
 			'post_type' => 'question',
@@ -1137,14 +1137,14 @@  discard block
 block discarded – undo
1137 1137
 			'suppress_filters' => 0,
1138 1138
 		);
1139 1139
 
1140
-		switch( $question_status ) {
1140
+		switch ($question_status) {
1141 1141
 			case 'unused': $quiz_status = 'NOT EXISTS'; break;
1142 1142
 			case 'used': $quiz_status = 'EXISTS'; break;
1143 1143
 			default: $quiz_status = ''; break;
1144 1144
 		}
1145 1145
 
1146
-		if( $quiz_status ) {
1147
-			switch( $quiz_status ) {
1146
+		if ($quiz_status) {
1147
+			switch ($quiz_status) {
1148 1148
 				case 'EXISTS':
1149 1149
 					$args['meta_query'][] = array(
1150 1150
 						'key' => '_quiz_id',
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 			}
1163 1163
 		}
1164 1164
 
1165
-		if( $question_type ) {
1165
+		if ($question_type) {
1166 1166
 			$args['tax_query'][] = array(
1167 1167
 				'taxonomy' => 'question-type',
1168 1168
 				'field' => 'slug',
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
 			);
1171 1171
 		}
1172 1172
 
1173
-		if( $question_category ) {
1173
+		if ($question_category) {
1174 1174
 			$args['tax_query'][] = array(
1175 1175
 				'taxonomy' => 'question-category',
1176 1176
 				'field' => 'slug',
@@ -1178,19 +1178,19 @@  discard block
 block discarded – undo
1178 1178
 			);
1179 1179
 		}
1180 1180
 
1181
-		if( $question_type && $question_category ) {
1181
+		if ($question_type && $question_category) {
1182 1182
 			$args['tax_query']['relation'] = 'AND';
1183 1183
 		}
1184 1184
 
1185
-		if( $question_search ) {
1185
+		if ($question_search) {
1186 1186
 			$args['s'] = $question_search;
1187 1187
 		}
1188 1188
 
1189
-		if( $page ) {
1189
+		if ($page) {
1190 1190
 			$args['paged'] = $page;
1191 1191
 		}
1192 1192
 
1193
-		$qry = new WP_Query( $args );
1193
+		$qry = new WP_Query($args);
1194 1194
 
1195 1195
         /**
1196 1196
          * Filter existing questions query
@@ -1199,39 +1199,39 @@  discard block
 block discarded – undo
1199 1199
          *
1200 1200
          * @param WP_Query $wp_query
1201 1201
          */
1202
-        $qry = apply_filters( 'sensei_existing_questions_query_results', $qry );
1202
+        $qry = apply_filters('sensei_existing_questions_query_results', $qry);
1203 1203
 
1204 1204
 		$questions['questions'] = $qry->posts;
1205
-		$questions['count'] = intval( $qry->found_posts );
1205
+		$questions['count'] = intval($qry->found_posts);
1206 1206
 		$questions['page'] = $page;
1207 1207
 
1208 1208
 		return $questions;
1209 1209
 	}
1210 1210
 
1211
-	public function quiz_panel_add_existing_question( $question_id = 0, $row = 1 ) {
1211
+	public function quiz_panel_add_existing_question($question_id = 0, $row = 1) {
1212 1212
 
1213 1213
 		$html = '';
1214 1214
 
1215
-		if( ! $question_id ) {
1215
+		if ( ! $question_id) {
1216 1216
 
1217 1217
             return;
1218 1218
 
1219 1219
         }
1220 1220
 
1221 1221
 		$existing_class = '';
1222
-		if( $row % 2 ) {
1222
+		if ($row % 2) {
1223 1223
             $existing_class = 'alternate';
1224 1224
         }
1225 1225
 
1226
-		$question_type = Sensei()->question->get_question_type( $question_id );
1226
+		$question_type = Sensei()->question->get_question_type($question_id);
1227 1227
 
1228
-		$question_cat_list = strip_tags( get_the_term_list( $question_id, 'question-category', '', ', ', '' ) );
1228
+		$question_cat_list = strip_tags(get_the_term_list($question_id, 'question-category', '', ', ', ''));
1229 1229
 
1230
-		$html .= '<tr class="' . esc_attr( $existing_class ) . '">
1231
-					<td class="cb"><input type="checkbox" value="' . $question_id . '" class="existing-item" /></td>
1232
-					<td>' . get_the_title( $question_id ) . '</td>
1233
-					<td>' . esc_html( $question_type ) . '</td>
1234
-					<td>' . esc_html( $question_cat_list ) . '</td>
1230
+		$html .= '<tr class="'.esc_attr($existing_class).'">
1231
+					<td class="cb"><input type="checkbox" value="' . $question_id.'" class="existing-item" /></td>
1232
+					<td>' . get_the_title($question_id).'</td>
1233
+					<td>' . esc_html($question_type).'</td>
1234
+					<td>' . esc_html($question_cat_list).'</td>
1235 1235
 				  </tr>';
1236 1236
 
1237 1237
 		return $html;
@@ -1244,58 +1244,58 @@  discard block
 block discarded – undo
1244 1244
 
1245 1245
 		//Add nonce security to the request
1246 1246
 		$nonce = '';
1247
-		if( isset( $_POST['filter_existing_questions_nonce'] ) ) {
1248
-			$nonce = esc_html( $_POST['filter_existing_questions_nonce'] );
1247
+		if (isset($_POST['filter_existing_questions_nonce'])) {
1248
+			$nonce = esc_html($_POST['filter_existing_questions_nonce']);
1249 1249
 		} // End If Statement
1250 1250
 
1251
-		if( ! wp_verify_nonce( $nonce, 'filter_existing_questions_nonce' ) ) {
1252
-			die( $return );
1251
+		if ( ! wp_verify_nonce($nonce, 'filter_existing_questions_nonce')) {
1252
+			die($return);
1253 1253
 		} // End If Statement
1254 1254
 
1255 1255
 		// Parse POST data
1256 1256
 		$data = $_POST['data'];
1257 1257
 		$question_data = array();
1258
-		parse_str( $data, $question_data );
1258
+		parse_str($data, $question_data);
1259 1259
 
1260
-		if( 0 < count( $question_data ) ) {
1260
+		if (0 < count($question_data)) {
1261 1261
 
1262 1262
 			$question_status = '';
1263
-			if( isset( $question_data['question_status'] ) ) {
1263
+			if (isset($question_data['question_status'])) {
1264 1264
 				$question_status = $question_data['question_status'];
1265 1265
 			}
1266 1266
 
1267 1267
 			$question_type = '';
1268
-			if( isset( $question_data['question_type'] ) ) {
1268
+			if (isset($question_data['question_type'])) {
1269 1269
 				$question_type = $question_data['question_type'];
1270 1270
 			}
1271 1271
 
1272 1272
 			$question_category = '';
1273
-			if( isset( $question_data['question_category'] ) ) {
1273
+			if (isset($question_data['question_category'])) {
1274 1274
 				$question_category = $question_data['question_category'];
1275 1275
 			}
1276 1276
 
1277 1277
 			$question_search = '';
1278
-			if( isset( $question_data['question_search'] ) ) {
1278
+			if (isset($question_data['question_search'])) {
1279 1279
 				$question_search = $question_data['question_search'];
1280 1280
 			}
1281 1281
 
1282 1282
 			$question_page = 1;
1283
-			if( isset( $question_data['question_page'] ) ) {
1284
-				$question_page = intval( $question_data['question_page'] );
1283
+			if (isset($question_data['question_page'])) {
1284
+				$question_page = intval($question_data['question_page']);
1285 1285
 			}
1286 1286
 
1287
-			$questions = $this->quiz_panel_get_existing_questions( $question_status, $question_type, $question_category, $question_search, $question_page );
1287
+			$questions = $this->quiz_panel_get_existing_questions($question_status, $question_type, $question_category, $question_search, $question_page);
1288 1288
 
1289 1289
 			$row = 1;
1290 1290
 			$html = '';
1291
-			foreach( $questions['questions'] as $question ) {
1292
-				$html .= $this->quiz_panel_add_existing_question( $question->ID, $row );
1291
+			foreach ($questions['questions'] as $question) {
1292
+				$html .= $this->quiz_panel_add_existing_question($question->ID, $row);
1293 1293
 				++$row;
1294 1294
 			}
1295 1295
 
1296
-			if( ! $html ) {
1296
+			if ( ! $html) {
1297 1297
 				$html = '<tr class="alternate">
1298
-								<td class="no-results" colspan="4"><em>' . __( 'There are no questions matching your search.', 'woothemes-sensei' ) . '</em></td>
1298
+								<td class="no-results" colspan="4"><em>' . __('There are no questions matching your search.', 'woothemes-sensei').'</em></td>
1299 1299
 							  </tr>';
1300 1300
 			}
1301 1301
 
@@ -1303,53 +1303,53 @@  discard block
 block discarded – undo
1303 1303
 			$return['count'] = $questions['count'];
1304 1304
 			$return['page'] = $questions['page'];
1305 1305
 
1306
-			wp_send_json( $return );
1306
+			wp_send_json($return);
1307 1307
 		}
1308 1308
 
1309
-		die( $return );
1309
+		die($return);
1310 1310
 	}
1311 1311
 
1312
-	public function quiz_panel_question_field( $question_type = '', $question_id = 0, $question_counter = 0 ) {
1312
+	public function quiz_panel_question_field($question_type = '', $question_id = 0, $question_counter = 0) {
1313 1313
 
1314 1314
 		$html = '';
1315 1315
 
1316
-		if( $question_type ) {
1316
+		if ($question_type) {
1317 1317
 
1318 1318
 			$right_answer = '';
1319 1319
 			$wrong_answers = array();
1320 1320
 			$answer_order_string = '';
1321 1321
 			$answer_order = array();
1322
-			if( $question_id ) {
1323
-				$right_answer = get_post_meta( $question_id, '_question_right_answer', true);
1324
-				$wrong_answers = get_post_meta( $question_id, '_question_wrong_answers', true);
1325
-				$answer_order_string = get_post_meta( $question_id, '_answer_order', true );
1326
-				$answer_order = array_filter( explode( ',', $answer_order_string ) );
1322
+			if ($question_id) {
1323
+				$right_answer = get_post_meta($question_id, '_question_right_answer', true);
1324
+				$wrong_answers = get_post_meta($question_id, '_question_wrong_answers', true);
1325
+				$answer_order_string = get_post_meta($question_id, '_answer_order', true);
1326
+				$answer_order = array_filter(explode(',', $answer_order_string));
1327 1327
 				$question_class = '';
1328 1328
 			} else {
1329 1329
 				$question_id = '';
1330 1330
 				$question_class = 'answer-fields question_required_fields hidden';
1331 1331
 			}
1332 1332
 
1333
-			switch ( $question_type ) {
1333
+			switch ($question_type) {
1334 1334
 				case 'multiple-choice':
1335
-					$html .= '<div class="question_default_fields multiple-choice-answers ' . str_replace( ' hidden', '', $question_class ) . '">';
1335
+					$html .= '<div class="question_default_fields multiple-choice-answers '.str_replace(' hidden', '', $question_class).'">';
1336 1336
 
1337 1337
 						$right_answers = (array) $right_answer;
1338 1338
 						// Calculate total right answers available (defaults to 1)
1339 1339
 						$total_right = 0;
1340
-						if( $question_id ) {
1341
-							$total_right = get_post_meta( $question_id, '_right_answer_count', true );
1340
+						if ($question_id) {
1341
+							$total_right = get_post_meta($question_id, '_right_answer_count', true);
1342 1342
 						}
1343
-						if( 0 == intval( $total_right ) ) {
1343
+						if (0 == intval($total_right)) {
1344 1344
 							$total_right = 1;
1345 1345
 						}
1346
-						for ( $i = 0; $i < $total_right; $i++ ) {
1347
-							if ( !isset( $right_answers[ $i ] ) ) { $right_answers[ $i ] = ''; }
1348
-							$right_answer_id = $this->get_answer_id( $right_answers[ $i ] );
1346
+						for ($i = 0; $i < $total_right; $i++) {
1347
+							if ( ! isset($right_answers[$i])) { $right_answers[$i] = ''; }
1348
+							$right_answer_id = $this->get_answer_id($right_answers[$i]);
1349 1349
 							// Right Answer
1350
-							$right_answer = '<label class="answer" for="question_' . $question_counter . '_right_answer_' . $i . '"><span>' . __( 'Right:' , 'woothemes-sensei' ) . '</span> <input rel="' . esc_attr( $right_answer_id ) . '" type="text" id="question_' . $question_counter . '_right_answer_' . $i . '" name="question_right_answers[]" value="' . esc_attr( $right_answers[ $i ] ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1351
-							if( $question_id ) {
1352
-								$answers[ $right_answer_id ] = $right_answer;
1350
+							$right_answer = '<label class="answer" for="question_'.$question_counter.'_right_answer_'.$i.'"><span>'.__('Right:', 'woothemes-sensei').'</span> <input rel="'.esc_attr($right_answer_id).'" type="text" id="question_'.$question_counter.'_right_answer_'.$i.'" name="question_right_answers[]" value="'.esc_attr($right_answers[$i]).'" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1351
+							if ($question_id) {
1352
+								$answers[$right_answer_id] = $right_answer;
1353 1353
 							} else {
1354 1354
 								$answers[] = $right_answer;
1355 1355
 							}
@@ -1357,23 +1357,23 @@  discard block
 block discarded – undo
1357 1357
 
1358 1358
 				    	// Calculate total wrong answers available (defaults to 4)
1359 1359
 				    	$total_wrong = 0;
1360
-				    	if( $question_id ) {
1361
-				    		$total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true );
1360
+				    	if ($question_id) {
1361
+				    		$total_wrong = get_post_meta($question_id, '_wrong_answer_count', true);
1362 1362
 				    	}
1363
-				    	if( 0 == intval( $total_wrong ) ) {
1363
+				    	if (0 == intval($total_wrong)) {
1364 1364
 				    		$total_wrong = 1;
1365 1365
 				    	}
1366 1366
 
1367 1367
                         // Setup Wrong Answer HTML
1368
-                        foreach ( $wrong_answers as $i => $answer ){
1368
+                        foreach ($wrong_answers as $i => $answer) {
1369 1369
 
1370
-                            $answer_id = $this->get_answer_id( $answer );
1371
-                            $wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
1372
-                            $wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
1373
-                            $wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1374
-                            if( $question_id ) {
1370
+                            $answer_id = $this->get_answer_id($answer);
1371
+                            $wrong_answer = '<label class="answer" for="question_'.$question_counter.'_wrong_answer_'.$i.'"><span>'.__('Wrong:', 'woothemes-sensei');
1372
+                            $wrong_answer .= '</span> <input rel="'.esc_attr($answer_id).'" type="text" id="question_'.$question_counter.'_wrong_answer_'.$i;
1373
+                            $wrong_answer .= '" name="question_wrong_answers[]" value="'.esc_attr($answer).'" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1374
+                            if ($question_id) {
1375 1375
 
1376
-                                $answers[ $answer_id ] = $wrong_answer;
1376
+                                $answers[$answer_id] = $wrong_answer;
1377 1377
 
1378 1378
                             } else {
1379 1379
 
@@ -1384,115 +1384,115 @@  discard block
 block discarded – undo
1384 1384
                         } // end for each
1385 1385
 
1386 1386
 				    	$answers_sorted = $answers;
1387
-				    	if( $question_id && count( $answer_order ) > 0 ) {
1387
+				    	if ($question_id && count($answer_order) > 0) {
1388 1388
 				    		$answers_sorted = array();
1389
-				    		foreach( $answer_order as $answer_id ) {
1390
-				    			if( isset( $answers[ $answer_id ] ) ) {
1391
-				    				$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1392
-				    				unset( $answers[ $answer_id ] );
1389
+				    		foreach ($answer_order as $answer_id) {
1390
+				    			if (isset($answers[$answer_id])) {
1391
+				    				$answers_sorted[$answer_id] = $answers[$answer_id];
1392
+				    				unset($answers[$answer_id]);
1393 1393
 				    			}
1394 1394
 				    		}
1395 1395
 
1396
-				    		if( count( $answers ) > 0 ) {
1397
-						    	foreach( $answers as $id => $answer ) {
1398
-						    		$answers_sorted[ $id ] = $answer;
1396
+				    		if (count($answers) > 0) {
1397
+						    	foreach ($answers as $id => $answer) {
1398
+						    		$answers_sorted[$id] = $answer;
1399 1399
 						    	}
1400 1400
 						    }
1401 1401
 				    	}
1402 1402
 
1403
-						foreach( $answers_sorted as $id => $answer ) {
1403
+						foreach ($answers_sorted as $id => $answer) {
1404 1404
 				    		$html .= $answer;
1405 1405
 				    	}
1406 1406
 
1407
-				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />';
1408
-				    	$html .= '<span class="hidden right_answer_count">' . $total_right . '</span>';
1409
-				    	$html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>';
1407
+				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="'.$answer_order_string.'" />';
1408
+				    	$html .= '<span class="hidden right_answer_count">'.$total_right.'</span>';
1409
+				    	$html .= '<span class="hidden wrong_answer_count">'.$total_wrong.'</span>';
1410 1410
 
1411 1411
 				    	$html .= '<div class="add_answer_options">';
1412
-					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>';
1413
-					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>';
1412
+					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add right answer', 'woothemes-sensei').'</a>';
1413
+					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add wrong answer', 'woothemes-sensei').'</a>';
1414 1414
 				    	$html .= '</div>';
1415 1415
 
1416
-                        $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' );
1416
+                        $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'multiple-choice');
1417 1417
 
1418 1418
 			    	$html .= '</div>';
1419 1419
 				break;
1420 1420
 				case 'boolean':
1421
-					$html .= '<div class="question_boolean_fields ' . $question_class . '">';
1422
-						if( $question_id ) {
1423
-							$field_name = 'question_' . $question_id . '_right_answer_boolean';
1421
+					$html .= '<div class="question_boolean_fields '.$question_class.'">';
1422
+						if ($question_id) {
1423
+							$field_name = 'question_'.$question_id.'_right_answer_boolean';
1424 1424
 						} else {
1425 1425
 							$field_name = 'question_right_answer_boolean';
1426 1426
 							$right_answer = 'true';
1427 1427
 						}
1428
-						$html .= '<label for="question_' . $question_id . '_boolean_true"><input id="question_' . $question_id . '_boolean_true" type="radio" name="' . $field_name . '" value="true" '. checked( $right_answer, 'true', false ) . ' /> ' . __( 'True', 'woothemes-sensei' ) . '</label>';
1429
-						$html .= '<label for="question_' . $question_id . '_boolean_false"><input id="question_' . $question_id . '_boolean_false" type="radio" name="' . $field_name . '" value="false" '. checked( $right_answer, 'false', false ) . ' /> ' . __( 'False', 'woothemes-sensei' ) . '</label>';
1428
+						$html .= '<label for="question_'.$question_id.'_boolean_true"><input id="question_'.$question_id.'_boolean_true" type="radio" name="'.$field_name.'" value="true" '.checked($right_answer, 'true', false).' /> '.__('True', 'woothemes-sensei').'</label>';
1429
+						$html .= '<label for="question_'.$question_id.'_boolean_false"><input id="question_'.$question_id.'_boolean_false" type="radio" name="'.$field_name.'" value="false" '.checked($right_answer, 'false', false).' /> '.__('False', 'woothemes-sensei').'</label>';
1430 1430
 
1431
-                    $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' );
1431
+                    $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'boolean');
1432 1432
 
1433 1433
 					$html .= '</div>';
1434 1434
 				break;
1435 1435
 				case 'gap-fill':
1436
-					$gapfill_array = explode( '||', $right_answer );
1437
-					if ( isset( $gapfill_array[0] ) ) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; }
1438
-					if ( isset( $gapfill_array[1] ) ) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; }
1439
-					if ( isset( $gapfill_array[2] ) ) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; }
1440
-					$html .= '<div class="question_gapfill_fields ' . $question_class . '">';
1436
+					$gapfill_array = explode('||', $right_answer);
1437
+					if (isset($gapfill_array[0])) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; }
1438
+					if (isset($gapfill_array[1])) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; }
1439
+					if (isset($gapfill_array[2])) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; }
1440
+					$html .= '<div class="question_gapfill_fields '.$question_class.'">';
1441 1441
 						// Fill in the Gaps
1442
-						$html .= '<label>' . __( 'Text before the Gap:' , 'woothemes-sensei' ) . '</label> ';
1443
-						$html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_pre" name="add_question_right_answer_gapfill_pre" value="' . $gapfill_pre . '" size="25" class="widefat gapfill-field" />';
1444
-	  					$html .= '<label>' . __( 'The Gap:' , 'woothemes-sensei' ) . '</label> ';
1445
-	  					$html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_gap" name="add_question_right_answer_gapfill_gap" value="' . $gapfill_gap . '" size="25" class="widefat gapfill-field" />';
1446
-	  					$html .= '<label>' . __( 'Text after the Gap:' , 'woothemes-sensei' ) . '</label> ';
1447
-	  					$html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_post" name="add_question_right_answer_gapfill_post" value="' . $gapfill_post . '" size="25" class="widefat gapfill-field" />';
1448
-	  					$html .= '<label>' . __( 'Preview:' , 'woothemes-sensei' ) . '</label> ';
1449
-	  					$html .= '<p class="gapfill-preview">' . $gapfill_pre . '&nbsp;<u>' . $gapfill_gap . '</u>&nbsp;' . $gapfill_post . '</p>';
1442
+						$html .= '<label>'.__('Text before the Gap:', 'woothemes-sensei').'</label> ';
1443
+						$html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_pre" name="add_question_right_answer_gapfill_pre" value="'.$gapfill_pre.'" size="25" class="widefat gapfill-field" />';
1444
+	  					$html .= '<label>'.__('The Gap:', 'woothemes-sensei').'</label> ';
1445
+	  					$html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_gap" name="add_question_right_answer_gapfill_gap" value="'.$gapfill_gap.'" size="25" class="widefat gapfill-field" />';
1446
+	  					$html .= '<label>'.__('Text after the Gap:', 'woothemes-sensei').'</label> ';
1447
+	  					$html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_post" name="add_question_right_answer_gapfill_post" value="'.$gapfill_post.'" size="25" class="widefat gapfill-field" />';
1448
+	  					$html .= '<label>'.__('Preview:', 'woothemes-sensei').'</label> ';
1449
+	  					$html .= '<p class="gapfill-preview">'.$gapfill_pre.'&nbsp;<u>'.$gapfill_gap.'</u>&nbsp;'.$gapfill_post.'</p>';
1450 1450
 	  				$html .= '</div>';
1451 1451
 				break;
1452 1452
 				case 'multi-line':
1453
-					$html .= '<div class="question_multiline_fields ' . $question_class . '">';
1453
+					$html .= '<div class="question_multiline_fields '.$question_class.'">';
1454 1454
 						// Guides for grading
1455
-						if( $question_counter ) {
1456
-							$field_id = 'question_' . $question_counter . '_add_question_right_answer_multiline';
1455
+						if ($question_counter) {
1456
+							$field_id = 'question_'.$question_counter.'_add_question_right_answer_multiline';
1457 1457
 						} else {
1458 1458
 							$field_id = 'add_question_right_answer_multiline';
1459 1459
 						}
1460
-						$html .= '<label>' . __( 'Guide/Teacher Notes for grading the answer' , 'woothemes-sensei' ) . '</label> ';
1461
-						$html .= '<textarea id="' . $field_id . '" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>';
1460
+						$html .= '<label>'.__('Guide/Teacher Notes for grading the answer', 'woothemes-sensei').'</label> ';
1461
+						$html .= '<textarea id="'.$field_id.'" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>';
1462 1462
 					$html .= '</div>';
1463 1463
 				break;
1464 1464
 				case 'single-line':
1465
-					$html .= '<div class="question_singleline_fields ' . $question_class . '">';
1465
+					$html .= '<div class="question_singleline_fields '.$question_class.'">';
1466 1466
 						// Recommended Answer
1467
-						if( $question_counter ) {
1468
-							$field_id = 'question_' . $question_counter . '_add_question_right_answer_singleline';
1467
+						if ($question_counter) {
1468
+							$field_id = 'question_'.$question_counter.'_add_question_right_answer_singleline';
1469 1469
 						} else {
1470 1470
 							$field_id = 'add_question_right_answer_singleline';
1471 1471
 						}
1472
-						$html .= '<label>' . __( 'Recommended Answer' , 'woothemes-sensei' ) . '</label> ';
1473
-						$html .= '<input type="text" id="' . $field_id . '" name="add_question_right_answer_singleline" value="' . $right_answer . '" size="25" class="widefat" />';
1472
+						$html .= '<label>'.__('Recommended Answer', 'woothemes-sensei').'</label> ';
1473
+						$html .= '<input type="text" id="'.$field_id.'" name="add_question_right_answer_singleline" value="'.$right_answer.'" size="25" class="widefat" />';
1474 1474
 					$html .= '</div>';
1475 1475
 				break;
1476 1476
 				case 'file-upload':
1477
-					$html .= '<div class="question_fileupload_fields ' . $question_class . '">';
1478
-						if( $question_counter ) {
1479
-							$right_field_id = 'question_' . $question_counter . '_add_question_right_answer_fileupload';
1480
-							$wrong_field_id = 'question_' . $question_counter . '_add_question_wrong_answer_fileupload';
1477
+					$html .= '<div class="question_fileupload_fields '.$question_class.'">';
1478
+						if ($question_counter) {
1479
+							$right_field_id = 'question_'.$question_counter.'_add_question_right_answer_fileupload';
1480
+							$wrong_field_id = 'question_'.$question_counter.'_add_question_wrong_answer_fileupload';
1481 1481
 						} else {
1482 1482
 							$right_field_id = 'add_question_right_answer_fileupload';
1483 1483
 							$wrong_field_id = 'add_question_wrong_answer_fileupload';
1484 1484
 						}
1485 1485
 
1486 1486
 						$wrong_answer = '';
1487
-						if( isset( $wrong_answers[0] ) ) {
1487
+						if (isset($wrong_answers[0])) {
1488 1488
 							$wrong_answer = $wrong_answers[0];
1489 1489
 						}
1490
-						$html .= '<label>' . __( 'Description for student explaining what needs to be uploaded' , 'woothemes-sensei' ) . '</label> ';
1491
-						$html .= '<textarea id="' . $wrong_field_id . '" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">' . $wrong_answer . '</textarea>';
1490
+						$html .= '<label>'.__('Description for student explaining what needs to be uploaded', 'woothemes-sensei').'</label> ';
1491
+						$html .= '<textarea id="'.$wrong_field_id.'" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">'.$wrong_answer.'</textarea>';
1492 1492
 
1493 1493
 						// Guides for grading
1494
-						$html .= '<label>' . __( 'Guide/Teacher Notes for grading the upload' , 'woothemes-sensei' ) . '</label> ';
1495
-						$html .= '<textarea id="' . $right_field_id . '" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>';
1494
+						$html .= '<label>'.__('Guide/Teacher Notes for grading the upload', 'woothemes-sensei').'</label> ';
1495
+						$html .= '<textarea id="'.$right_field_id.'" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>';
1496 1496
 					$html .= '</div>';
1497 1497
 				break;
1498 1498
 			}
@@ -1501,32 +1501,32 @@  discard block
 block discarded – undo
1501 1501
 		return $html;
1502 1502
 	}
1503 1503
 
1504
-	public function quiz_panel_question_feedback( $question_counter = 0, $question_id = 0, $question_type = '' ) {
1504
+	public function quiz_panel_question_feedback($question_counter = 0, $question_id = 0, $question_type = '') {
1505 1505
 
1506 1506
         // default field name
1507 1507
         $field_name = 'answer_feedback';
1508
-        if( 'boolean' == $question_type ){
1508
+        if ('boolean' == $question_type) {
1509 1509
 
1510 1510
             $field_name = 'answer_feedback_boolean';
1511 1511
 
1512
-        }elseif( 'multiple-choice' == $question_type ){
1512
+        }elseif ('multiple-choice' == $question_type) {
1513 1513
 
1514 1514
             $field_name = 'answer_feedback_multiple_choice';
1515 1515
 
1516 1516
         }// end if
1517 1517
 
1518
-		if( $question_counter ) {
1519
-			$field_name = 'answer_' . $question_counter . '_feedback';
1518
+		if ($question_counter) {
1519
+			$field_name = 'answer_'.$question_counter.'_feedback';
1520 1520
 		}
1521 1521
 
1522 1522
 		$feedback = '';
1523
-		if( $question_id ) {
1524
-			$feedback = get_post_meta( $question_id, '_answer_feedback', true );
1523
+		if ($question_id) {
1524
+			$feedback = get_post_meta($question_id, '_answer_feedback', true);
1525 1525
 		}
1526 1526
 
1527
-		$html = '<p title="' . __( 'This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei' ) . '">';
1528
-		$html .= '<label for="' . $field_name . '">' . __( 'Answer Feedback' , 'woothemes-sensei' ) . ':</label>';
1529
-		$html .= '<textarea id="' . $field_name . '" name="' . $field_name . '" rows="4" cols="40" class="answer_feedback widefat">' . $feedback . '</textarea>';
1527
+		$html = '<p title="'.__('This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei').'">';
1528
+		$html .= '<label for="'.$field_name.'">'.__('Answer Feedback', 'woothemes-sensei').':</label>';
1529
+		$html .= '<textarea id="'.$field_name.'" name="'.$field_name.'" rows="4" cols="40" class="answer_feedback widefat">'.$feedback.'</textarea>';
1530 1530
 		$html .= '</p>';
1531 1531
 
1532 1532
 		return $html;
@@ -1535,19 +1535,19 @@  discard block
 block discarded – undo
1535 1535
 	public function question_get_answer_id() {
1536 1536
 		$data = $_POST['data'];
1537 1537
 		$answer_data = array();
1538
-		parse_str( $data, $answer_data );
1538
+		parse_str($data, $answer_data);
1539 1539
 		$answer = $answer_data['answer_value'];
1540
-		$answer_id = $this->get_answer_id( $answer );
1540
+		$answer_id = $this->get_answer_id($answer);
1541 1541
 		echo $answer_id;
1542 1542
 		die();
1543 1543
 	}
1544 1544
 
1545
-	public function get_answer_id( $answer = '' ) {
1545
+	public function get_answer_id($answer = '') {
1546 1546
 
1547 1547
 		$answer_id = '';
1548 1548
 
1549
-		if( $answer ) {
1550
-			$answer_id = md5( $answer );
1549
+		if ($answer) {
1550
+			$answer_id = md5($answer);
1551 1551
 		}
1552 1552
 
1553 1553
 		return $answer_id;
@@ -1560,17 +1560,17 @@  discard block
 block discarded – undo
1560 1560
 	 * @access public
1561 1561
 	 * @return void
1562 1562
 	 */
1563
-	public function lesson_quiz_meta_box_content () {
1563
+	public function lesson_quiz_meta_box_content() {
1564 1564
 		global $post;
1565 1565
 
1566 1566
 		// Get quiz panel
1567 1567
 		$quiz_id = 0;
1568 1568
 		$quizzes = array();
1569
-		if ( 0 < $post->ID ) {
1570
-			$quiz_id = $this->lesson_quizzes( $post->ID, 'any' );
1569
+		if (0 < $post->ID) {
1570
+			$quiz_id = $this->lesson_quizzes($post->ID, 'any');
1571 1571
 		}
1572 1572
 
1573
-		echo $this->quiz_panel( $quiz_id );
1573
+		echo $this->quiz_panel($quiz_id);
1574 1574
 
1575 1575
 	} // End lesson_quiz_meta_box_content()
1576 1576
 
@@ -1587,53 +1587,53 @@  discard block
 block discarded – undo
1587 1587
 		$quiz_id = 0;
1588 1588
 		$lesson_id = $post->ID;
1589 1589
 		$quizzes = array();
1590
-		if ( 0 < $lesson_id ) {
1591
-			$quiz_id = $this->lesson_quizzes( $lesson_id, 'any' );
1590
+		if (0 < $lesson_id) {
1591
+			$quiz_id = $this->lesson_quizzes($lesson_id, 'any');
1592 1592
 		}
1593 1593
 
1594
-		if( $quiz_id ) {
1595
-			$html .= $this->quiz_settings_panel( $lesson_id, $quiz_id );
1594
+		if ($quiz_id) {
1595
+			$html .= $this->quiz_settings_panel($lesson_id, $quiz_id);
1596 1596
 		} else {
1597
-			$html .= '<p><em>' . __( 'There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei' ) . '</em></p>';
1597
+			$html .= '<p><em>'.__('There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei').'</em></p>';
1598 1598
 		}
1599 1599
 
1600 1600
 		echo $html;
1601 1601
 	}
1602 1602
 
1603
-	public function quiz_settings_panel( $lesson_id = 0, $quiz_id = 0 ) {
1603
+	public function quiz_settings_panel($lesson_id = 0, $quiz_id = 0) {
1604 1604
 
1605 1605
 
1606 1606
 		$html = '';
1607 1607
 
1608
-		if( ! $lesson_id && ! $quiz_id ) return $html;
1608
+		if ( ! $lesson_id && ! $quiz_id) return $html;
1609 1609
 
1610
-		$settings = $this->get_quiz_settings( $quiz_id );
1610
+		$settings = $this->get_quiz_settings($quiz_id);
1611 1611
 
1612
-		$html = Sensei()->admin->render_settings( $settings, $quiz_id, 'quiz-settings' );
1612
+		$html = Sensei()->admin->render_settings($settings, $quiz_id, 'quiz-settings');
1613 1613
 
1614 1614
 		return $html;
1615 1615
 
1616 1616
 	}
1617 1617
 
1618
-	public function get_quiz_settings( $quiz_id = 0 ) {
1618
+	public function get_quiz_settings($quiz_id = 0) {
1619 1619
 
1620 1620
 		$disable_passmark = '';
1621
-		$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
1622
-		if( ! $pass_required ) {
1621
+		$pass_required = get_post_meta($quiz_id, '_pass_required', true);
1622
+		if ( ! $pass_required) {
1623 1623
 			$disable_passmark = 'hidden';
1624 1624
 		}
1625 1625
 
1626 1626
 		// Setup Questions Query
1627 1627
 		$questions = array();
1628
-		if ( 0 < $quiz_id ) {
1629
-			$questions = $this->lesson_quiz_questions( $quiz_id );
1628
+		if (0 < $quiz_id) {
1629
+			$questions = $this->lesson_quiz_questions($quiz_id);
1630 1630
 		}
1631 1631
 
1632 1632
 		// Count questions
1633 1633
 		$question_count = 0;
1634
-		foreach( $questions as $question ) {
1635
-			if( $question->post_type == 'multiple_question' ) {
1636
-				$question_number = get_post_meta( $question->ID, 'number', true );
1634
+		foreach ($questions as $question) {
1635
+			if ($question->post_type == 'multiple_question') {
1636
+				$question_number = get_post_meta($question->ID, 'number', true);
1637 1637
 				$question_count += $question_number;
1638 1638
 			} else {
1639 1639
 				++$question_count;
@@ -1643,15 +1643,15 @@  discard block
 block discarded – undo
1643 1643
 		$settings = array(
1644 1644
 			array(
1645 1645
 				'id' 			=> 'pass_required',
1646
-				'label'			=> __( 'Pass required to complete lesson', 'woothemes-sensei' ),
1647
-				'description'	=> __( 'The passmark must be achieved before the lesson is complete.', 'woothemes-sensei' ),
1646
+				'label'			=> __('Pass required to complete lesson', 'woothemes-sensei'),
1647
+				'description'	=> __('The passmark must be achieved before the lesson is complete.', 'woothemes-sensei'),
1648 1648
 				'type'			=> 'checkbox',
1649 1649
 				'default'		=> '',
1650 1650
 				'checked'		=> 'on',
1651 1651
 			),
1652 1652
 			array(
1653 1653
 				'id' 			=> 'quiz_passmark',
1654
-				'label'			=> __( 'Quiz passmark percentage', 'woothemes-sensei' ),
1654
+				'label'			=> __('Quiz passmark percentage', 'woothemes-sensei'),
1655 1655
 				'description'	=> '',
1656 1656
 				'type'			=> 'number',
1657 1657
 				'default'		=> 0,
@@ -1662,17 +1662,17 @@  discard block
 block discarded – undo
1662 1662
 			),
1663 1663
 			array(
1664 1664
 				'id' 			=> 'show_questions',
1665
-				'label'			=> __( 'Number of questions to show', 'woothemes-sensei' ),
1666
-				'description'	=> __( 'Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei' ),
1665
+				'label'			=> __('Number of questions to show', 'woothemes-sensei'),
1666
+				'description'	=> __('Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei'),
1667 1667
 				'type'			=> 'number',
1668 1668
 				'default'		=> '',
1669
-				'placeholder'	=> __( 'All', 'woothemes-sensei' ),
1669
+				'placeholder'	=> __('All', 'woothemes-sensei'),
1670 1670
 				'min'			=> 1,
1671 1671
 				'max'			=> $question_count,
1672 1672
 			),
1673 1673
 			array(
1674 1674
 				'id' 			=> 'random_question_order',
1675
-				'label'			=> __( 'Randomise question order', 'woothemes-sensei' ),
1675
+				'label'			=> __('Randomise question order', 'woothemes-sensei'),
1676 1676
 				'description'	=> '',
1677 1677
 				'type'			=> 'checkbox',
1678 1678
 				'default'		=> 'no',
@@ -1680,23 +1680,23 @@  discard block
 block discarded – undo
1680 1680
 			),
1681 1681
 			array(
1682 1682
 				'id' 			=> 'quiz_grade_type',
1683
-				'label'			=> __( 'Grade quiz automatically', 'woothemes-sensei' ),
1684
-				'description'	=> __( 'Grades quiz and displays answer explanation immediately after completion. Only applicable if quiz is limited to Multiple Choice, True/False and Gap Fill questions. Questions that have a grade of zero are skipped during autograding.', 'woothemes-sensei' ),
1683
+				'label'			=> __('Grade quiz automatically', 'woothemes-sensei'),
1684
+				'description'	=> __('Grades quiz and displays answer explanation immediately after completion. Only applicable if quiz is limited to Multiple Choice, True/False and Gap Fill questions. Questions that have a grade of zero are skipped during autograding.', 'woothemes-sensei'),
1685 1685
 				'type'			=> 'checkbox',
1686 1686
 				'default'		=> 'auto',
1687 1687
 				'checked'		=> 'auto',
1688 1688
 			),
1689 1689
 			array(
1690 1690
 				'id' 			=> 'enable_quiz_reset',
1691
-				'label'			=> __( 'Allow user to retake the quiz', 'woothemes-sensei' ),
1692
-				'description'	=> __( 'Enables the quiz reset button.', 'woothemes-sensei' ),
1691
+				'label'			=> __('Allow user to retake the quiz', 'woothemes-sensei'),
1692
+				'description'	=> __('Enables the quiz reset button.', 'woothemes-sensei'),
1693 1693
 				'type'			=> 'checkbox',
1694 1694
 				'default'		=> '',
1695 1695
 				'checked'		=> 'on',
1696 1696
 			),
1697 1697
 		);
1698 1698
 
1699
-		return apply_filters( 'sensei_quiz_settings', $settings );
1699
+		return apply_filters('sensei_quiz_settings', $settings);
1700 1700
 	}
1701 1701
 
1702 1702
 	/**
@@ -1705,38 +1705,38 @@  discard block
 block discarded – undo
1705 1705
 	 * @access public
1706 1706
 	 * @return void
1707 1707
 	 */
1708
-	public function enqueue_scripts( $hook ) {
1708
+	public function enqueue_scripts($hook) {
1709 1709
 		global  $post_type;
1710 1710
 
1711
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) );
1712
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
1713
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order' ) );
1711
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question'));
1712
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
1713
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order'));
1714 1714
 
1715 1715
 		// Test for Write Panel Pages
1716
-		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
1716
+		if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) {
1717 1717
 
1718
-			$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
1718
+			$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
1719 1719
 
1720 1720
 			// Load the lessons script
1721 1721
             wp_enqueue_media();
1722
-			wp_enqueue_script( 'sensei-lesson-metadata', Sensei()->plugin_url . 'assets/js/lesson-metadata' . $suffix . '.js', array( 'jquery', 'sensei-core-select2' ,'jquery-ui-sortable' ), Sensei()->version, true );
1723
-			wp_enqueue_script( 'sensei-lesson-chosen', Sensei()->plugin_url . 'assets/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1724
-			wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'sensei-lesson-chosen' ), Sensei()->version, true );
1722
+			wp_enqueue_script('sensei-lesson-metadata', Sensei()->plugin_url.'assets/js/lesson-metadata'.$suffix.'.js', array('jquery', 'sensei-core-select2', 'jquery-ui-sortable'), Sensei()->version, true);
1723
+			wp_enqueue_script('sensei-lesson-chosen', Sensei()->plugin_url.'assets/chosen/chosen.jquery'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1724
+			wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery'.$suffix.'.js', array('jquery', 'sensei-lesson-chosen'), Sensei()->version, true);
1725 1725
 
1726 1726
             // Load the bulk edit screen script
1727
-            if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) {
1728
-                wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true);
1727
+            if ('edit.php' == $hook && 'lesson' == $_GET['post_type']) {
1728
+                wp_enqueue_script('sensei-lessons-bulk-edit', Sensei()->plugin_url.'assets/js/admin/lesson-bulk-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1729 1729
             }
1730 1730
 
1731 1731
 			// Localise script
1732
-			$translation_strings = array( 'right_colon' => __( 'Right:', 'woothemes-sensei' ), 'wrong_colon' => __( 'Wrong:', 'woothemes-sensei' ), 'add_file' => __( 'Add file', 'woothemes-sensei' ), 'change_file' => __( 'Change file', 'woothemes-sensei' ), 'confirm_remove' => __( 'Are you sure you want to remove this question?', 'woothemes-sensei' ), 'confirm_remove_multiple' => __( 'Are you sure you want to remove these questions?', 'woothemes-sensei' ), 'too_many_for_cat' => __( 'You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei' ) );
1733
-			$ajax_vars = array( 'lesson_update_question_nonce' => wp_create_nonce( 'lesson_update_question_nonce' ), 'lesson_add_course_nonce' => wp_create_nonce( 'lesson_add_course_nonce' ), 'lesson_update_grade_type_nonce' => wp_create_nonce( 'lesson_update_grade_type_nonce' ), 'lesson_update_question_order_nonce' => wp_create_nonce( 'lesson_update_question_order_nonce' ), 'lesson_update_question_order_random_nonce' => wp_create_nonce( 'lesson_update_question_order_random_nonce' ), 'lesson_add_multiple_questions_nonce' => wp_create_nonce( 'lesson_add_multiple_questions_nonce' ), 'lesson_remove_multiple_questions_nonce' => wp_create_nonce( 'lesson_remove_multiple_questions_nonce' ), 'lesson_add_existing_questions_nonce' => wp_create_nonce( 'lesson_add_existing_questions_nonce' ), 'filter_existing_questions_nonce' => wp_create_nonce( 'filter_existing_questions_nonce' ) );
1734
-			$data = array_merge( $translation_strings, $ajax_vars );
1735
-			wp_localize_script( 'sensei-lesson-metadata', 'woo_localized_data', $data );
1732
+			$translation_strings = array('right_colon' => __('Right:', 'woothemes-sensei'), 'wrong_colon' => __('Wrong:', 'woothemes-sensei'), 'add_file' => __('Add file', 'woothemes-sensei'), 'change_file' => __('Change file', 'woothemes-sensei'), 'confirm_remove' => __('Are you sure you want to remove this question?', 'woothemes-sensei'), 'confirm_remove_multiple' => __('Are you sure you want to remove these questions?', 'woothemes-sensei'), 'too_many_for_cat' => __('You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei'));
1733
+			$ajax_vars = array('lesson_update_question_nonce' => wp_create_nonce('lesson_update_question_nonce'), 'lesson_add_course_nonce' => wp_create_nonce('lesson_add_course_nonce'), 'lesson_update_grade_type_nonce' => wp_create_nonce('lesson_update_grade_type_nonce'), 'lesson_update_question_order_nonce' => wp_create_nonce('lesson_update_question_order_nonce'), 'lesson_update_question_order_random_nonce' => wp_create_nonce('lesson_update_question_order_random_nonce'), 'lesson_add_multiple_questions_nonce' => wp_create_nonce('lesson_add_multiple_questions_nonce'), 'lesson_remove_multiple_questions_nonce' => wp_create_nonce('lesson_remove_multiple_questions_nonce'), 'lesson_add_existing_questions_nonce' => wp_create_nonce('lesson_add_existing_questions_nonce'), 'filter_existing_questions_nonce' => wp_create_nonce('filter_existing_questions_nonce'));
1734
+			$data = array_merge($translation_strings, $ajax_vars);
1735
+			wp_localize_script('sensei-lesson-metadata', 'woo_localized_data', $data);
1736 1736
 
1737 1737
 			// Chosen RTL
1738
-			if ( is_rtl() ) {
1739
-				wp_enqueue_script( 'sensei-chosen-rtl', Sensei()->plugin_url . 'assets/chosen/chosen-rtl' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1738
+			if (is_rtl()) {
1739
+				wp_enqueue_script('sensei-chosen-rtl', Sensei()->plugin_url.'assets/chosen/chosen-rtl'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1740 1740
 			}
1741 1741
 
1742 1742
 		}
@@ -1750,16 +1750,16 @@  discard block
 block discarded – undo
1750 1750
 	 * @since  1.4.0
1751 1751
 	 * @return void
1752 1752
 	 */
1753
-	public function enqueue_styles ( $hook ) {
1753
+	public function enqueue_styles($hook) {
1754 1754
 		global  $post_type;
1755 1755
 
1756
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question', 'sensei_message' ) );
1757
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
1758
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings' ) );
1756
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question', 'sensei_message'));
1757
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
1758
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings'));
1759 1759
 
1760 1760
 		// Test for Write Panel Pages
1761
-		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
1762
-			wp_enqueue_style( 'woothemes-sensei-settings-api', esc_url( Sensei()->plugin_url . 'assets/css/settings.css' ), '', Sensei()->version );
1761
+		if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) {
1762
+			wp_enqueue_style('woothemes-sensei-settings-api', esc_url(Sensei()->plugin_url.'assets/css/settings.css'), '', Sensei()->version);
1763 1763
 		}
1764 1764
 
1765 1765
 	} // End enqueue_styles()
@@ -1771,12 +1771,12 @@  discard block
 block discarded – undo
1771 1771
 	 * @param  array $defaults
1772 1772
 	 * @return array $new_columns
1773 1773
 	 */
1774
-	public function add_column_headings ( $defaults ) {
1774
+	public function add_column_headings($defaults) {
1775 1775
 		$new_columns['cb'] = '<input type="checkbox" />';
1776
-		$new_columns['title'] = _x( 'Lesson Title', 'column name', 'woothemes-sensei' );
1777
-		$new_columns['lesson-course'] = _x( 'Course', 'column name', 'woothemes-sensei' );
1778
-		$new_columns['lesson-prerequisite'] = _x( 'Pre-requisite Lesson', 'column name', 'woothemes-sensei' );
1779
-		if ( isset( $defaults['date'] ) ) {
1776
+		$new_columns['title'] = _x('Lesson Title', 'column name', 'woothemes-sensei');
1777
+		$new_columns['lesson-course'] = _x('Course', 'column name', 'woothemes-sensei');
1778
+		$new_columns['lesson-prerequisite'] = _x('Pre-requisite Lesson', 'column name', 'woothemes-sensei');
1779
+		if (isset($defaults['date'])) {
1780 1780
 			$new_columns['date'] = $defaults['date'];
1781 1781
 		}
1782 1782
 		return $new_columns;
@@ -1790,23 +1790,23 @@  discard block
 block discarded – undo
1790 1790
 	 * @param  int $id
1791 1791
 	 * @return void
1792 1792
 	 */
1793
-	public function add_column_data ( $column_name, $id ) {
1793
+	public function add_column_data($column_name, $id) {
1794 1794
 		global $wpdb, $post;
1795 1795
 
1796
-		switch ( $column_name ) {
1796
+		switch ($column_name) {
1797 1797
 			case 'id':
1798 1798
 				echo $id;
1799 1799
 			break;
1800 1800
 			case 'lesson-course':
1801
-				$lesson_course_id = get_post_meta( $id, '_lesson_course', true);
1802
-				if ( 0 < absint( $lesson_course_id ) ) {
1803
-					echo '<a href="' . esc_url( get_edit_post_link( absint( $lesson_course_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $lesson_course_id ) ) ) ) . '">' . get_the_title( absint( $lesson_course_id ) ) . '</a>';
1801
+				$lesson_course_id = get_post_meta($id, '_lesson_course', true);
1802
+				if (0 < absint($lesson_course_id)) {
1803
+					echo '<a href="'.esc_url(get_edit_post_link(absint($lesson_course_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($lesson_course_id)))).'">'.get_the_title(absint($lesson_course_id)).'</a>';
1804 1804
 				} // End If Statement
1805 1805
 			break;
1806 1806
 			case 'lesson-prerequisite':
1807
-				$lesson_prerequisite_id = get_post_meta( $id, '_lesson_prerequisite', true);
1808
-				if ( 0 < absint( $lesson_prerequisite_id ) ) {
1809
-					echo '<a href="' . esc_url( get_edit_post_link( absint( $lesson_prerequisite_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $lesson_prerequisite_id ) ) ) ) . '">' . get_the_title( absint( $lesson_prerequisite_id ) ) . '</a>';
1807
+				$lesson_prerequisite_id = get_post_meta($id, '_lesson_prerequisite', true);
1808
+				if (0 < absint($lesson_prerequisite_id)) {
1809
+					echo '<a href="'.esc_url(get_edit_post_link(absint($lesson_prerequisite_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($lesson_prerequisite_id)))).'">'.get_the_title(absint($lesson_prerequisite_id)).'</a>';
1810 1810
 				} // End If Statement
1811 1811
 			break;
1812 1812
 			default:
@@ -1820,14 +1820,14 @@  discard block
 block discarded – undo
1820 1820
 	 * @access public
1821 1821
 	 * @return void
1822 1822
 	 */
1823
-	public function lesson_add_course () {
1823
+	public function lesson_add_course() {
1824 1824
 		global $current_user;
1825 1825
 		//Add nonce security to the request
1826
-		if ( isset($_POST['lesson_add_course_nonce']) ) {
1827
-			$nonce = esc_html( $_POST['lesson_add_course_nonce'] );
1826
+		if (isset($_POST['lesson_add_course_nonce'])) {
1827
+			$nonce = esc_html($_POST['lesson_add_course_nonce']);
1828 1828
 		} // End If Statement
1829
-		if ( ! wp_verify_nonce( $nonce, 'lesson_add_course_nonce' )
1830
-            || ! current_user_can( 'edit_lessons' ) ) {
1829
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_course_nonce')
1830
+            || ! current_user_can('edit_lessons')) {
1831 1831
 			die('');
1832 1832
 		} // End If Statement
1833 1833
 		// Parse POST data
@@ -1849,14 +1849,14 @@  discard block
 block discarded – undo
1849 1849
 	 * @access public
1850 1850
 	 * @return void
1851 1851
 	 */
1852
-	public function lesson_update_question () {
1852
+	public function lesson_update_question() {
1853 1853
 		global $current_user;
1854 1854
 		//Add nonce security to the request
1855
-		if ( isset($_POST['lesson_update_question_nonce']) ) {
1856
-			$nonce = esc_html( $_POST['lesson_update_question_nonce'] );
1855
+		if (isset($_POST['lesson_update_question_nonce'])) {
1856
+			$nonce = esc_html($_POST['lesson_update_question_nonce']);
1857 1857
 		} // End If Statement
1858
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_nonce' )
1859
-            ||  ! current_user_can( 'edit_questions' )) {
1858
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_nonce')
1859
+            ||  ! current_user_can('edit_questions')) {
1860 1860
 
1861 1861
 			die('');
1862 1862
 
@@ -1866,30 +1866,30 @@  discard block
 block discarded – undo
1866 1866
 		// WP slashes all incoming data regardless of Magic Quotes setting (see wp_magic_quotes()), which means that
1867 1867
 		// even the $_POST['data'] encoded with encodeURIComponent has it's apostrophes slashed.
1868 1868
 		// So first restore the original unslashed apostrophes by removing those slashes
1869
-		$data = wp_unslash( $_POST['data'] );
1869
+		$data = wp_unslash($_POST['data']);
1870 1870
 		// Then parse the string to an array (note that parse_str automatically urldecodes all the variables)
1871 1871
 		$question_data = array();
1872 1872
 		parse_str($data, $question_data);
1873 1873
 		// Finally re-slash all elements to ensure consistancy for lesson_save_question()
1874
-		$question_data = wp_slash( $question_data );
1874
+		$question_data = wp_slash($question_data);
1875 1875
 		// Save the question
1876 1876
 		$return = false;
1877 1877
 		// Question Save and Delete logic
1878
-		if ( isset( $question_data['action'] ) && ( $question_data['action'] == 'delete' ) ) {
1878
+		if (isset($question_data['action']) && ($question_data['action'] == 'delete')) {
1879 1879
 			// Delete the Question
1880 1880
 			$return = $this->lesson_delete_question($question_data);
1881 1881
 		} else {
1882 1882
 			// Save the Question
1883
-			if ( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) {
1883
+			if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) {
1884 1884
 				$current_user = wp_get_current_user();
1885 1885
 				$question_data['post_author'] = $current_user->ID;
1886
-				$question_id = $this->lesson_save_question( $question_data );
1887
-				$question_type = Sensei()->question->get_question_type( $question_id );
1886
+				$question_id = $this->lesson_save_question($question_data);
1887
+				$question_type = Sensei()->question->get_question_type($question_id);
1888 1888
 
1889
-				$question_count = intval( $question_data['question_count'] );
1889
+				$question_count = intval($question_data['question_count']);
1890 1890
 				++$question_count;
1891 1891
 
1892
-				$return = $this->quiz_panel_question( $question_type, $question_count, $question_id );
1892
+				$return = $this->quiz_panel_question($question_type, $question_count, $question_id);
1893 1893
 			} // End If Statement
1894 1894
 		} // End If Statement
1895 1895
 
@@ -1904,49 +1904,49 @@  discard block
 block discarded – undo
1904 1904
 
1905 1905
 		//Add nonce security to the request
1906 1906
 		$nonce = '';
1907
-		if( isset( $_POST['lesson_add_multiple_questions_nonce'] ) ) {
1908
-			$nonce = esc_html( $_POST['lesson_add_multiple_questions_nonce'] );
1907
+		if (isset($_POST['lesson_add_multiple_questions_nonce'])) {
1908
+			$nonce = esc_html($_POST['lesson_add_multiple_questions_nonce']);
1909 1909
 		} // End If Statement
1910 1910
 
1911
-		if( ! wp_verify_nonce( $nonce, 'lesson_add_multiple_questions_nonce' )
1912
-            || ! current_user_can( 'edit_lessons' ) ) {
1913
-			die( $return );
1911
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_multiple_questions_nonce')
1912
+            || ! current_user_can('edit_lessons')) {
1913
+			die($return);
1914 1914
 		} // End If Statement
1915 1915
 
1916 1916
 		// Parse POST data
1917 1917
 		$data = $_POST['data'];
1918 1918
 		$question_data = array();
1919
-		parse_str( $data, $question_data );
1919
+		parse_str($data, $question_data);
1920 1920
 
1921
-		if( is_array( $question_data ) ) {
1922
-			if( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) {
1921
+		if (is_array($question_data)) {
1922
+			if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) {
1923 1923
 
1924
-				$quiz_id = intval( $question_data['quiz_id'] );
1925
-				$question_number = intval( $question_data['question_number'] );
1926
-				$question_category = intval( $question_data['question_category'] );
1924
+				$quiz_id = intval($question_data['quiz_id']);
1925
+				$question_number = intval($question_data['question_number']);
1926
+				$question_category = intval($question_data['question_category']);
1927 1927
 
1928
-				$question_counter = intval( $question_data['question_count'] );
1928
+				$question_counter = intval($question_data['question_count']);
1929 1929
 				++$question_counter;
1930 1930
 
1931
-				$cat = get_term( $question_category, 'question-category' );
1931
+				$cat = get_term($question_category, 'question-category');
1932 1932
 
1933 1933
 				$post_data = array(
1934 1934
 					'post_content' => '',
1935 1935
 					'post_status' => 'publish',
1936
-					'post_title' => sprintf( __( '%1$s Question(s) from %2$s', 'woothemes-sensei' ), $question_number, $cat->name ),
1936
+					'post_title' => sprintf(__('%1$s Question(s) from %2$s', 'woothemes-sensei'), $question_number, $cat->name),
1937 1937
 					'post_type' => 'multiple_question'
1938 1938
 				);
1939 1939
 
1940
-				$multiple_id = wp_insert_post( $post_data );
1940
+				$multiple_id = wp_insert_post($post_data);
1941 1941
 
1942
-				if( $multiple_id && ! is_wp_error( $multiple_id ) ) {
1943
-					add_post_meta( $multiple_id, 'category', $question_category );
1944
-					add_post_meta( $multiple_id, 'number', $question_number );
1945
-					add_post_meta( $multiple_id, '_quiz_id', $quiz_id, false );
1946
-					add_post_meta( $multiple_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_counter );
1947
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
1948
-					update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
1949
-					$return = $this->quiz_panel_question( 'category', $question_counter, $multiple_id, 'quiz', array( $cat->name, $question_number ) );
1942
+				if ($multiple_id && ! is_wp_error($multiple_id)) {
1943
+					add_post_meta($multiple_id, 'category', $question_category);
1944
+					add_post_meta($multiple_id, 'number', $question_number);
1945
+					add_post_meta($multiple_id, '_quiz_id', $quiz_id, false);
1946
+					add_post_meta($multiple_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_counter);
1947
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
1948
+					update_post_meta($lesson_id, '_quiz_has_questions', '1');
1949
+					$return = $this->quiz_panel_question('category', $question_counter, $multiple_id, 'quiz', array($cat->name, $question_number));
1950 1950
 				}
1951 1951
 			}
1952 1952
 		}
@@ -1960,25 +1960,25 @@  discard block
 block discarded – undo
1960 1960
 
1961 1961
 		//Add nonce security to the request
1962 1962
 		$nonce = '';
1963
-		if( isset( $_POST['lesson_remove_multiple_questions_nonce'] ) ) {
1964
-			$nonce = esc_html( $_POST['lesson_remove_multiple_questions_nonce'] );
1963
+		if (isset($_POST['lesson_remove_multiple_questions_nonce'])) {
1964
+			$nonce = esc_html($_POST['lesson_remove_multiple_questions_nonce']);
1965 1965
 		} // End If Statement
1966 1966
 
1967
-		if( ! wp_verify_nonce( $nonce, 'lesson_remove_multiple_questions_nonce' )
1968
-        || ! current_user_can( 'edit_lessons' ) ) {
1967
+		if ( ! wp_verify_nonce($nonce, 'lesson_remove_multiple_questions_nonce')
1968
+        || ! current_user_can('edit_lessons')) {
1969 1969
 			die('');
1970 1970
 		} // End If Statement
1971 1971
 
1972 1972
 		// Parse POST data
1973 1973
 		$data = $_POST['data'];
1974 1974
 		$question_data = array();
1975
-		parse_str( $data, $question_data );
1975
+		parse_str($data, $question_data);
1976 1976
 
1977
-		if( is_array( $question_data ) ) {
1978
-			wp_delete_post( $question_data['question_id'], true );
1977
+		if (is_array($question_data)) {
1978
+			wp_delete_post($question_data['question_id'], true);
1979 1979
 		}
1980 1980
 
1981
-		die( 'Deleted' );
1981
+		die('Deleted');
1982 1982
 	}
1983 1983
 
1984 1984
 	public function get_question_category_limit() {
@@ -1989,11 +1989,11 @@  discard block
 block discarded – undo
1989 1989
 		// Parse POST data
1990 1990
 		$data = $_POST['data'];
1991 1991
 		$cat_data = array();
1992
-		parse_str( $data, $cat_data );
1992
+		parse_str($data, $cat_data);
1993 1993
 
1994
-		if( isset( $cat_data['cat'] ) && '' != $cat_data['cat'] ) {
1995
-			$cat = get_term( $cat_data['cat'], 'question-category' );
1996
-			if( isset( $cat->count ) ) {
1994
+		if (isset($cat_data['cat']) && '' != $cat_data['cat']) {
1995
+			$cat = get_term($cat_data['cat'], 'question-category');
1996
+			if (isset($cat->count)) {
1997 1997
 				$return = $cat->count;
1998 1998
 			}
1999 1999
 		}
@@ -2007,45 +2007,45 @@  discard block
 block discarded – undo
2007 2007
 
2008 2008
 		//Add nonce security to the request
2009 2009
 		$nonce = '';
2010
-		if( isset( $_POST['lesson_add_existing_questions_nonce'] ) ) {
2011
-			$nonce = esc_html( $_POST['lesson_add_existing_questions_nonce'] );
2010
+		if (isset($_POST['lesson_add_existing_questions_nonce'])) {
2011
+			$nonce = esc_html($_POST['lesson_add_existing_questions_nonce']);
2012 2012
 		} // End If Statement
2013 2013
 
2014
-		if( ! wp_verify_nonce( $nonce, 'lesson_add_existing_questions_nonce' )
2015
-        || ! current_user_can( 'edit_lessons' ) ) {
2014
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_existing_questions_nonce')
2015
+        || ! current_user_can('edit_lessons')) {
2016 2016
 			die('');
2017 2017
 		} // End If Statement
2018 2018
 
2019 2019
 		// Parse POST data
2020 2020
 		$data = $_POST['data'];
2021 2021
 		$question_data = array();
2022
-		parse_str( $data, $question_data );
2022
+		parse_str($data, $question_data);
2023 2023
 
2024 2024
 		$return = '';
2025 2025
 
2026
-		if( is_array( $question_data ) ) {
2026
+		if (is_array($question_data)) {
2027 2027
 
2028
-			if( isset( $question_data['questions'] ) && '' != $question_data['questions'] ) {
2028
+			if (isset($question_data['questions']) && '' != $question_data['questions']) {
2029 2029
 
2030
-				$questions = explode( ',', trim( $question_data['questions'], ',' ) );
2030
+				$questions = explode(',', trim($question_data['questions'], ','));
2031 2031
 				$quiz_id = $question_data['quiz_id'];
2032
-				$question_count = intval( $question_data['question_count'] );
2032
+				$question_count = intval($question_data['question_count']);
2033 2033
 
2034
-				foreach( $questions as $question_id ) {
2034
+				foreach ($questions as $question_id) {
2035 2035
 
2036 2036
 					++$question_count;
2037 2037
 
2038
-					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2039
-					if( ! in_array( $quiz_id, $quizzes ) ) {
2040
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2041
-						$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2042
-						update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2038
+					$quizzes = get_post_meta($question_id, '_quiz_id', false);
2039
+					if ( ! in_array($quiz_id, $quizzes)) {
2040
+			    		add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2041
+						$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
2042
+						update_post_meta($lesson_id, '_quiz_has_questions', '1');
2043 2043
 			    	}
2044 2044
 
2045
-			    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2046
-					$question_type = Sensei()->question->get_question_type( $question_id );
2045
+			    	add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count);
2046
+					$question_type = Sensei()->question->get_question_type($question_id);
2047 2047
 
2048
-					$return .= $this->quiz_panel_question( $question_type, $question_count, $question_id );
2048
+					$return .= $this->quiz_panel_question($question_type, $question_count, $question_id);
2049 2049
 				}
2050 2050
 			}
2051 2051
 		}
@@ -2057,14 +2057,14 @@  discard block
 block discarded – undo
2057 2057
 
2058 2058
 	public function lesson_update_grade_type() {
2059 2059
 		//Add nonce security to the request
2060
-		if ( isset($_POST['lesson_update_grade_type_nonce']) ) {
2060
+		if (isset($_POST['lesson_update_grade_type_nonce'])) {
2061 2061
 
2062
-			$nonce = esc_html( $_POST['lesson_update_grade_type_nonce'] );
2062
+			$nonce = esc_html($_POST['lesson_update_grade_type_nonce']);
2063 2063
 
2064 2064
 		} // End If Statement
2065 2065
 
2066
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_grade_type_nonce' )
2067
-        || ! current_user_can( 'edit_lessons' ) ) {
2066
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_grade_type_nonce')
2067
+        || ! current_user_can('edit_lessons')) {
2068 2068
 
2069 2069
 			die('');
2070 2070
 
@@ -2074,18 +2074,18 @@  discard block
 block discarded – undo
2074 2074
 		$data = $_POST['data'];
2075 2075
 		$quiz_data = array();
2076 2076
 		parse_str($data, $quiz_data);
2077
-		update_post_meta( $quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type'] );
2077
+		update_post_meta($quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type']);
2078 2078
 		die();
2079 2079
 	}
2080 2080
 
2081 2081
 	public function lesson_update_question_order() {
2082 2082
 		// Add nonce security to the request
2083
-		if ( isset($_POST['lesson_update_question_order_nonce']) ) {
2084
-			$nonce = esc_html( $_POST['lesson_update_question_order_nonce'] );
2083
+		if (isset($_POST['lesson_update_question_order_nonce'])) {
2084
+			$nonce = esc_html($_POST['lesson_update_question_order_nonce']);
2085 2085
 		} // End If Statement
2086 2086
 
2087
-        if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_nonce' )
2088
-            ||! current_user_can( 'edit_lessons' ) ) {
2087
+        if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_nonce')
2088
+            ||! current_user_can('edit_lessons')) {
2089 2089
 			die('');
2090 2090
 		} // End If Statement
2091 2091
 
@@ -2093,25 +2093,25 @@  discard block
 block discarded – undo
2093 2093
 		$data = $_POST['data'];
2094 2094
 		$quiz_data = array();
2095 2095
 		parse_str($data, $quiz_data);
2096
-		if( strlen( $quiz_data['question_order'] ) > 0 ) {
2097
-			$questions = explode( ',', $quiz_data['question_order'] );
2096
+		if (strlen($quiz_data['question_order']) > 0) {
2097
+			$questions = explode(',', $quiz_data['question_order']);
2098 2098
 			$o = 1;
2099
-			foreach( $questions as $question_id ) {
2100
-				update_post_meta( $question_id, '_quiz_question_order' . $quiz_data['quiz_id'], $quiz_data['quiz_id'] . '000' . $o );
2099
+			foreach ($questions as $question_id) {
2100
+				update_post_meta($question_id, '_quiz_question_order'.$quiz_data['quiz_id'], $quiz_data['quiz_id'].'000'.$o);
2101 2101
 				++$o;
2102 2102
 			}
2103
-			update_post_meta( $quiz_data['quiz_id'], '_question_order', $questions );
2103
+			update_post_meta($quiz_data['quiz_id'], '_question_order', $questions);
2104 2104
 		}
2105 2105
 		die();
2106 2106
 	}
2107 2107
 
2108 2108
 	public function lesson_update_question_order_random() {
2109 2109
 		//Add nonce security to the request
2110
-		if ( isset($_POST['lesson_update_question_order_random_nonce']) ) {
2111
-			$nonce = esc_html( $_POST['lesson_update_question_order_random_nonce'] );
2110
+		if (isset($_POST['lesson_update_question_order_random_nonce'])) {
2111
+			$nonce = esc_html($_POST['lesson_update_question_order_random_nonce']);
2112 2112
 		} // End If Statement
2113
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_random_nonce' )
2114
-            || ! current_user_can( 'edit_lessons' ) ) {
2113
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_random_nonce')
2114
+            || ! current_user_can('edit_lessons')) {
2115 2115
 
2116 2116
 			die('');
2117 2117
 
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
 		$data = $_POST['data'];
2121 2121
 		$quiz_data = array();
2122 2122
 		parse_str($data, $quiz_data);
2123
-		update_post_meta( $quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order'] );
2123
+		update_post_meta($quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order']);
2124 2124
 		die();
2125 2125
 	}
2126 2126
 
@@ -2131,7 +2131,7 @@  discard block
 block discarded – undo
2131 2131
 	 * @param array $data (default: array())
2132 2132
 	 * @return integer|boolean $course_id or false
2133 2133
 	 */
2134
-	private function lesson_save_course( $data = array() ) {
2134
+	private function lesson_save_course($data = array()) {
2135 2135
 		global $current_user;
2136 2136
 		$return = false;
2137 2137
 		// Setup the course data
@@ -2140,58 +2140,58 @@  discard block
 block discarded – undo
2140 2140
 		$course_title = '';
2141 2141
 		$course_prerequisite = 0;
2142 2142
 		$course_category = 0;
2143
-		if ( isset( $data[ 'course_id' ] ) && ( 0 < absint( $data[ 'course_id' ] ) ) ) {
2144
-			$course_id = absint( $data[ 'course_id' ] );
2143
+		if (isset($data['course_id']) && (0 < absint($data['course_id']))) {
2144
+			$course_id = absint($data['course_id']);
2145 2145
 		} // End If Statement
2146
-		if ( isset( $data[ 'course_title' ] ) && ( '' != $data[ 'course_title' ] ) ) {
2147
-			$course_title = $data[ 'course_title' ];
2146
+		if (isset($data['course_title']) && ('' != $data['course_title'])) {
2147
+			$course_title = $data['course_title'];
2148 2148
 		} // End If Statement
2149 2149
 		$post_title = $course_title;
2150
-		if ( isset($data[ 'post_author' ]) ) {
2151
-			$post_author = $data[ 'post_author' ];
2150
+		if (isset($data['post_author'])) {
2151
+			$post_author = $data['post_author'];
2152 2152
 		} else {
2153 2153
 			$current_user = wp_get_current_user();
2154 2154
 			$post_author = $current_user->ID;
2155 2155
 		} // End If Statement
2156 2156
 		$post_status = 'publish';
2157 2157
 		$post_type = 'course';
2158
-		if ( isset( $data[ 'course_content' ] ) && ( '' != $data[ 'course_content' ] ) ) {
2159
-			$course_content = $data[ 'course_content' ];
2158
+		if (isset($data['course_content']) && ('' != $data['course_content'])) {
2159
+			$course_content = $data['course_content'];
2160 2160
 		} // End If Statement
2161 2161
 		$post_content = $course_content;
2162 2162
 		// Course Query Arguments
2163
-		$post_type_args = array(	'post_content' => $post_content,
2163
+		$post_type_args = array('post_content' => $post_content,
2164 2164
   		    						'post_status' => $post_status,
2165 2165
   		    						'post_title' => $post_title,
2166 2166
   		    						'post_type' => $post_type
2167 2167
   		    						);
2168 2168
   		// Only save if there is a valid title
2169
-  		if ( $post_title != '' ) {
2169
+  		if ($post_title != '') {
2170 2170
   		    // Check for prerequisite courses & product id
2171
-  		    $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2172
-  		    $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2173
-  		    $course_category_id = absint( $data[ 'course_category' ] );
2174
-  		    if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2171
+  		    $course_prerequisite_id = absint($data['course_prerequisite']);
2172
+  		    $course_woocommerce_product_id = absint($data['course_woocommerce_product']);
2173
+  		    $course_category_id = absint($data['course_category']);
2174
+  		    if (0 == $course_woocommerce_product_id) { $course_woocommerce_product_id = '-'; }
2175 2175
   		    // Insert or Update the Lesson Quiz
2176
-		    if ( 0 < $course_id ) {
2177
-		    	$post_type_args[ 'ID' ] = $course_id;
2176
+		    if (0 < $course_id) {
2177
+		    	$post_type_args['ID'] = $course_id;
2178 2178
 		    	$course_id = wp_update_post($post_type_args);
2179
-		    	update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2180
-		    	update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2181
-		    	if ( 0 < $course_category_id ) {
2182
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2179
+		    	update_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id);
2180
+		    	update_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id);
2181
+		    	if (0 < $course_category_id) {
2182
+		    		wp_set_object_terms($course_id, $course_category_id, 'course-category');
2183 2183
 		    	} // End If Statement
2184 2184
 		    } else {
2185 2185
 		    	$course_id = wp_insert_post($post_type_args);
2186
-		    	add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2187
-		    	add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2188
-		    	if ( 0 < $course_category_id ) {
2189
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2186
+		    	add_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id);
2187
+		    	add_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id);
2188
+		    	if (0 < $course_category_id) {
2189
+		    		wp_set_object_terms($course_id, $course_category_id, 'course-category');
2190 2190
 		    	} // End If Statement
2191 2191
 		    } // End If Statement
2192 2192
 		} // End If Statement
2193 2193
   		// Check that the insert or update saved by testing the post id
2194
-  		if ( 0 < $course_id ) {
2194
+  		if (0 < $course_id) {
2195 2195
   			$return = $course_id;
2196 2196
   		} // End If Statement
2197 2197
   		return $return;
@@ -2205,7 +2205,7 @@  discard block
 block discarded – undo
2205 2205
 	 * @param array $data (default: array())
2206 2206
 	 * @return integer|boolean $question_id or false
2207 2207
 	 */
2208
-	public function lesson_save_question( $data = array(), $context = 'quiz' ) {
2208
+	public function lesson_save_question($data = array(), $context = 'quiz') {
2209 2209
 		$return = false;
2210 2210
 		// Save the Questions
2211 2211
 		// Setup the Question data
@@ -2217,130 +2217,130 @@  discard block
 block discarded – undo
2217 2217
 		$question_category = '';
2218 2218
 
2219 2219
 		// Handle Question Type
2220
-		if ( isset( $data[ 'question_type' ] ) && ( '' != $data[ 'question_type' ] ) ) {
2221
-			$question_type = $data[ 'question_type' ];
2220
+		if (isset($data['question_type']) && ('' != $data['question_type'])) {
2221
+			$question_type = $data['question_type'];
2222 2222
 		} // End If Statement
2223 2223
 
2224
-		if ( isset( $data[ 'question_category' ] ) && ( '' != $data[ 'question_category' ] ) ) {
2225
-			$question_category = $data[ 'question_category' ];
2224
+		if (isset($data['question_category']) && ('' != $data['question_category'])) {
2225
+			$question_category = $data['question_category'];
2226 2226
 		} // End If Statement
2227 2227
 
2228
-		if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) {
2229
-			$question_id = absint( $data[ 'question_id' ] );
2228
+		if (isset($data['question_id']) && (0 < absint($data['question_id']))) {
2229
+			$question_id = absint($data['question_id']);
2230 2230
 		} // End If Statement
2231
-		if ( isset( $data[ 'question' ] ) && ( '' != $data[ 'question' ] ) ) {
2232
-			$question_text = $data[ 'question' ];
2231
+		if (isset($data['question']) && ('' != $data['question'])) {
2232
+			$question_text = $data['question'];
2233 2233
 		} // End If Statement
2234 2234
 		$post_title = $question_text;
2235 2235
 		// Handle Default Fields (multiple choice)
2236
-		if ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answers' ] ) && ( '' != $data[ 'question_right_answers' ] ) ) {
2237
-			$question_right_answers = $data[ 'question_right_answers' ];
2236
+		if ('multiple-choice' == $question_type && isset($data['question_right_answers']) && ('' != $data['question_right_answers'])) {
2237
+			$question_right_answers = $data['question_right_answers'];
2238 2238
 		} // End If Statement
2239
-		elseif ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answer' ] ) && ( '' != $data[ 'question_right_answer' ] ) ) {
2240
-			$question_right_answer = $data[ 'question_right_answer' ];
2239
+		elseif ('multiple-choice' == $question_type && isset($data['question_right_answer']) && ('' != $data['question_right_answer'])) {
2240
+			$question_right_answer = $data['question_right_answer'];
2241 2241
 		} // End If Statement
2242
-		if ( 'multiple-choice' == $question_type && isset( $data[ 'question_wrong_answers' ] ) && ( '' != $data[ 'question_wrong_answers' ] ) ) {
2243
-			$question_wrong_answers = $data[ 'question_wrong_answers' ];
2242
+		if ('multiple-choice' == $question_type && isset($data['question_wrong_answers']) && ('' != $data['question_wrong_answers'])) {
2243
+			$question_wrong_answers = $data['question_wrong_answers'];
2244 2244
 		} // End If Statement
2245 2245
 		// Handle Boolean Fields - Edit
2246
-		if ( 'boolean' == $question_type && isset( $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) && ( '' != $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) ) {
2247
-			$question_right_answer = $data[ 'question_' . $question_id . '_right_answer_boolean' ];
2246
+		if ('boolean' == $question_type && isset($data['question_'.$question_id.'_right_answer_boolean']) && ('' != $data['question_'.$question_id.'_right_answer_boolean'])) {
2247
+			$question_right_answer = $data['question_'.$question_id.'_right_answer_boolean'];
2248 2248
 		} // End If Statement
2249 2249
 		// Handle Boolean Fields - Add
2250
-		if ( 'boolean' == $question_type && isset( $data[ 'question_right_answer_boolean' ] ) && ( '' != $data[ 'question_right_answer_boolean' ] ) ) {
2251
-			$question_right_answer = $data[ 'question_right_answer_boolean' ];
2250
+		if ('boolean' == $question_type && isset($data['question_right_answer_boolean']) && ('' != $data['question_right_answer_boolean'])) {
2251
+			$question_right_answer = $data['question_right_answer_boolean'];
2252 2252
 		} // End If Statement
2253 2253
 		// Handle Gap Fill Fields
2254
-		if ( 'gap-fill' == $question_type && isset( $data[ 'add_question_right_answer_gapfill_gap' ] ) && '' != $data[ 'add_question_right_answer_gapfill_gap' ] ) {
2255
-			$question_right_answer = $data[ 'add_question_right_answer_gapfill_pre' ] . '||' . $data[ 'add_question_right_answer_gapfill_gap' ] . '||' . $data[ 'add_question_right_answer_gapfill_post' ];
2254
+		if ('gap-fill' == $question_type && isset($data['add_question_right_answer_gapfill_gap']) && '' != $data['add_question_right_answer_gapfill_gap']) {
2255
+			$question_right_answer = $data['add_question_right_answer_gapfill_pre'].'||'.$data['add_question_right_answer_gapfill_gap'].'||'.$data['add_question_right_answer_gapfill_post'];
2256 2256
 		} // End If Statement
2257 2257
 		// Handle Multi Line Fields
2258
-		if ( 'multi-line' == $question_type && isset( $data[ 'add_question_right_answer_multiline' ] ) && ( '' != $data[ 'add_question_right_answer_multiline' ] ) ) {
2259
-			$question_right_answer = $data[ 'add_question_right_answer_multiline' ];
2258
+		if ('multi-line' == $question_type && isset($data['add_question_right_answer_multiline']) && ('' != $data['add_question_right_answer_multiline'])) {
2259
+			$question_right_answer = $data['add_question_right_answer_multiline'];
2260 2260
 		} // End If Statement
2261 2261
 		// Handle Single Line Fields
2262
-		if ( 'single-line' == $question_type && isset( $data[ 'add_question_right_answer_singleline' ] ) && ( '' != $data[ 'add_question_right_answer_singleline' ] ) ) {
2263
-			$question_right_answer = $data[ 'add_question_right_answer_singleline' ];
2262
+		if ('single-line' == $question_type && isset($data['add_question_right_answer_singleline']) && ('' != $data['add_question_right_answer_singleline'])) {
2263
+			$question_right_answer = $data['add_question_right_answer_singleline'];
2264 2264
 		} // End If Statement
2265 2265
 		// Handle File Upload Fields
2266
-		if ( 'file-upload' == $question_type && isset( $data[ 'add_question_right_answer_fileupload' ] ) && ( '' != $data[ 'add_question_right_answer_fileupload' ] ) ) {
2267
-			$question_right_answer = $data[ 'add_question_right_answer_fileupload' ];
2266
+		if ('file-upload' == $question_type && isset($data['add_question_right_answer_fileupload']) && ('' != $data['add_question_right_answer_fileupload'])) {
2267
+			$question_right_answer = $data['add_question_right_answer_fileupload'];
2268 2268
 		} // End If Statement
2269
-		if ( 'file-upload' == $question_type && isset( $data[ 'add_question_wrong_answer_fileupload' ] ) && ( '' != $data[ 'add_question_wrong_answer_fileupload' ] ) ) {
2270
-			$question_wrong_answers = array( $data[ 'add_question_wrong_answer_fileupload' ] );
2269
+		if ('file-upload' == $question_type && isset($data['add_question_wrong_answer_fileupload']) && ('' != $data['add_question_wrong_answer_fileupload'])) {
2270
+			$question_wrong_answers = array($data['add_question_wrong_answer_fileupload']);
2271 2271
 		} // End If Statement
2272 2272
 
2273 2273
 		// Handle Question Grade
2274
-		if ( isset( $data[ 'question_grade' ] ) && ( '' != $data[ 'question_grade' ] ) ) {
2275
-			$question_grade = $data[ 'question_grade' ];
2274
+		if (isset($data['question_grade']) && ('' != $data['question_grade'])) {
2275
+			$question_grade = $data['question_grade'];
2276 2276
 		} // End If Statement
2277 2277
 
2278 2278
 		// Handle Answer Feedback
2279 2279
 		$answer_feedback = '';
2280
-		if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) {
2280
+		if (isset($data['answer_feedback_boolean']) && ! empty($data['answer_feedback_boolean'])) {
2281 2281
 
2282
-            $answer_feedback = $data[ 'answer_feedback_boolean' ];
2282
+            $answer_feedback = $data['answer_feedback_boolean'];
2283 2283
 
2284
-		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2284
+		}elseif (isset($data['answer_feedback_multiple_choice']) && ! empty($data['answer_feedback_multiple_choice'])) {
2285 2285
 
2286
-            $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2286
+            $answer_feedback = $data['answer_feedback_multiple_choice'];
2287 2287
 
2288
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2288
+        }elseif (isset($data['answer_feedback'])) {
2289 2289
 
2290
-            $answer_feedback = $data[ 'answer_feedback' ];
2290
+            $answer_feedback = $data['answer_feedback'];
2291 2291
 
2292 2292
         } // End If Statement
2293 2293
 
2294 2294
 		$post_title = $question_text;
2295
-		$post_author = $data[ 'post_author' ];
2295
+		$post_author = $data['post_author'];
2296 2296
 		$post_status = 'publish';
2297 2297
 		$post_type = 'question';
2298 2298
 		// Handle the extended question text
2299
-		if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) {
2300
-			$post_content = $data[ 'question_description' ];
2299
+		if (isset($data['question_description']) && ('' != $data['question_description'])) {
2300
+			$post_content = $data['question_description'];
2301 2301
 		}
2302 2302
 		else {
2303 2303
 			$post_content = '';
2304 2304
 		}
2305 2305
 		// Question Query Arguments
2306
-		$post_type_args = array(	'post_content' => $post_content,
2306
+		$post_type_args = array('post_content' => $post_content,
2307 2307
   		    						'post_status' => $post_status,
2308 2308
   		    						'post_title' => $post_title,
2309 2309
   		    						'post_type' => $post_type
2310 2310
   		    						);
2311 2311
 
2312 2312
   		// Remove empty values and reindex the array
2313
-  		if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) {
2314
-  			$question_right_answers_array = array_values( array_filter( $question_right_answers, 'strlen' ) );
2313
+  		if (is_array($question_right_answers) && 0 < count($question_right_answers)) {
2314
+  			$question_right_answers_array = array_values(array_filter($question_right_answers, 'strlen'));
2315 2315
   			$question_right_answers = array();
2316 2316
 
2317
-  			foreach( $question_right_answers_array as $answer ) {
2318
-  				if( ! in_array( $answer, $question_right_answers ) ) {
2317
+  			foreach ($question_right_answers_array as $answer) {
2318
+  				if ( ! in_array($answer, $question_right_answers)) {
2319 2319
   					$question_right_answers[] = $answer;
2320 2320
   				}
2321 2321
   			}
2322
-  			if ( 0 < count($question_right_answers) ) {
2322
+  			if (0 < count($question_right_answers)) {
2323 2323
   				$question_right_answer = $question_right_answers;
2324 2324
   			}
2325 2325
   		} // End If Statement
2326
-  		$right_answer_count = count( $question_right_answer );
2326
+  		$right_answer_count = count($question_right_answer);
2327 2327
 
2328 2328
 		// Remove empty values and reindex the array
2329
-  		if ( is_array( $question_wrong_answers ) ) {
2330
-  			$question_wrong_answers_array = array_values( array_filter( $question_wrong_answers, 'strlen' ) );
2329
+  		if (is_array($question_wrong_answers)) {
2330
+  			$question_wrong_answers_array = array_values(array_filter($question_wrong_answers, 'strlen'));
2331 2331
   			$question_wrong_answers = array();
2332 2332
   		} // End If Statement
2333 2333
 
2334
-  		foreach( $question_wrong_answers_array as $answer ) {
2335
-  			if( ! in_array( $answer, $question_wrong_answers ) ) {
2334
+  		foreach ($question_wrong_answers_array as $answer) {
2335
+  			if ( ! in_array($answer, $question_wrong_answers)) {
2336 2336
   				$question_wrong_answers[] = $answer;
2337 2337
   			}
2338 2338
   		}
2339 2339
 
2340
-  		$wrong_answer_count = count( $question_wrong_answers );
2340
+  		$wrong_answer_count = count($question_wrong_answers);
2341 2341
 
2342 2342
   		// Only save if there is a valid title
2343
-  		if ( $post_title != '' ) {
2343
+  		if ($post_title != '') {
2344 2344
 
2345 2345
   			// Get Quiz ID for the question
2346 2346
   		    $quiz_id = $data['quiz_id'];
@@ -2350,86 +2350,86 @@  discard block
 block discarded – undo
2350 2350
 
2351 2351
   		    // Get answer order
2352 2352
   		    $answer_order = '';
2353
-  		    if( isset( $data['answer_order'] ) ) {
2353
+  		    if (isset($data['answer_order'])) {
2354 2354
 				$answer_order = $data['answer_order'];
2355 2355
 			}
2356 2356
 
2357 2357
 			// Get random order selection
2358 2358
 			$random_order = 'no';
2359
-			if( isset( $data['random_order'] ) ) {
2359
+			if (isset($data['random_order'])) {
2360 2360
 				$random_order = $data['random_order'];
2361 2361
 			}
2362 2362
 
2363 2363
   		    // Insert or Update the question
2364
-  		    if ( 0 < $question_id ) {
2364
+  		    if (0 < $question_id) {
2365 2365
 
2366
-  		    	$post_type_args[ 'ID' ] = $question_id;
2367
-		    	$question_id = wp_update_post( $post_type_args );
2366
+  		    	$post_type_args['ID'] = $question_id;
2367
+		    	$question_id = wp_update_post($post_type_args);
2368 2368
 
2369 2369
 		    	// Update poast meta
2370
-		    	if( 'quiz' == $context ) {
2371
-		    		$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2372
-		    		if( ! in_array( $quiz_id, $quizzes ) ) {
2373
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2370
+		    	if ('quiz' == $context) {
2371
+		    		$quizzes = get_post_meta($question_id, '_quiz_id', false);
2372
+		    		if ( ! in_array($quiz_id, $quizzes)) {
2373
+			    		add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2374 2374
 			    	}
2375 2375
 		    	}
2376 2376
 
2377
-		    	update_post_meta( $question_id, '_question_grade', $question_grade );
2378
-		    	update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2379
-		    	update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2380
-		    	update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2381
-		    	update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2382
-		    	update_post_meta( $question_id, '_question_media', $question_media );
2383
-		    	update_post_meta( $question_id, '_answer_order', $answer_order );
2384
-		    	update_post_meta( $question_id, '_random_order', $random_order );
2385
-
2386
-		    	if( 'quiz' != $context ) {
2387
-		    		wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2377
+		    	update_post_meta($question_id, '_question_grade', $question_grade);
2378
+		    	update_post_meta($question_id, '_question_right_answer', $question_right_answer);
2379
+		    	update_post_meta($question_id, '_right_answer_count', $right_answer_count);
2380
+		    	update_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers);
2381
+		    	update_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count);
2382
+		    	update_post_meta($question_id, '_question_media', $question_media);
2383
+		    	update_post_meta($question_id, '_answer_order', $answer_order);
2384
+		    	update_post_meta($question_id, '_random_order', $random_order);
2385
+
2386
+		    	if ('quiz' != $context) {
2387
+		    		wp_set_post_terms($question_id, array($question_type), 'question-type', false);
2388 2388
 		    	}
2389 2389
 				// Don't store empty value, no point
2390
-				if ( !empty($answer_feedback) ) {
2391
-					update_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2390
+				if ( ! empty($answer_feedback)) {
2391
+					update_post_meta($question_id, '_answer_feedback', $answer_feedback);
2392 2392
 				}
2393 2393
 
2394 2394
 		    } else {
2395
-				$question_id = wp_insert_post( $post_type_args );
2396
-				$question_count = intval( $data['question_count'] );
2395
+				$question_id = wp_insert_post($post_type_args);
2396
+				$question_count = intval($data['question_count']);
2397 2397
 				++$question_count;
2398 2398
 
2399 2399
 				// Set post meta
2400
-				if( 'quiz' == $context ) {
2401
-					add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2402
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2403
-					update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2400
+				if ('quiz' == $context) {
2401
+					add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2402
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
2403
+					update_post_meta($lesson_id, '_quiz_has_questions', '1');
2404 2404
 				}
2405 2405
 
2406
-				if( isset( $question_grade ) ) {
2407
-		    		add_post_meta( $question_id, '_question_grade', $question_grade );
2406
+				if (isset($question_grade)) {
2407
+		    		add_post_meta($question_id, '_question_grade', $question_grade);
2408 2408
 		    	}
2409
-		    	add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2410
-		    	add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2411
-		    	add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2412
-		    	add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2413
-		    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2414
-		    	add_post_meta( $question_id, '_question_media', $question_media );
2415
-		    	add_post_meta( $question_id, '_answer_order', $answer_order );
2416
-		    	add_post_meta( $question_id, '_random_order', $random_order );
2409
+		    	add_post_meta($question_id, '_question_right_answer', $question_right_answer);
2410
+		    	add_post_meta($question_id, '_right_answer_count', $right_answer_count);
2411
+		    	add_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers);
2412
+		    	add_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count);
2413
+		    	add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count);
2414
+		    	add_post_meta($question_id, '_question_media', $question_media);
2415
+		    	add_post_meta($question_id, '_answer_order', $answer_order);
2416
+		    	add_post_meta($question_id, '_random_order', $random_order);
2417 2417
 				// Don't store empty value, no point
2418
-				if ( !empty($answer_feedback) ) {
2419
-					add_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2418
+				if ( ! empty($answer_feedback)) {
2419
+					add_post_meta($question_id, '_answer_feedback', $answer_feedback);
2420 2420
 				}
2421 2421
 
2422 2422
 		    	// Set the post terms for question-type
2423
-			    wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2423
+			    wp_set_post_terms($question_id, array($question_type), 'question-type');
2424 2424
 
2425
-			    if( $question_category ) {
2426
-	    			wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2425
+			    if ($question_category) {
2426
+	    			wp_set_post_terms($question_id, array($question_category), 'question-category');
2427 2427
 	    		}
2428 2428
 
2429 2429
 		    } // End If Statement
2430 2430
 		} // End If Statement
2431 2431
   		// Check that the insert or update saved by testing the post id
2432
-  		if ( 0 < $question_id ) {
2432
+  		if (0 < $question_id) {
2433 2433
   			$return = $question_id;
2434 2434
   		} // End If Statement
2435 2435
   		return $return;
@@ -2443,20 +2443,20 @@  discard block
 block discarded – undo
2443 2443
 	 * @param array $data (default: array())
2444 2444
 	 * @return boolean
2445 2445
 	 */
2446
-	private function lesson_delete_question( $data = array() ) {
2446
+	private function lesson_delete_question($data = array()) {
2447 2447
 
2448 2448
 		// Get which question to delete
2449 2449
 		$question_id = 0;
2450
-		if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) {
2451
-			$question_id = absint( $data[ 'question_id' ] );
2450
+		if (isset($data['question_id']) && (0 < absint($data['question_id']))) {
2451
+			$question_id = absint($data['question_id']);
2452 2452
 		} // End If Statement
2453 2453
 		// Delete the question
2454
-		if ( 0 < $question_id ) {
2455
-			$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2454
+		if (0 < $question_id) {
2455
+			$quizzes = get_post_meta($question_id, '_quiz_id', false);
2456 2456
 
2457
-			foreach( $quizzes as $quiz_id ) {
2458
-				if( $quiz_id == $data['quiz_id'] ) {
2459
-					delete_post_meta( $question_id, '_quiz_id', $quiz_id );
2457
+			foreach ($quizzes as $quiz_id) {
2458
+				if ($quiz_id == $data['quiz_id']) {
2459
+					delete_post_meta($question_id, '_quiz_id', $quiz_id);
2460 2460
 				}
2461 2461
 			}
2462 2462
 
@@ -2475,9 +2475,9 @@  discard block
 block discarded – undo
2475 2475
 	public function lesson_complexities() {
2476 2476
 
2477 2477
 		// V2 - make filter for this array
2478
-        $lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2479
-									'std' => __( 'Standard', 'woothemes-sensei' ),
2480
-									'hard' => __( 'Hard', 'woothemes-sensei' )
2478
+        $lesson_complexities = array('easy' => __('Easy', 'woothemes-sensei'),
2479
+									'std' => __('Standard', 'woothemes-sensei'),
2480
+									'hard' => __('Hard', 'woothemes-sensei')
2481 2481
 									);
2482 2482
 
2483 2483
 		return $lesson_complexities;
@@ -2492,9 +2492,9 @@  discard block
 block discarded – undo
2492 2492
 	 * @param string $post_status (default: 'publish')
2493 2493
 	 * @return int
2494 2494
 	 */
2495
-	public function lesson_count( $post_status = 'publish', $course_id = false ) {
2495
+	public function lesson_count($post_status = 'publish', $course_id = false) {
2496 2496
 
2497
-		$post_args = array(	'post_type'         => 'lesson',
2497
+		$post_args = array('post_type'         => 'lesson',
2498 2498
 							'posts_per_page'    => -1,
2499 2499
 //							'orderby'           => 'menu_order date',
2500 2500
 //							'order'             => 'ASC',
@@ -2502,7 +2502,7 @@  discard block
 block discarded – undo
2502 2502
 							'suppress_filters'  => 0,
2503 2503
 							'fields'            => 'ids',
2504 2504
 							);
2505
-		if( $course_id ) {
2505
+		if ($course_id) {
2506 2506
 			$post_args['meta_query'][] = array(
2507 2507
 				'key' => '_lesson_course',
2508 2508
 				'value' => $course_id,
@@ -2519,10 +2519,10 @@  discard block
 block discarded – undo
2519 2519
 
2520 2520
 		// Allow WP to generate the complex final query, just shortcut to only do an overall count
2521 2521
 //		add_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
2522
-		$lessons_query = new WP_Query( apply_filters( 'sensei_lesson_count', $post_args ) );
2522
+		$lessons_query = new WP_Query(apply_filters('sensei_lesson_count', $post_args));
2523 2523
 //		remove_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
2524 2524
 
2525
-		return count( $lessons_query->posts );
2525
+		return count($lessons_query->posts);
2526 2526
 	} // End lesson_count()
2527 2527
 
2528 2528
 
@@ -2535,11 +2535,11 @@  discard block
 block discarded – undo
2535 2535
 	 * @param string $fields (default: 'ids')
2536 2536
 	 * @return int $quiz_id
2537 2537
 	 */
2538
-	public function lesson_quizzes( $lesson_id = 0, $post_status = 'any', $fields = 'ids' ) {
2538
+	public function lesson_quizzes($lesson_id = 0, $post_status = 'any', $fields = 'ids') {
2539 2539
 
2540 2540
 		$posts_array = array();
2541 2541
 
2542
-		$post_args = array(	'post_type' 		=> 'quiz',
2542
+		$post_args = array('post_type' 		=> 'quiz',
2543 2543
 							'posts_per_page' 		=> 1,
2544 2544
 							'orderby'         	=> 'title',
2545 2545
     						'order'           	=> 'DESC',
@@ -2548,7 +2548,7 @@  discard block
 block discarded – undo
2548 2548
 							'suppress_filters' 	=> 0,
2549 2549
 							'fields'            => $fields
2550 2550
 							);
2551
-		$posts_array = get_posts( $post_args );
2551
+		$posts_array = get_posts($post_args);
2552 2552
         $quiz_id = array_shift($posts_array);
2553 2553
 
2554 2554
 		return $quiz_id;
@@ -2571,37 +2571,37 @@  discard block
 block discarded – undo
2571 2571
      *
2572 2572
 	 * @return array $questions { $question type WP_Post }
2573 2573
 	 */
2574
-	public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) {
2574
+	public function lesson_quiz_questions($quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC') {
2575 2575
 
2576 2576
 		$quiz_id = (string) $quiz_id;
2577
-        $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2577
+        $quiz_lesson_id = Sensei()->quiz->get_lesson_id($quiz_id);
2578 2578
 
2579 2579
         // setup the user id
2580
-        if( is_admin() ) {
2581
-            $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2580
+        if (is_admin()) {
2581
+            $user_id = isset($_GET['user']) ? $_GET['user'] : '';
2582 2582
         } else {
2583 2583
             $user_id = get_current_user_id();
2584 2584
         }
2585 2585
 
2586 2586
         // get the users current status on the lesson
2587
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2587
+        $user_lesson_status = Sensei_Utils::user_lesson_status($quiz_lesson_id, $user_id);
2588 2588
 
2589 2589
 		// Set the default question order if it has not already been set for this quiz
2590
-		$this->set_default_question_order( $quiz_id );
2590
+		$this->set_default_question_order($quiz_id);
2591 2591
 
2592 2592
 		// If viewing quiz on the frontend then show questions in random order if set
2593
-		if ( ! is_admin() ) {
2594
-			$random_order = get_post_meta( $quiz_id, '_random_question_order', true );
2595
-			if( $random_order && $random_order == 'yes' ) {
2593
+		if ( ! is_admin()) {
2594
+			$random_order = get_post_meta($quiz_id, '_random_question_order', true);
2595
+			if ($random_order && $random_order == 'yes') {
2596 2596
 				$orderby = 'rand';
2597 2597
 			}
2598 2598
 		}
2599 2599
 
2600 2600
 		// Get all questions and multiple questions
2601 2601
 		$question_query_args = array(
2602
-			'post_type' 		=> array( 'question', 'multiple_question' ),
2602
+			'post_type' 		=> array('question', 'multiple_question'),
2603 2603
 			'posts_per_page' 	=> -1,
2604
-			'meta_key'        	=> '_quiz_question_order' . $quiz_id,
2604
+			'meta_key'        	=> '_quiz_question_order'.$quiz_id,
2605 2605
 			'orderby'         	=> $orderby,
2606 2606
 			'order'           	=> $order,
2607 2607
 			'meta_query'		=> array(
@@ -2615,7 +2615,7 @@  discard block
 block discarded – undo
2615 2615
 		);
2616 2616
 
2617 2617
         //query the questions
2618
-		$questions_query = new WP_Query( $question_query_args );
2618
+		$questions_query = new WP_Query($question_query_args);
2619 2619
 
2620 2620
         // Set return array to initially include all items
2621 2621
         $questions = $questions_query->posts;
@@ -2625,20 +2625,20 @@  discard block
 block discarded – undo
2625 2625
 
2626 2626
 		// If viewing quiz on frontend or in grading then only single questions must be shown
2627 2627
 		$selected_questions = false;
2628
-		if( ! is_admin() || ( is_admin() && isset( $_GET['page'] ) && 'sensei_grading' == $_GET['page'] && isset( $_GET['user'] ) && isset( $_GET['quiz_id'] ) ) ) {
2628
+		if ( ! is_admin() || (is_admin() && isset($_GET['page']) && 'sensei_grading' == $_GET['page'] && isset($_GET['user']) && isset($_GET['quiz_id']))) {
2629 2629
 
2630 2630
 			// Fetch the questions that the user was asked in their quiz if they have already completed it
2631
-			$questions_asked_string = !empty( $user_lesson_status->comment_ID) ? get_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', true ) : false;
2632
-			if( !empty($questions_asked_string) ) {
2631
+			$questions_asked_string = ! empty($user_lesson_status->comment_ID) ? get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true) : false;
2632
+			if ( ! empty($questions_asked_string)) {
2633 2633
 
2634
-				$selected_questions = explode( ',', $questions_asked_string );
2634
+				$selected_questions = explode(',', $questions_asked_string);
2635 2635
 
2636 2636
 				// Fetch each question in the order in which they were asked
2637 2637
 				$questions = array();
2638
-				foreach( $selected_questions as $question_id ) {
2639
-					if( ! $question_id ) continue;
2640
-					$question = get_post( $question_id );
2641
-					if( ! isset( $question ) || ! isset( $question->ID ) ) continue;
2638
+				foreach ($selected_questions as $question_id) {
2639
+					if ( ! $question_id) continue;
2640
+					$question = get_post($question_id);
2641
+					if ( ! isset($question) || ! isset($question->ID)) continue;
2642 2642
 					$questions[] = $question;
2643 2643
 				}
2644 2644
 
@@ -2650,24 +2650,24 @@  discard block
 block discarded – undo
2650 2650
 				$existing_questions = array();
2651 2651
 
2652 2652
 				// Set array of questions that already exist so we can prevent duplicates from appearing
2653
-				foreach( $questions_array as $question ) {
2654
-					if( 'question' != $question->post_type ) continue;
2653
+				foreach ($questions_array as $question) {
2654
+					if ('question' != $question->post_type) continue;
2655 2655
 					$existing_questions[] = $question->ID;
2656 2656
 				}
2657 2657
 
2658 2658
 				// Include only single questions in the return array
2659 2659
 				$questions_loop = $questions_array;
2660 2660
 				$questions_array = array();
2661
-				foreach( $questions_loop as $k => $question ) {
2661
+				foreach ($questions_loop as $k => $question) {
2662 2662
 
2663 2663
 					// If this is a single question then include it
2664
-					if( 'question' == $question->post_type ) {
2664
+					if ('question' == $question->post_type) {
2665 2665
 						$questions_array[] = $question;
2666 2666
 					} else {
2667 2667
 
2668 2668
 						// If this is a multiple question then get the specified amount of questions from the specified category
2669
-						$question_cat = intval( get_post_meta( $question->ID, 'category', true ) );
2670
-						$question_number = intval( get_post_meta( $question->ID, 'number', true ) );
2669
+						$question_cat = intval(get_post_meta($question->ID, 'category', true));
2670
+						$question_number = intval(get_post_meta($question->ID, 'number', true));
2671 2671
 
2672 2672
 						$qargs = array(
2673 2673
 							'post_type' 		=> 'question',
@@ -2684,14 +2684,14 @@  discard block
 block discarded – undo
2684 2684
 							'suppress_filters' 	=> 0,
2685 2685
 							'post__not_in'		=> $existing_questions,
2686 2686
 						);
2687
-						$cat_questions = get_posts( $qargs );
2687
+						$cat_questions = get_posts($qargs);
2688 2688
 
2689 2689
 						// Merge results into return array
2690
-						$questions_array = array_merge( $questions_array, $cat_questions );
2690
+						$questions_array = array_merge($questions_array, $cat_questions);
2691 2691
 
2692 2692
 						// Add selected questions to existing questions array to prevent duplicates from being added
2693
-						foreach( $questions_array as $cat_question ) {
2694
-							if( in_array( $cat_question->ID, $existing_questions ) ) continue;
2693
+						foreach ($questions_array as $cat_question) {
2694
+							if (in_array($cat_question->ID, $existing_questions)) continue;
2695 2695
 							$existing_questions[] = $cat_question->ID;
2696 2696
 						}
2697 2697
 					}
@@ -2703,29 +2703,29 @@  discard block
 block discarded – undo
2703 2703
 		}
2704 2704
 
2705 2705
 		// If user has not already taken the quiz and a limited number of questions are to be shown, then show a random selection of the specified amount of questions
2706
-		if( ! $selected_questions ) {
2706
+		if ( ! $selected_questions) {
2707 2707
 
2708 2708
 			// Only limit questions like this on the frontend
2709
-			if( ! is_admin() ) {
2709
+			if ( ! is_admin()) {
2710 2710
 
2711 2711
 				// Get number of questions to show
2712
-				$show_questions = intval( get_post_meta( $quiz_id, '_show_questions', true ) );
2713
-				if( $show_questions ) {
2712
+				$show_questions = intval(get_post_meta($quiz_id, '_show_questions', true));
2713
+				if ($show_questions) {
2714 2714
 
2715 2715
 					// Get random set of array keys from selected questions array
2716
-					$selected_questions = array_rand( $questions_array, $show_questions );
2716
+					$selected_questions = array_rand($questions_array, $show_questions);
2717 2717
 
2718 2718
 					// Loop through all questions and pick the the ones to be shown based on the random key selection
2719 2719
 					$questions = array();
2720
-					foreach( $questions_array as $k => $question ) {
2720
+					foreach ($questions_array as $k => $question) {
2721 2721
 
2722 2722
 						// Random keys will always be an array, unless only one question is to be shown
2723
-						if( is_array( $selected_questions ) ) {
2724
-							if( in_array( $k, $selected_questions ) ) {
2723
+						if (is_array($selected_questions)) {
2724
+							if (in_array($k, $selected_questions)) {
2725 2725
 								$questions[] = $question;
2726 2726
 							}
2727
-						} elseif( 1 == $show_questions ) {
2728
-							if ( $selected_questions == $k ) {
2727
+						} elseif (1 == $show_questions) {
2728
+							if ($selected_questions == $k) {
2729 2729
 								$questions[] = $question;
2730 2730
 							}
2731 2731
 						}
@@ -2736,12 +2736,12 @@  discard block
 block discarded – undo
2736 2736
 
2737 2737
         // Save the questions that will be asked for the current user
2738 2738
         // this happens only once per user/quiz, unless the user resets the quiz
2739
-        if( ! is_admin() ){
2739
+        if ( ! is_admin()) {
2740 2740
 
2741
-            if( $user_lesson_status ) {
2741
+            if ($user_lesson_status) {
2742 2742
 
2743 2743
                 $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2744
-                if ( empty($questions_asked) && $user_lesson_status) {
2744
+                if (empty($questions_asked) && $user_lesson_status) {
2745 2745
 
2746 2746
                     $questions_asked = array();
2747 2747
                     foreach ($questions as $question) {
@@ -2764,7 +2764,7 @@  discard block
 block discarded – undo
2764 2764
          * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2765 2765
          * @since 1.8.0
2766 2766
          */
2767
-		return apply_filters( 'sensei_lesson_quiz_questions', $questions,  $quiz_id  );
2767
+		return apply_filters('sensei_lesson_quiz_questions', $questions, $quiz_id);
2768 2768
 
2769 2769
 	} // End lesson_quiz_questions()
2770 2770
 
@@ -2772,13 +2772,13 @@  discard block
 block discarded – undo
2772 2772
 	 * Set the default quiz order
2773 2773
 	 * @param integer $quiz_id ID of quiz
2774 2774
 	 */
2775
-	public function set_default_question_order( $quiz_id = 0 ) {
2775
+	public function set_default_question_order($quiz_id = 0) {
2776 2776
 
2777
-		if( $quiz_id ) {
2777
+		if ($quiz_id) {
2778 2778
 
2779
-			$question_order = get_post_meta( $quiz_id, '_question_order', true );
2779
+			$question_order = get_post_meta($quiz_id, '_question_order', true);
2780 2780
 
2781
-			if( ! $question_order ) {
2781
+			if ( ! $question_order) {
2782 2782
 
2783 2783
 				$args = array(
2784 2784
 					'post_type' 		=> 'question',
@@ -2794,11 +2794,11 @@  discard block
 block discarded – undo
2794 2794
 					'post_status'		=> 'any',
2795 2795
 					'suppress_filters' 	=> 0
2796 2796
 				);
2797
-				$questions = get_posts( $args );
2797
+				$questions = get_posts($args);
2798 2798
 
2799 2799
 				$o = 1;
2800
-				foreach( $questions as $question ) {
2801
-					add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $o, true );
2800
+				foreach ($questions as $question) {
2801
+					add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$o, true);
2802 2802
 					$o++;
2803 2803
 				}
2804 2804
 			}
@@ -2817,36 +2817,36 @@  discard block
 block discarded – undo
2817 2817
 	 * @param string $height (default: '100')
2818 2818
 	 * @return string
2819 2819
 	 */
2820
-	public function lesson_image( $lesson_id = 0, $width = '100', $height = '100', $widget = false ) {
2820
+	public function lesson_image($lesson_id = 0, $width = '100', $height = '100', $widget = false) {
2821 2821
 
2822 2822
 		$html = '';
2823 2823
 
2824 2824
 		// Get Width and Height settings
2825
-		if ( ( $width == '100' ) && ( $height == '100' ) ) {
2825
+		if (($width == '100') && ($height == '100')) {
2826 2826
 
2827
-			if ( is_singular( 'lesson' ) ) {
2827
+			if (is_singular('lesson')) {
2828 2828
 
2829
-				if ( ! $widget && ! Sensei()->settings->settings[ 'lesson_single_image_enable' ] ) {
2829
+				if ( ! $widget && ! Sensei()->settings->settings['lesson_single_image_enable']) {
2830 2830
 
2831 2831
 					return '';
2832 2832
 
2833 2833
 				} // End If Statement
2834 2834
 
2835 2835
 				$image_thumb_size = 'lesson_single_image';
2836
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
2836
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
2837 2837
 				$width = $dimensions['width'];
2838 2838
 				$height = $dimensions['height'];
2839 2839
 				$crop = $dimensions['crop'];
2840 2840
 
2841 2841
 			} else {
2842 2842
 
2843
-				if ( ! $widget && ! Sensei()->settings->settings[ 'course_lesson_image_enable' ] ) {
2843
+				if ( ! $widget && ! Sensei()->settings->settings['course_lesson_image_enable']) {
2844 2844
 
2845 2845
 					return '';
2846 2846
 				} // End If Statement
2847 2847
 
2848 2848
 				$image_thumb_size = 'lesson_archive_image';
2849
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
2849
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
2850 2850
 				$width = $dimensions['width'];
2851 2851
 				$height = $dimensions['height'];
2852 2852
 				$crop = $dimensions['crop'];
@@ -2857,23 +2857,23 @@  discard block
 block discarded – undo
2857 2857
 
2858 2858
 		$img_url = '';
2859 2859
 
2860
-		if ( has_post_thumbnail( $lesson_id ) ) {
2860
+		if (has_post_thumbnail($lesson_id)) {
2861 2861
 
2862 2862
    			// Get Featured Image
2863
-   			$img_url = get_the_post_thumbnail( $lesson_id, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') );
2863
+   			$img_url = get_the_post_thumbnail($lesson_id, array($width, $height), array('class' => 'woo-image thumbnail alignleft'));
2864 2864
 
2865 2865
  		} else {
2866 2866
 
2867 2867
  			// Display Image Placeholder if none
2868
-			if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) {
2868
+			if (Sensei()->settings->settings['placeholder_images_enable']) {
2869 2869
 
2870
-                $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2870
+                $img_url = apply_filters('sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/'.$width.'x'.$height.'" class="woo-image thumbnail alignleft" />');
2871 2871
 
2872 2872
 			} // End If Statement
2873 2873
 
2874 2874
 		} // End If Statement
2875 2875
 
2876
-		$html .= '<a href="' . get_permalink( $lesson_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $lesson_id ) ) . '">' . $img_url . '</a>';
2876
+		$html .= '<a href="'.get_permalink($lesson_id).'" title="'.esc_attr(get_post_field('post_title', $lesson_id)).'">'.$img_url.'</a>';
2877 2877
 
2878 2878
 		return $html;
2879 2879
 
@@ -2885,9 +2885,9 @@  discard block
 block discarded – undo
2885 2885
      * @since 1.9.0
2886 2886
      * @param integer $lesson_id
2887 2887
      */
2888
-    public static function the_lesson_image( $lesson_id = 0 ){
2888
+    public static function the_lesson_image($lesson_id = 0) {
2889 2889
 
2890
-        echo Sensei()->lesson->lesson_image( $lesson_id );
2890
+        echo Sensei()->lesson->lesson_image($lesson_id);
2891 2891
 
2892 2892
     }
2893 2893
 
@@ -2898,17 +2898,17 @@  discard block
 block discarded – undo
2898 2898
      * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2899 2899
 	 * @return string
2900 2900
 	 */
2901
-	public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) {
2901
+	public static function lesson_excerpt($lesson = null, $add_p_tags = true) {
2902 2902
 		$html = '';
2903
-		if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) {
2903
+		if (is_a($lesson, 'WP_Post') && 'lesson' == $lesson->post_type) {
2904 2904
 
2905
-            $excerpt =  $lesson->post_excerpt;
2905
+            $excerpt = $lesson->post_excerpt;
2906 2906
 
2907 2907
             // if $add_p_tags true wrap with <p> else return the excerpt as is
2908
-            $html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2908
+            $html = $add_p_tags ? wpautop($excerpt) : $excerpt;
2909 2909
 
2910 2910
 		}
2911
-		return apply_filters( 'sensei_lesson_excerpt', $html );
2911
+		return apply_filters('sensei_lesson_excerpt', $html);
2912 2912
 
2913 2913
 	} // End lesson_excerpt()
2914 2914
 
@@ -2921,20 +2921,20 @@  discard block
 block discarded – undo
2921 2921
      * @param int $lesson_id
2922 2922
      * @return int|bool $course_id or bool when nothing is found.
2923 2923
      */
2924
-     public function get_course_id( $lesson_id ){
2924
+     public function get_course_id($lesson_id) {
2925 2925
 
2926
-         if( ! isset( $lesson_id ) || empty( $lesson_id )
2927
-         ||  'lesson' != get_post_type( $lesson_id ) ){
2926
+         if ( ! isset($lesson_id) || empty($lesson_id)
2927
+         ||  'lesson' != get_post_type($lesson_id)) {
2928 2928
              return false;
2929 2929
          }
2930 2930
 
2931
-         $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2931
+         $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
2932 2932
 
2933 2933
          // make sure the course id is valid
2934
-         if( empty( $lesson_course_id )
2935
-             || is_array( $lesson_course_id )
2936
-             || intval( $lesson_course_id ) < 1
2937
-             || 'course' != get_post_type( $lesson_course_id ) ){
2934
+         if (empty($lesson_course_id)
2935
+             || is_array($lesson_course_id)
2936
+             || intval($lesson_course_id) < 1
2937
+             || 'course' != get_post_type($lesson_course_id)) {
2938 2938
 
2939 2939
              return false;
2940 2940
 
@@ -2961,11 +2961,11 @@  discard block
 block discarded – undo
2961 2961
      * @param string $post_type
2962 2962
      * @return void
2963 2963
      */
2964
-    public function all_lessons_edit_fields( $column_name, $post_type ) {
2964
+    public function all_lessons_edit_fields($column_name, $post_type) {
2965 2965
 
2966 2966
         // only show these options ont he lesson post type edit screen
2967
-        if( 'lesson' != $post_type || 'lesson-course' != $column_name
2968
-            || ! current_user_can( 'edit_lessons' ) ) {
2967
+        if ('lesson' != $post_type || 'lesson-course' != $column_name
2968
+            || ! current_user_can('edit_lessons')) {
2969 2969
             return;
2970 2970
         }
2971 2971
 
@@ -2973,41 +2973,41 @@  discard block
 block discarded – undo
2973 2973
         <fieldset class="sensei-edit-field-set inline-edit-lesson">
2974 2974
             <div class="sensei-inline-edit-col column-<?php echo $column_name ?>">
2975 2975
                     <?php
2976
-                    echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2976
+                    echo '<h4>'.__('Lesson Information', 'woothemes-sensei').'</h4>';
2977 2977
                     // create a nonce field to be  used as a security measure when saving the data
2978
-                    wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2979
-                    wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2978
+                    wp_nonce_field('bulk-edit-lessons', '_edit_lessons_nonce');
2979
+                    wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce');
2980 2980
 
2981 2981
                     // unchanged option - we need this in because
2982 2982
                     // the default option in bulk edit should not be empty. If it is
2983 2983
                     // the user will erase data they didn't want to touch.
2984
-                    $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2984
+                    $no_change_text = '-- '.__('No Change', 'woothemes-sensei').' --';
2985 2985
 
2986 2986
                     //
2987 2987
                     //course selection
2988 2988
                     //
2989
-                    $courses =  WooThemes_Sensei_Course::get_all_courses();
2989
+                    $courses = WooThemes_Sensei_Course::get_all_courses();
2990 2990
                     $course_options = array();
2991
-                    if ( count( $courses ) > 0 ) {
2992
-                        foreach ($courses as $course ){
2993
-                            $course_options[ $course->ID ] = get_the_title( $course->ID );
2991
+                    if (count($courses) > 0) {
2992
+                        foreach ($courses as $course) {
2993
+                            $course_options[$course->ID] = get_the_title($course->ID);
2994 2994
                         }
2995 2995
                     }
2996 2996
                     //pre-append the no change option
2997
-                    $course_options['-1']=  $no_change_text;
2998
-                    $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2999
-                    $course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
3000
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
2997
+                    $course_options['-1'] = $no_change_text;
2998
+                    $course_attributes = array('name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course', 'class'=>' ');
2999
+                    $course_field = Sensei_Utils::generate_drop_down('-1', $course_options, $course_attributes);
3000
+                    echo $this->generate_all_lessons_edit_field(__('Lesson Course', 'woothemes-sensei'), $course_field);
3001 3001
 
3002 3002
                     //
3003 3003
                     // lesson complexity selection
3004 3004
                     //
3005
-                    $lesson_complexities =  $this->lesson_complexities();
3005
+                    $lesson_complexities = $this->lesson_complexities();
3006 3006
                     //pre-append the no change option
3007
-                    $lesson_complexities['-1']=  $no_change_text;
3008
-                    $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
3009
-                    $complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
3010
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
3007
+                    $lesson_complexities['-1'] = $no_change_text;
3008
+                    $complexity_dropdown_attributes = array('name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity', 'class'=>' ');
3009
+                    $complexity_filed = Sensei_Utils::generate_drop_down('-1', $lesson_complexities, $complexity_dropdown_attributes);
3010
+                    echo $this->generate_all_lessons_edit_field(__('Lesson Complexity', 'woothemes-sensei'), $complexity_filed);
3011 3011
 
3012 3012
                     ?>
3013 3013
 
@@ -3020,34 +3020,34 @@  discard block
 block discarded – undo
3020 3020
                     //
3021 3021
                     $pass_required_options = array(
3022 3022
                         '-1' => $no_change_text,
3023
-                         '0' => __('No','woothemes'),
3024
-                         '1' => __('Yes','woothemes'),
3023
+                         '0' => __('No', 'woothemes'),
3024
+                         '1' => __('Yes', 'woothemes'),
3025 3025
                     );
3026 3026
 
3027
-                    $pass_required_select_attributes = array( 'name'=> 'pass_required',
3027
+                    $pass_required_select_attributes = array('name'=> 'pass_required',
3028 3028
                                                                 'id'=> 'sensei-edit-lesson-pass-required',
3029
-                                                                'class'=>' '   );
3030
-                    $require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3031
-                    echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3029
+                                                                'class'=>' ');
3030
+                    $require_pass_field = Sensei_Utils::generate_drop_down('-1', $pass_required_options, $pass_required_select_attributes, false);
3031
+                    echo $this->generate_all_lessons_edit_field(__('Pass required', 'woothemes-sensei'), $require_pass_field);
3032 3032
 
3033 3033
                     //
3034 3034
                     // Quiz pass percentage
3035 3035
                     //
3036 3036
                     $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3037
-                    echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3037
+                    echo $this->generate_all_lessons_edit_field(__('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field);
3038 3038
 
3039 3039
                     //
3040 3040
                     // Enable quiz reset button
3041 3041
                     //
3042 3042
                     $quiz_reset_select__options = array(
3043 3043
                         '-1' => $no_change_text,
3044
-                        '0' => __('No','woothemes'),
3045
-                        '1' => __('Yes','woothemes'),
3044
+                        '0' => __('No', 'woothemes'),
3045
+                        '1' => __('Yes', 'woothemes'),
3046 3046
                     );
3047 3047
                     $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3048
-                    $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3049
-                    $quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3050
-                    echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3048
+                    $quiz_reset_select_attributes = array('name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ');
3049
+                    $quiz_reset_field = Sensei_Utils::generate_drop_down('-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false);
3050
+                    echo $this->generate_all_lessons_edit_field(__('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field);
3051 3051
 
3052 3052
                     ?>
3053 3053
             </div>
@@ -3066,17 +3066,17 @@  discard block
 block discarded – undo
3066 3066
      * @param string $field type markup for the field that must be wrapped.
3067 3067
      * @return string $field_html
3068 3068
      */
3069
-    public function generate_all_lessons_edit_field( $title  ,$field ){
3069
+    public function generate_all_lessons_edit_field($title, $field) {
3070 3070
 
3071 3071
         $html = '';
3072 3072
         $html = '<div class="inline-edit-group" >';
3073
-        $html .=  '<span class="title">'. $title .'</span> ';
3073
+        $html .= '<span class="title">'.$title.'</span> ';
3074 3074
         $html .= '<span class="input-text-wrap">';
3075 3075
         $html .= $field;
3076 3076
         $html .= '</span>';
3077 3077
         $html .= '</label></div>';
3078 3078
 
3079
-        return $html ;
3079
+        return $html;
3080 3080
 
3081 3081
     }//end generate_all_lessons_edit_field
3082 3082
 
@@ -3090,48 +3090,48 @@  discard block
 block discarded – undo
3090 3090
     function save_all_lessons_edit_fields() {
3091 3091
 
3092 3092
         // verify all the data before attempting to save
3093
-        if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3094
-            ||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3093
+        if ( ! isset($_POST['security']) || ! check_ajax_referer('bulk-edit-lessons', 'security')
3094
+            ||  empty($_POST['post_ids']) || ! is_array($_POST['post_ids'])) {
3095 3095
             die();
3096 3096
         }
3097 3097
 
3098 3098
         // get our variables
3099
-        $new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3100
-        $new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3101
-        $new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3102
-        $new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3103
-        $new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3099
+        $new_course = sanitize_text_field($_POST['sensei_edit_lesson_course']);
3100
+        $new_complexity = sanitize_text_field($_POST['sensei_edit_complexity']);
3101
+        $new_pass_required = sanitize_text_field($_POST['sensei_edit_pass_required']);
3102
+        $new_pass_percentage = sanitize_text_field($_POST['sensei_edit_pass_percentage']);
3103
+        $new_enable_quiz_reset = sanitize_text_field($_POST['sensei_edit_enable_quiz_reset']);
3104 3104
         // store the values for all selected posts
3105
-        foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3105
+        foreach ($_POST['post_ids'] as $lesson_id) {
3106 3106
 
3107 3107
             // get the quiz id needed for the quiz meta
3108
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3108
+            $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
3109 3109
 
3110 3110
             // do not save the items if the value is -1 as this
3111 3111
             // means it was not changed
3112 3112
 
3113 3113
             // update lesson course
3114
-            if( -1 != $new_course ){
3115
-                update_post_meta( $lesson_id, '_lesson_course', $new_course );
3114
+            if ( -1 != $new_course ) {
3115
+                update_post_meta($lesson_id, '_lesson_course', $new_course);
3116 3116
             }
3117 3117
             // update lesson complexity
3118
-            if( -1 != $new_complexity ){
3119
-                update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3118
+            if ( -1 != $new_complexity ) {
3119
+                update_post_meta($lesson_id, '_lesson_complexity', $new_complexity);
3120 3120
             }
3121 3121
 
3122 3122
             // Quiz Related settings
3123
-            if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3123
+            if (isset($quiz_id) && 0 < intval($quiz_id)) {
3124 3124
 
3125 3125
                 // update pass required
3126 3126
                 if (-1 != $new_pass_required) {
3127 3127
 
3128
-                    $checked = $new_pass_required  ? 'on' : '';
3128
+                    $checked = $new_pass_required ? 'on' : '';
3129 3129
                     update_post_meta($quiz_id, '_pass_required', $checked);
3130
-                    unset( $checked );
3130
+                    unset($checked);
3131 3131
                 }
3132 3132
 
3133 3133
                 // update pass percentage
3134
-                if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3134
+                if ( ! empty($new_pass_percentage) && is_numeric($new_pass_percentage)) {
3135 3135
 
3136 3136
                         update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3137 3137
 
@@ -3142,9 +3142,9 @@  discard block
 block discarded – undo
3142 3142
                 //
3143 3143
                 if (-1 != $new_enable_quiz_reset ) {
3144 3144
 
3145
-                    $checked = $new_enable_quiz_reset ? 'on' : ''  ;
3145
+                    $checked = $new_enable_quiz_reset ? 'on' : '';
3146 3146
                     update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3147
-                    unset( $checked );
3147
+                    unset($checked);
3148 3148
 
3149 3149
                 }
3150 3150
 
@@ -3168,31 +3168,31 @@  discard block
 block discarded – undo
3168 3168
      * @since 1.8.0
3169 3169
      * @return void
3170 3170
      */
3171
-    public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3171
+    public function set_quick_edit_admin_defaults($column_name, $post_id) {
3172 3172
 
3173
-        if( 'lesson-course' != $column_name ){
3173
+        if ('lesson-course' != $column_name) {
3174 3174
             return;
3175 3175
         }
3176 3176
         // load the script
3177
-        $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3178
-        wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3177
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3178
+        wp_enqueue_script('sensei-lesson-quick-edit', Sensei()->plugin_url.'assets/js/admin/lesson-quick-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true);
3179 3179
 
3180 3180
         // setup the values for all meta fields
3181 3181
         $data = array();
3182
-        foreach( $this->meta_fields as $field ){
3182
+        foreach ($this->meta_fields as $field) {
3183 3183
 
3184
-            $data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3184
+            $data[$field] = get_post_meta($post_id, '_'.$field, true);
3185 3185
 
3186 3186
         }
3187 3187
         // add quiz meta fields
3188
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3189
-        foreach( Sensei()->quiz->meta_fields as $field ){
3188
+        $quiz_id = Sensei()->lesson->lesson_quizzes($post_id);
3189
+        foreach (Sensei()->quiz->meta_fields as $field) {
3190 3190
 
3191
-            $data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3191
+            $data[$field] = get_post_meta($quiz_id, '_'.$field, true);
3192 3192
 
3193 3193
         }
3194 3194
 
3195
-        wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3195
+        wp_localize_script('sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data);
3196 3196
 
3197 3197
     }// end quick edit admin defaults
3198 3198
 
@@ -3205,19 +3205,19 @@  discard block
 block discarded – undo
3205 3205
      * @param array $classes
3206 3206
      * @return array $classes
3207 3207
      */
3208
-    public static function single_course_lessons_classes( $classes ){
3208
+    public static function single_course_lessons_classes($classes) {
3209 3209
 
3210
-        if(  is_singular('course') ){
3210
+        if (is_singular('course')) {
3211 3211
 
3212 3212
             global $post;
3213 3213
             $course_id = $post->ID;
3214 3214
 
3215
-            $lesson_classes = array( 'course', 'post' );
3216
-            if ( is_user_logged_in() ) {
3215
+            $lesson_classes = array('course', 'post');
3216
+            if (is_user_logged_in()) {
3217 3217
 
3218 3218
                 // Check if Lesson is complete
3219
-                $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3220
-                if ( $single_lesson_complete ) {
3219
+                $single_lesson_complete = Sensei_Utils::user_completed_lesson(get_the_ID(), get_current_user_id());
3220
+                if ($single_lesson_complete) {
3221 3221
 
3222 3222
                     $lesson_classes[] = 'lesson-completed';
3223 3223
 
@@ -3225,14 +3225,14 @@  discard block
 block discarded – undo
3225 3225
 
3226 3226
             } // End If Statement
3227 3227
 
3228
-            $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3229
-            if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3228
+            $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
3229
+            if (Sensei_Utils::is_preview_lesson(get_the_ID()) && ! $is_user_taking_course) {
3230 3230
 
3231 3231
                 $lesson_classes[] = 'lesson-preview';
3232 3232
 
3233 3233
             }
3234 3234
 
3235
-            $classes = array_merge( $classes, $lesson_classes  );
3235
+            $classes = array_merge($classes, $lesson_classes);
3236 3236
 
3237 3237
         }
3238 3238
 
@@ -3246,56 +3246,56 @@  discard block
 block discarded – undo
3246 3246
      * @since 1.9.0
3247 3247
      * @param $lesson_id
3248 3248
      */
3249
-    public static function the_lesson_meta( $lesson_id ){
3249
+    public static function the_lesson_meta($lesson_id) {
3250 3250
 
3251 3251
         global $wp_query;
3252 3252
         $loop_lesson_number = $wp_query->current_post + 1;
3253 3253
 
3254
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
3254
+        $course_id = Sensei()->lesson->get_course_id($lesson_id);
3255 3255
         $single_lesson_complete = false;
3256
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3256
+        $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
3257 3257
 
3258 3258
         // Get Lesson data
3259 3259
         $complexity_array = Sensei()->lesson->lesson_complexities();
3260 3260
 
3261
-        $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3262
-        if ( '' != $lesson_complexity ) {
3261
+        $lesson_complexity = get_post_meta($lesson_id, '_lesson_complexity', true);
3262
+        if ('' != $lesson_complexity) {
3263 3263
 
3264 3264
             $lesson_complexity = $complexity_array[$lesson_complexity];
3265 3265
 
3266 3266
         }
3267
-        $user_info = get_userdata( absint( get_post()->post_author ) );
3268
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3267
+        $user_info = get_userdata(absint(get_post()->post_author));
3268
+        $is_preview = Sensei_Utils::is_preview_lesson($lesson_id);
3269 3269
         $preview_label = '';
3270
-        if ( $is_preview && !$is_user_taking_course ) {
3270
+        if ($is_preview && ! $is_user_taking_course) {
3271 3271
 
3272
-            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3273
-            $preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3272
+            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text($lesson_id);
3273
+            $preview_label = '<span class="preview-heading">'.$preview_label.'</span>';
3274 3274
 
3275 3275
         }
3276 3276
 
3277 3277
 
3278
-        $count_markup= '';
3278
+        $count_markup = '';
3279 3279
         /**
3280 3280
          * Filter for if you want the $lesson_count to show next to the lesson.
3281 3281
          *
3282 3282
          * @since 1.0
3283 3283
          * @param bool default false.
3284 3284
          */
3285
-        if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3285
+        if (apply_filters('sensei_show_lesson_numbers', false)) {
3286 3286
 
3287
-            $count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3287
+            $count_markup = '<span class="lesson-number">'.$loop_lesson_number.'</span>';
3288 3288
 
3289 3289
         }
3290 3290
 
3291
-        $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3291
+        $heading_link_title = sprintf(__('Start %s', 'woothemes-sensei'), get_the_title($lesson_id));
3292 3292
 
3293 3293
         ?>
3294 3294
         <header>
3295 3295
             <h2>
3296
-                <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>"
3297
-                   title="<?php esc_attr_e( $heading_link_title ) ?>" >
3298
-                    <?php echo $count_markup. get_the_title( $lesson_id ) . $preview_label; ?>
3296
+                <a href="<?php echo esc_url_raw(get_permalink($lesson_id)) ?>"
3297
+                   title="<?php esc_attr_e($heading_link_title) ?>" >
3298
+                    <?php echo $count_markup.get_the_title($lesson_id).$preview_label; ?>
3299 3299
                 </a>
3300 3300
             </h2>
3301 3301
 
@@ -3304,33 +3304,33 @@  discard block
 block discarded – undo
3304 3304
                 <?php
3305 3305
 
3306 3306
                 $meta_html = '';
3307
-                $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3307
+                $user_lesson_status = Sensei_Utils::user_lesson_status(get_the_ID(), get_current_user_id());
3308 3308
 
3309
-                $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3310
-                if ( '' != $lesson_length ) {
3309
+                $lesson_length = get_post_meta($lesson_id, '_lesson_length', true);
3310
+                if ('' != $lesson_length) {
3311 3311
 
3312
-                    $meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3312
+                    $meta_html .= '<span class="lesson-length">'.__('Length: ', 'woothemes-sensei').$lesson_length.__(' minutes', 'woothemes-sensei').'</span>';
3313 3313
 
3314 3314
                 }
3315 3315
 
3316
-                if ( Sensei()->settings->get( 'lesson_author' ) ) {
3316
+                if (Sensei()->settings->get('lesson_author')) {
3317 3317
 
3318
-                    $meta_html .= '<span class="lesson-author">' .  __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
3318
+                    $meta_html .= '<span class="lesson-author">'.__('Author: ', 'woothemes-sensei').'<a href="'.get_author_posts_url(absint(get_post()->post_author)).'" title="'.esc_attr($user_info->display_name).'">'.esc_html($user_info->display_name).'</a></span>';
3319 3319
 
3320 3320
                 } // End If Statement
3321
-                if ( '' != $lesson_complexity ) {
3321
+                if ('' != $lesson_complexity) {
3322 3322
 
3323
-                    $meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3323
+                    $meta_html .= '<span class="lesson-complexity">'.__('Complexity: ', 'woothemes-sensei').$lesson_complexity.'</span>';
3324 3324
 
3325 3325
                 }
3326 3326
 
3327
-                if ( $single_lesson_complete ) {
3327
+                if ($single_lesson_complete) {
3328 3328
 
3329
-                    $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3329
+                    $meta_html .= '<span class="lesson-status complete">'.__('Complete', 'woothemes-sensei').'</span>';
3330 3330
 
3331
-                } elseif ( $user_lesson_status ) {
3331
+                } elseif ($user_lesson_status) {
3332 3332
 
3333
-                    $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3333
+                    $meta_html .= '<span class="lesson-status in-progress">'.__('In Progress', 'woothemes-sensei').'</span>';
3334 3334
 
3335 3335
                 } // End If Statement
3336 3336
 
@@ -3353,19 +3353,19 @@  discard block
 block discarded – undo
3353 3353
      *
3354 3354
      * @param $lesson_id
3355 3355
      */
3356
-    public static function the_lesson_thumbnail( $lesson_id ){
3356
+    public static function the_lesson_thumbnail($lesson_id) {
3357 3357
 
3358
-        if( empty( $lesson_id ) ){
3358
+        if (empty($lesson_id)) {
3359 3359
 
3360 3360
             $lesson_id = get_the_ID();
3361 3361
 
3362 3362
         }
3363 3363
 
3364
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3364
+        if ('lesson' != get_post_type($lesson_id)) {
3365 3365
             return;
3366 3366
         }
3367 3367
 
3368
-        echo Sensei()->lesson->lesson_image( $lesson_id );
3368
+        echo Sensei()->lesson->lesson_image($lesson_id);
3369 3369
     }
3370 3370
 
3371 3371
 
@@ -3376,14 +3376,14 @@  discard block
 block discarded – undo
3376 3376
      * @param string $excerpt
3377 3377
      * @return string $excerpt
3378 3378
      */
3379
-    public static function alter_the_lesson_excerpt( $excerpt ) {
3379
+    public static function alter_the_lesson_excerpt($excerpt) {
3380 3380
 
3381
-        if ('lesson' == get_post_type(get_the_ID())){
3381
+        if ('lesson' == get_post_type(get_the_ID())) {
3382 3382
 
3383 3383
             // remove this hooks to avoid an infinite loop.
3384
-            remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3384
+            remove_filter('get_the_excerpt', array('WooThemes_Sensei_Lesson', 'alter_the_lesson_excerpt'));
3385 3385
 
3386
-            return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3386
+            return WooThemes_Sensei_Lesson::lesson_excerpt(get_post(get_the_ID()));
3387 3387
         }
3388 3388
 
3389 3389
         return $excerpt;
@@ -3398,20 +3398,20 @@  discard block
 block discarded – undo
3398 3398
      * @param $current_lesson_id
3399 3399
      * @return mixed | bool | int $prerequisite_lesson_id or false
3400 3400
      */
3401
-    public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3401
+    public static function get_lesson_prerequisite_id($current_lesson_id) {
3402 3402
 
3403
-        $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3403
+        $prerequisite_lesson_id = get_post_meta($current_lesson_id, '_lesson_prerequisite', true);
3404 3404
 
3405 3405
         // set ti to false if not a valid prerequisite lesson id
3406
-        if(  empty( $prerequisite_lesson_id )
3407
-            || 'lesson' != get_post_type( $prerequisite_lesson_id )
3408
-            || $prerequisite_lesson_id == $current_lesson_id  ) {
3406
+        if (empty($prerequisite_lesson_id)
3407
+            || 'lesson' != get_post_type($prerequisite_lesson_id)
3408
+            || $prerequisite_lesson_id == $current_lesson_id) {
3409 3409
 
3410 3410
             $prerequisite_lesson_id = false;
3411 3411
 
3412 3412
         }
3413 3413
 
3414
-        return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3414
+        return apply_filters('sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id);
3415 3415
 
3416 3416
     }
3417 3417
 
@@ -3426,27 +3426,27 @@  discard block
 block discarded – undo
3426 3426
      * @param $user_id
3427 3427
      * @return bool
3428 3428
      */
3429
-    public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3429
+    public  static function is_prerequisite_complete($lesson_id, $user_id) {
3430 3430
 
3431
-        if( empty( $lesson_id ) || empty( $user_id )
3432
-        || 'lesson' != get_post_type( $lesson_id )
3433
-        ||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3431
+        if (empty($lesson_id) || empty($user_id)
3432
+        || 'lesson' != get_post_type($lesson_id)
3433
+        ||  ! is_a(get_user_by('id', $user_id), 'WP_User')) {
3434 3434
 
3435 3435
             return false;
3436 3436
 
3437 3437
         }
3438 3438
 
3439
-        $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3439
+        $pre_requisite_id = (string) self::get_lesson_prerequisite_id($lesson_id);
3440 3440
 
3441 3441
         // not a valid pre-requisite so pre-requisite is completed
3442
-        if( 'lesson' != get_post_type( $pre_requisite_id )
3443
-            || ! is_numeric( $pre_requisite_id ) ){
3442
+        if ('lesson' != get_post_type($pre_requisite_id)
3443
+            || ! is_numeric($pre_requisite_id)) {
3444 3444
 
3445 3445
             return true;
3446 3446
 
3447 3447
         }
3448 3448
 
3449
-        return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3449
+        return  Sensei_Utils::user_completed_lesson($pre_requisite_id, $user_id);
3450 3450
 
3451 3451
     }// end is_prerequisite_complete
3452 3452
 
@@ -3455,20 +3455,20 @@  discard block
 block discarded – undo
3455 3455
      *
3456 3456
      * @since 1.9.0
3457 3457
      */
3458
-    public  static function user_not_taking_course_message(){
3458
+    public  static function user_not_taking_course_message() {
3459 3459
 
3460 3460
         $lesson_id = get_the_ID();
3461 3461
 
3462
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3462
+        if ('lesson' != get_post_type($lesson_id)) {
3463 3463
             return;
3464 3464
         }
3465 3465
 
3466
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3467
-        $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3468
-        $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3469
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3466
+        $is_preview = Sensei_Utils::is_preview_lesson($lesson_id);
3467
+        $pre_requisite_complete = self::is_prerequisite_complete($lesson_id, get_current_user_id());
3468
+        $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
3469
+        $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id());
3470 3470
 
3471
-        if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3471
+        if ($pre_requisite_complete && $is_preview && ! $user_taking_course) {
3472 3472
             ?>
3473 3473
 
3474 3474
             <div class="sensei-message alert">
@@ -3488,11 +3488,11 @@  discard block
 block discarded – undo
3488 3488
      *
3489 3489
      * @since 1.9.0
3490 3490
      */
3491
-    public static function course_signup_link( ){
3491
+    public static function course_signup_link( ) {
3492 3492
 
3493
-        $course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3493
+        $course_id = Sensei()->lesson->get_course_id(get_the_ID());
3494 3494
 
3495
-        if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3495
+        if (empty($course_id) || 'course' != get_post_type($course_id) || sensei_all_access()) {
3496 3496
 
3497 3497
             return;
3498 3498
 
@@ -3502,42 +3502,42 @@  discard block
 block discarded – undo
3502 3502
         <section class="course-signup lesson-meta">
3503 3503
 
3504 3504
             <?php
3505
-            $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3505
+            $wc_post_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true);
3506 3506
 
3507
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3507
+            if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) {
3508 3508
 
3509 3509
                 global $current_user;
3510
-                if( is_user_logged_in() ) {
3510
+                if (is_user_logged_in()) {
3511 3511
                     wp_get_current_user();
3512 3512
 
3513
-                    $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3513
+                    $course_purchased = Sensei_Utils::sensei_customer_bought_product($current_user->user_email, $current_user->ID, $wc_post_id);
3514 3514
 
3515
-                    if( $course_purchased ) {
3515
+                    if ($course_purchased) {
3516 3516
 
3517
-                        $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3518
-                        $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3517
+                        $prereq_course_id = get_post_meta($course_id, '_course_prerequisite', true);
3518
+                        $course_link = '<a href="'.esc_url(get_permalink($prereq_course_id)).'" title="'.esc_attr(get_the_title($prereq_course_id)).'">'.__('the previous course', 'woothemes-sensei').'</a>';
3519 3519
                         ?>
3520 3520
                             <div class="sensei-message info">
3521 3521
 
3522
-                                <?php  echo sprintf( __( 'Please complete %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); ?>
3522
+                                <?php  echo sprintf(__('Please complete %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); ?>
3523 3523
 
3524 3524
                             </div>
3525 3525
 
3526 3526
                     <?php } else {
3527 3527
 
3528
-	                    if( ! Sensei_Utils::user_started_course( $course_id, $current_user->ID )  ){
3528
+	                    if ( ! Sensei_Utils::user_started_course($course_id, $current_user->ID)) {
3529 3529
 
3530 3530
 		                    ?>
3531 3531
 
3532 3532
 	                        <div class="sensei-message info">
3533 3533
 
3534 3534
 	                            <?php
3535
-	                            $course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3536
-	                                            . '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3537
-	                                            . '">' . __( 'course', 'woothemes-sensei' )
3535
+	                            $course_link = '<a href="'.esc_url(get_permalink($course_id))
3536
+	                                            . '"title="'.__('Sign Up', 'woothemes-sensei')
3537
+	                                            . '">'.__('course', 'woothemes-sensei')
3538 3538
 	                                            . '</a>';
3539 3539
 
3540
-	                            echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3540
+	                            echo  sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
3541 3541
 
3542 3542
 	                            ?>
3543 3543
 
@@ -3549,29 +3549,29 @@  discard block
 block discarded – undo
3549 3549
 
3550 3550
                 <?php } else { ?>
3551 3551
 
3552
-                    <div class="sensei-message info"><?php echo sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Sign Up', 'woothemes-sensei' )  . '">' . __( 'course', 'woothemes-sensei' ) . '</a>' ); ?></div>
3552
+                    <div class="sensei-message info"><?php echo sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Sign Up', 'woothemes-sensei').'">'.__('course', 'woothemes-sensei').'</a>'); ?></div>
3553 3553
 
3554 3554
                 <?php } ?>
3555 3555
 
3556 3556
             <?php } else { ?>
3557 3557
 
3558
-            <?php if( ! Sensei_Utils::user_started_course( $course_id, get_current_user_id() ) &&  sensei_is_login_required() )  : ?>
3558
+            <?php if ( ! Sensei_Utils::user_started_course($course_id, get_current_user_id()) && sensei_is_login_required())  : ?>
3559 3559
 
3560 3560
                 <div class="sensei-message alert">
3561 3561
                     <?php
3562
-                    $course_link =  '<a href="'
3563
-                                        . esc_url( get_permalink( $course_id ) )
3564
-                                        . '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3565
-                                        . '">' . __( 'course', 'woothemes-sensei' )
3562
+                    $course_link = '<a href="'
3563
+                                        . esc_url(get_permalink($course_id))
3564
+                                        . '" title="'.__('Sign Up', 'woothemes-sensei')
3565
+                                        . '">'.__('course', 'woothemes-sensei')
3566 3566
                                     . '</a>';
3567 3567
 
3568
-					if ( Sensei_Utils::is_preview_lesson( get_the_ID( ) ) ) {
3568
+					if (Sensei_Utils::is_preview_lesson(get_the_ID( ))) {
3569 3569
 
3570
-						echo sprintf( __( 'This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ),  $course_link );
3570
+						echo sprintf(__('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei'), $course_link);
3571 3571
 
3572 3572
 					} else {
3573 3573
 
3574
-						echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3574
+						echo sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
3575 3575
 
3576 3576
 					}
3577 3577
 
@@ -3592,14 +3592,14 @@  discard block
 block discarded – undo
3592 3592
      *
3593 3593
      * @since 1.9.0
3594 3594
      */
3595
-    public  static function prerequisite_complete_message(){
3595
+    public  static function prerequisite_complete_message() {
3596 3596
 
3597
-        $lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3597
+        $lesson_prerequisite = WooThemes_Sensei_Lesson::get_lesson_prerequisite_id(get_the_ID());
3598 3598
         $lesson_has_pre_requisite = $lesson_prerequisite > 0;
3599
-        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3599
+        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(get_the_ID(), get_current_user_id()) && $lesson_has_pre_requisite) {
3600 3600
 
3601
-            $prerequisite_lesson_link  = '<a href="' . esc_url( get_permalink( $lesson_prerequisite ) ) . '" title="' . esc_attr(  sprintf( __( 'You must first complete: %1$s', 'woothemes-sensei' ), get_the_title( $lesson_prerequisite ) ) ) . '">' . get_the_title( $lesson_prerequisite ). '</a>';
3602
-            echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3601
+            $prerequisite_lesson_link = '<a href="'.esc_url(get_permalink($lesson_prerequisite)).'" title="'.esc_attr(sprintf(__('You must first complete: %1$s', 'woothemes-sensei'), get_the_title($lesson_prerequisite))).'">'.get_the_title($lesson_prerequisite).'</a>';
3602
+            echo sprintf(__('You must first complete %1$s before viewing this Lesson', 'woothemes-sensei'), $prerequisite_lesson_link);
3603 3603
 
3604 3604
         }
3605 3605
 
@@ -3611,7 +3611,7 @@  discard block
 block discarded – undo
3611 3611
      *
3612 3612
      * @deprecated since 1.9.0
3613 3613
      */
3614
-    public static function deprecate_sensei_lesson_archive_header_hook(){
3614
+    public static function deprecate_sensei_lesson_archive_header_hook() {
3615 3615
 
3616 3616
         sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3617 3617
 
@@ -3627,9 +3627,9 @@  discard block
 block discarded – undo
3627 3627
 
3628 3628
         $before_html = '<header class="archive-header"><h1>';
3629 3629
         $after_html = '</h1></header>';
3630
-        $html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3630
+        $html = $before_html.__('Lessons Archive', 'woothemes-sensei').$after_html;
3631 3631
 
3632
-        echo apply_filters( 'sensei_lesson_archive_title', $html );
3632
+        echo apply_filters('sensei_lesson_archive_title', $html);
3633 3633
 
3634 3634
     } // sensei_course_archive_header()
3635 3635
 
@@ -3639,7 +3639,7 @@  discard block
 block discarded – undo
3639 3639
      * @global $post
3640 3640
      * @since 1.9.0
3641 3641
      */
3642
-    public static function the_title(){
3642
+    public static function the_title() {
3643 3643
 
3644 3644
         global $post;
3645 3645
 
@@ -3652,7 +3652,7 @@  discard block
 block discarded – undo
3652 3652
                 /**
3653 3653
                  * Filter documented in class-sensei-messages.php the_title
3654 3654
                  */
3655
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3655
+                echo apply_filters('sensei_single_title', get_the_title($post), $post->post_type);
3656 3656
                 ?>
3657 3657
 
3658 3658
             </h1>
@@ -3670,16 +3670,16 @@  discard block
 block discarded – undo
3670 3670
      *
3671 3671
      * @param $post_id
3672 3672
      */
3673
-    public static function flush_rewrite_rules( $post_id ){
3673
+    public static function flush_rewrite_rules($post_id) {
3674 3674
 
3675
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3675
+        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3676 3676
 
3677 3677
             return;
3678 3678
 
3679 3679
         }
3680 3680
 
3681 3681
 
3682
-        if( 'lesson' == get_post_type( $post_id )  ){
3682
+        if ('lesson' == get_post_type($post_id)) {
3683 3683
 
3684 3684
             Sensei()->initiate_rewrite_rules_flush();
3685 3685
 
@@ -3696,27 +3696,27 @@  discard block
 block discarded – undo
3696 3696
      * @param int $lesson_id
3697 3697
      * @param int $user_id
3698 3698
      */
3699
-    public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3699
+    public static function footer_quiz_call_to_action($lesson_id = 0, $user_id = 0) {
3700 3700
 
3701 3701
 
3702
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3703
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3702
+        $lesson_id                 = empty($lesson_id) ? get_the_ID() : $lesson_id;
3703
+        $user_id                   = empty($lesson_id) ? get_current_user_id() : $user_id;
3704 3704
 
3705 3705
 
3706
-	    if ( ! sensei_can_user_view_lesson( $lesson_id, $user_id ) ) {
3706
+	    if ( ! sensei_can_user_view_lesson($lesson_id, $user_id)) {
3707 3707
 		    return;
3708 3708
 	    }
3709 3709
 
3710
-        $lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3711
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3712
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3713
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3710
+        $lesson_prerequisite       = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
3711
+        $lesson_course_id          = (int) get_post_meta($lesson_id, '_lesson_course', true);
3712
+        $quiz_id                   = Sensei()->lesson->lesson_quizzes($lesson_id);
3713
+        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id);
3714 3714
         $show_actions              = is_user_logged_in() ? true : false;
3715 3715
 
3716
-        if( intval( $lesson_prerequisite ) > 0 ) {
3716
+        if (intval($lesson_prerequisite) > 0) {
3717 3717
 
3718 3718
             // If the user hasn't completed the prereq then hide the current actions
3719
-            $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3719
+            $show_actions = Sensei_Utils::user_completed_lesson($lesson_prerequisite, $user_id);
3720 3720
 
3721 3721
         }
3722 3722
 
@@ -3725,19 +3725,19 @@  discard block
 block discarded – undo
3725 3725
         <footer>
3726 3726
 
3727 3727
             <?php
3728
-            if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3728
+            if ($show_actions && $quiz_id && Sensei()->access_settings()) {
3729 3729
 
3730
-                $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3731
-                if( $has_quiz_questions ) {
3730
+                $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
3731
+                if ($has_quiz_questions) {
3732 3732
                     ?>
3733 3733
 
3734 3734
                     <p>
3735 3735
 
3736 3736
                         <a class="button"
3737
-                           href="<?php echo esc_url_raw( get_permalink( $quiz_id ) ); ?>"
3738
-                           title="<?php _e( 'View the Lesson Quiz', 'woothemes-sensei'  ); ?>">
3737
+                           href="<?php echo esc_url_raw(get_permalink($quiz_id)); ?>"
3738
+                           title="<?php _e('View the Lesson Quiz', 'woothemes-sensei'); ?>">
3739 3739
 
3740
-                            <?php  _e( 'View the Lesson Quiz', 'woothemes-sensei' ); ?>
3740
+                            <?php  _e('View the Lesson Quiz', 'woothemes-sensei'); ?>
3741 3741
 
3742 3742
                         </a>
3743 3743
 
@@ -3748,11 +3748,11 @@  discard block
 block discarded – undo
3748 3748
 
3749 3749
             } // End If Statement
3750 3750
 
3751
-            if ( $show_actions && ! $has_user_completed_lesson ) {
3751
+            if ($show_actions && ! $has_user_completed_lesson) {
3752 3752
 
3753 3753
                 sensei_complete_lesson_button();
3754 3754
 
3755
-            } elseif( $show_actions ) {
3755
+            } elseif ($show_actions) {
3756 3756
 
3757 3757
                 sensei_reset_lesson_button();
3758 3758
 
@@ -3769,20 +3769,20 @@  discard block
 block discarded – undo
3769 3769
      *
3770 3770
      * @since 1.9.0
3771 3771
      */
3772
-    public static function output_comments(){
3772
+    public static function output_comments() {
3773 3773
 
3774
-        if( ! is_user_logged_in() ){
3774
+        if ( ! is_user_logged_in()) {
3775 3775
             return;
3776 3776
         }
3777 3777
 
3778
-        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3779
-        $course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3780
-        $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3781
-        $user_taking_course = Sensei_Utils::user_started_course($course_id );
3778
+        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete(get_the_ID(), get_current_user_id());
3779
+        $course_id = Sensei()->lesson->get_course_id(get_the_ID());
3780
+        $allow_comments = Sensei()->settings->settings['lesson_comments'];
3781
+        $user_taking_course = Sensei_Utils::user_started_course($course_id);
3782 3782
 
3783
-        $lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3783
+        $lesson_allow_comments = $allow_comments && $pre_requisite_complete && $user_taking_course;
3784 3784
 
3785
-        if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3785
+        if ($lesson_allow_comments || is_singular('sensei_message')) {
3786 3786
 
3787 3787
             comments_template();
3788 3788
 
@@ -3798,26 +3798,26 @@  discard block
 block discarded – undo
3798 3798
      *
3799 3799
      * @since 1.9.0
3800 3800
      */
3801
-    public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3801
+    public static function user_lesson_quiz_status_message($lesson_id = 0, $user_id = 0) {
3802 3802
 
3803
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3804
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3805
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3806
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3807
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3803
+        $lesson_id                 = empty($lesson_id) ? get_the_ID() : $lesson_id;
3804
+        $user_id                   = empty($lesson_id) ? get_current_user_id() : $user_id;
3805
+        $lesson_course_id          = (int) get_post_meta($lesson_id, '_lesson_course', true);
3806
+        $quiz_id                   = Sensei()->lesson->lesson_quizzes($lesson_id);
3807
+        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id);
3808 3808
 
3809 3809
 
3810
-        if ( $quiz_id && is_user_logged_in()
3811
-            && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3810
+        if ($quiz_id && is_user_logged_in()
3811
+            && Sensei_Utils::user_started_course($lesson_course_id, $user_id)) {
3812 3812
 
3813 3813
             $no_quiz_count = 0;
3814
-            $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3814
+            $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
3815 3815
 
3816 3816
             // Display lesson quiz status message
3817
-            if ( $has_user_completed_lesson || $has_quiz_questions ) {
3818
-                $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3819
-                echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3820
-                if( $has_quiz_questions ) {
3817
+            if ($has_user_completed_lesson || $has_quiz_questions) {
3818
+                $status = Sensei_Utils::sensei_user_quiz_status_message($lesson_id, $user_id, true);
3819
+                echo '<div class="sensei-message '.$status['box_class'].'">'.$status['message'].'</div>';
3820
+                if ($has_quiz_questions) {
3821 3821
                    // echo $status['extra'];
3822 3822
                 } // End If Statement
3823 3823
             } // End If Statement
@@ -3833,11 +3833,11 @@  discard block
 block discarded – undo
3833 3833
      * @param $content
3834 3834
      * @return string
3835 3835
      */
3836
-    public static function limit_archive_content ( $content ){
3836
+    public static function limit_archive_content($content) {
3837 3837
 
3838
-        if( is_archive('lesson') && Sensei()->settings->get('access_permission') ){
3838
+        if (is_archive('lesson') && Sensei()->settings->get('access_permission')) {
3839 3839
 
3840
-            return wp_trim_words( $content, $num_words = 30, $more = '…' );
3840
+            return wp_trim_words($content, $num_words = 30, $more = '…');
3841 3841
         }
3842 3842
 
3843 3843
         return $content;
@@ -3850,9 +3850,9 @@  discard block
 block discarded – undo
3850 3850
      * @since 1.9.0
3851 3851
      * @return array
3852 3852
      */
3853
-    public static function get_all_lesson_ids(){
3853
+    public static function get_all_lesson_ids() {
3854 3854
 
3855
-        return get_posts( array(
3855
+        return get_posts(array(
3856 3856
             'post_type'=>'lesson',
3857 3857
             'fields'=>'ids',
3858 3858
             'post_status' => 'publish',
@@ -3869,4 +3869,4 @@  discard block
 block discarded – undo
3869 3869
  * @ignore only for backward compatibility
3870 3870
  * @since 1.9.0
3871 3871
  */
3872
-class WooThemes_Sensei_Lesson extends Sensei_Lesson{}
3872
+class WooThemes_Sensei_Lesson extends Sensei_Lesson {}
Please login to merge, or discard this patch.
includes/class-sensei-analysis-user-profile-list-table.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -201,7 +201,7 @@
 block discarded – undo
201 201
 
202 202
 		if( 'complete' == $item->comment_approved ) {
203 203
 
204
-            $status =  __( 'Completed', 'woothemes-sensei' );
204
+			$status =  __( 'Completed', 'woothemes-sensei' );
205 205
 			$status_class = 'graded';
206 206
 
207 207
 			$course_end_date = $item->comment_date;
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.
Spacing   +78 added lines, -78 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
  * Analysis User Profile Data Table in Sensei.
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
 	 * @since  1.2.0
19 19
 	 * @return  void
20 20
 	 */
21
-	public function __construct ( $user_id = 0 ) {
22
-		$this->user_id = intval( $user_id );
21
+	public function __construct($user_id = 0) {
22
+		$this->user_id = intval($user_id);
23 23
 
24 24
 		// Load Parent token into constructor
25
-		parent::__construct( 'analysis_user_profile' );
25
+		parent::__construct('analysis_user_profile');
26 26
 
27 27
 		// Actions
28
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
29
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
28
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
29
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
30 30
 
31
-		add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) );
31
+		add_filter('sensei_list_table_search_button_text', array($this, 'search_button'));
32 32
 	} // End __construct()
33 33
 
34 34
 	/**
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	function get_columns() {
40 40
 		$columns = array(
41
-			'title' => __( 'Course', 'woothemes-sensei' ),
42
-			'started' => __( 'Date Started', 'woothemes-sensei' ),
43
-			'completed' => __( 'Date Completed', 'woothemes-sensei' ),
44
-			'status' => __( 'Status', 'woothemes-sensei' ),
41
+			'title' => __('Course', 'woothemes-sensei'),
42
+			'started' => __('Date Started', 'woothemes-sensei'),
43
+			'completed' => __('Date Completed', 'woothemes-sensei'),
44
+			'status' => __('Status', 'woothemes-sensei'),
45 45
 //			'grade' => __( 'Grade', 'woothemes-sensei' ),
46
-			'percent' => __( 'Percent Complete', 'woothemes-sensei' ),
46
+			'percent' => __('Percent Complete', 'woothemes-sensei'),
47 47
 		);
48
-		$columns = apply_filters( 'sensei_analysis_user_profile_columns', $columns );
48
+		$columns = apply_filters('sensei_analysis_user_profile_columns', $columns);
49 49
 		return $columns;
50 50
 	}
51 51
 
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	function get_sortable_columns() {
58 58
 		$columns = array(
59
-			'title' => array( 'title', false ),
60
-			'started' => array( 'started', false ),
61
-			'completed' => array( 'completed', false ),
62
-			'status' => array( 'status', false ),
59
+			'title' => array('title', false),
60
+			'started' => array('started', false),
61
+			'completed' => array('completed', false),
62
+			'status' => array('status', false),
63 63
 //			'grade' => array( 'grade', false ),
64
-			'percent' => array( 'percent', false )
64
+			'percent' => array('percent', false)
65 65
 		);
66
-		$columns = apply_filters( 'sensei_analysis_user_profile_columns_sortable', $columns );
66
+		$columns = apply_filters('sensei_analysis_user_profile_columns_sortable', $columns);
67 67
 		return $columns;
68 68
 	}
69 69
 
@@ -77,32 +77,32 @@  discard block
 block discarded – undo
77 77
 
78 78
 		// Handle orderby (needs work)
79 79
 		$orderby = '';
80
-		if ( !empty( $_GET['orderby'] ) ) {
81
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
82
-				$orderby = esc_html( $_GET['orderby'] );
80
+		if ( ! empty($_GET['orderby'])) {
81
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
82
+				$orderby = esc_html($_GET['orderby']);
83 83
 			} // End If Statement
84 84
 		}
85 85
 
86 86
 		// Handle order
87 87
 		$order = 'ASC';
88
-		if ( !empty( $_GET['order'] ) ) {
89
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
88
+		if ( ! empty($_GET['order'])) {
89
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
90 90
 		}
91 91
 
92 92
 		// Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids
93 93
 		$search = false;
94
-		if ( !empty( $_GET['s'] ) ) {
95
-			$search = esc_html( $_GET['s'] );
94
+		if ( ! empty($_GET['s'])) {
95
+			$search = esc_html($_GET['s']);
96 96
 		} // End If Statement
97 97
 		$this->search = $search;
98 98
 
99
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
100
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
99
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
100
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
101 101
 
102 102
 		$paged = $this->get_pagenum();
103 103
 		$offset = 0;
104
-		if ( !empty($paged) ) {
105
-			$offset = $per_page * ( $paged - 1 );
104
+		if ( ! empty($paged)) {
105
+			$offset = $per_page * ($paged - 1);
106 106
 		} // End If Statement
107 107
 
108 108
 		$args = array(
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
 			'orderby' => $orderby,
112 112
 			'order' => $order,
113 113
 		);
114
-		if ( $this->search ) {
114
+		if ($this->search) {
115 115
 			$args['search'] = $this->search;
116 116
 		} // End If Statement
117 117
 
118
-		$this->items = $this->get_course_statuses( $args );
118
+		$this->items = $this->get_course_statuses($args);
119 119
 
120 120
 		$total_items = $this->total_items;
121
-		$total_pages = ceil( $total_items / $per_page );
122
-		$this->set_pagination_args( array(
121
+		$total_pages = ceil($total_items / $per_page);
122
+		$this->set_pagination_args(array(
123 123
 			'total_items' => $total_items,
124 124
 			'total_pages' => $total_pages,
125 125
 			'per_page' => $per_page
126
-		) );
126
+		));
127 127
 	}
128 128
 
129 129
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @since  1.7.0
132 132
 	 * @return data
133 133
 	 */
134
-	public function generate_report( $report ) {
134
+	public function generate_report($report) {
135 135
 
136 136
 		$data = array();
137 137
 
@@ -139,22 +139,22 @@  discard block
 block discarded – undo
139 139
 
140 140
 		// Handle orderby
141 141
 		$orderby = '';
142
-		if ( !empty( $_GET['orderby'] ) ) {
143
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
144
-				$orderby = esc_html( $_GET['orderby'] );
142
+		if ( ! empty($_GET['orderby'])) {
143
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
144
+				$orderby = esc_html($_GET['orderby']);
145 145
 			} // End If Statement
146 146
 		}
147 147
 
148 148
 		// Handle order
149 149
 		$order = 'ASC';
150
-		if ( !empty( $_GET['order'] ) ) {
151
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
150
+		if ( ! empty($_GET['order'])) {
151
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
152 152
 		}
153 153
 
154 154
 		// Handle search
155 155
 		$search = false;
156
-		if ( !empty( $_GET['s'] ) ) {
157
-			$search = esc_html( $_GET['s'] );
156
+		if ( ! empty($_GET['s'])) {
157
+			$search = esc_html($_GET['s']);
158 158
 		} // End If Statement
159 159
 		$this->search = $search;
160 160
 
@@ -162,23 +162,23 @@  discard block
 block discarded – undo
162 162
 			'orderby' => $orderby,
163 163
 			'order' => $order,
164 164
 		);
165
-		if ( $this->search ) {
165
+		if ($this->search) {
166 166
 			$args['search'] = $this->search;
167 167
 		} // End If Statement
168 168
 
169 169
 		// Start the csv with the column headings
170 170
 		$column_headers = array();
171 171
 		$columns = $this->get_columns();
172
-		foreach( $columns AS $key => $title ) {
172
+		foreach ($columns AS $key => $title) {
173 173
 			$column_headers[] = $title;
174 174
 		}
175 175
 		$data[] = $column_headers;
176 176
 
177
-		$this->items = $this->get_course_statuses( $args );
177
+		$this->items = $this->get_course_statuses($args);
178 178
 
179 179
 		// Process each row
180
-		foreach( $this->items AS $item) {
181
-			$data[] = $this->get_row_data( $item );
180
+		foreach ($this->items AS $item) {
181
+			$data[] = $this->get_row_data($item);
182 182
 		}
183 183
 
184 184
 		return $data;
@@ -189,43 +189,43 @@  discard block
 block discarded – undo
189 189
 	 * @since  1.7.0
190 190
 	 * @param object $item The current item
191 191
 	 */
192
-	protected function get_row_data( $item ) {
192
+	protected function get_row_data($item) {
193 193
 
194
-		$course_title =  get_the_title( $item->comment_post_ID );
195
-		$course_percent = get_comment_meta( $item->comment_ID, 'percent', true );
196
-		$course_start_date = get_comment_meta( $item->comment_ID, 'start', true );
194
+		$course_title = get_the_title($item->comment_post_ID);
195
+		$course_percent = get_comment_meta($item->comment_ID, 'percent', true);
196
+		$course_start_date = get_comment_meta($item->comment_ID, 'start', true);
197 197
 		$course_end_date = '';
198 198
 
199
-		if( 'complete' == $item->comment_approved ) {
199
+		if ('complete' == $item->comment_approved) {
200 200
 
201
-            $status =  __( 'Completed', 'woothemes-sensei' );
201
+            $status = __('Completed', 'woothemes-sensei');
202 202
 			$status_class = 'graded';
203 203
 
204 204
 			$course_end_date = $item->comment_date;
205 205
 
206 206
 		} else {
207 207
 
208
-			$status =  __( 'In Progress', 'woothemes-sensei' );
208
+			$status = __('In Progress', 'woothemes-sensei');
209 209
 			$status_class = 'in-progress';
210 210
 
211 211
 		}
212 212
 
213 213
 		// Output users data
214
-		if ( !$this->csv_output ) {
215
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $this->user_id, 'course_id' => $item->comment_post_ID ), admin_url( 'admin.php' ) );
214
+		if ( ! $this->csv_output) {
215
+			$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $this->user_id, 'course_id' => $item->comment_post_ID), admin_url('admin.php'));
216 216
 
217
-			$course_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $course_title . '</a></strong>';
218
-			$status = sprintf( '<span class="%s">%s</span>', $status_class, $status );
219
-			if ( is_numeric($course_percent) ) {
217
+			$course_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.$course_title.'</a></strong>';
218
+			$status = sprintf('<span class="%s">%s</span>', $status_class, $status);
219
+			if (is_numeric($course_percent)) {
220 220
 				$course_percent .= '%';
221 221
 			}
222 222
 		} // End If Statement
223
-		$column_data = apply_filters( 'sensei_analysis_user_profile_column_data', array( 'title' => $course_title,
223
+		$column_data = apply_filters('sensei_analysis_user_profile_column_data', array('title' => $course_title,
224 224
 										'started' => $course_start_date,
225 225
 										'completed' => $course_end_date,
226 226
 										'status' => $status,
227 227
 										'percent' => $course_percent,
228
-									), $item );
228
+									), $item);
229 229
 
230 230
 		return $column_data;
231 231
 	}
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @since  1.7.0
236 236
 	 * @return array statuses
237 237
 	 */
238
-	private function get_course_statuses( $args ) {
238
+	private function get_course_statuses($args) {
239 239
 
240 240
 		$activity_args = array( 
241 241
 				'user_id' => $this->user_id,
@@ -247,23 +247,23 @@  discard block
 block discarded – undo
247 247
 				'status' => 'any',
248 248
 			);
249 249
 
250
-		$activity_args = apply_filters( 'sensei_analysis_user_profile_filter_statuses', $activity_args );
250
+		$activity_args = apply_filters('sensei_analysis_user_profile_filter_statuses', $activity_args);
251 251
 
252 252
 		// WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice
253
-		$this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
253
+		$this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0)));
254 254
 
255 255
 		// Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views?
256
-		if ( $this->total_items < $activity_args['offset'] ) {
256
+		if ($this->total_items < $activity_args['offset']) {
257 257
 
258
-			$new_paged = floor( $this->total_items / $activity_args['number'] );
258
+			$new_paged = floor($this->total_items / $activity_args['number']);
259 259
 			$activity_args['offset'] = $new_paged * $activity_args['number'];
260 260
 
261 261
 		}
262
-		$statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true );
262
+		$statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true);
263 263
 
264 264
 		// Need to always return an array, even with only 1 item
265
-		if ( !is_array($statuses) ) {
266
-			$statuses = array( $statuses );
265
+		if ( ! is_array($statuses)) {
266
+			$statuses = array($statuses);
267 267
 		}
268 268
 
269 269
 		return $statuses;
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * @return void
277 277
 	 */
278 278
 	public function no_items() {
279
-		echo  __( 'No courses found.', 'woothemes-sensei' );
279
+		echo  __('No courses found.', 'woothemes-sensei');
280 280
 	} // End no_items()
281 281
 
282 282
 	/**
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 * @return void
286 286
 	 */
287 287
 	public function data_table_header() {
288
-		echo '<strong>' . __( 'Courses', 'woothemes-sensei' ) . '</strong>';
288
+		echo '<strong>'.__('Courses', 'woothemes-sensei').'</strong>';
289 289
 	}
290 290
 
291 291
 	/**
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 	 * @return void
295 295
 	 */
296 296
 	public function data_table_footer() {
297
-		$user = get_user_by( 'id', $this->user_id );
298
-		$report = sanitize_title( $user->display_name ) . '-course-overview';
299
-		$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $this->user_id, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) );
300
-		echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>';
297
+		$user = get_user_by('id', $this->user_id);
298
+		$report = sanitize_title($user->display_name).'-course-overview';
299
+		$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $this->user_id, 'sensei_report_download' => $report), admin_url('admin.php'));
300
+		echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>';
301 301
 	}
302 302
 
303 303
 	/**
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 	 * @since  1.7.0
306 306
 	 * @return string
307 307
 	 */
308
-	public function search_button( $text = '' ) {
309
-		return __( 'Search Courses', 'woothemes-sensei' );
308
+	public function search_button($text = '') {
309
+		return __('Search Courses', 'woothemes-sensei');
310 310
 	}
311 311
 
312 312
 } // End Class
Please login to merge, or discard this patch.
templates/globals/wrapper-end.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
3 5
 /**
4 6
  * The Template for displaying the my course page data.
5 7
  *
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * Content wrappers
5 5
  *
Please login to merge, or discard this patch.
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,15 +1,15 @@
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) exit;
3 3
 /**
4
- * Content wrappers
5
- *
6
- * All support theme wrappers can be found in includes/theme-integrations
7
- *
8
- * @author 		Automattic
9
- * @package 	Sensei
10
- * @category    Templates
11
- * @version     1.9.0
12
- */
4
+	 * Content wrappers
5
+	 *
6
+	 * All support theme wrappers can be found in includes/theme-integrations
7
+	 *
8
+	 * @author 		Automattic
9
+	 * @package 	Sensei
10
+	 * @category    Templates
11
+	 * @version     1.9.0
12
+	 */
13 13
 ?>
14 14
 
15 15
     </main>
Please login to merge, or discard this patch.
templates/single-quiz/question_type-multi-line.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
3 5
 /**
4 6
  * The Template for displaying the my course page data.
5 7
  *
Please login to merge, or discard this patch.
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -14,19 +14,19 @@
 block discarded – undo
14 14
 
15 15
 <?php
16 16
 
17
-    /**
18
-     * Get the question data with the current quiz id
19
-     * All data is loaded in this array to keep the template clean.
20
-     */
21
-    $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
17
+	/**
18
+	 * Get the question data with the current quiz id
19
+	 * All data is loaded in this array to keep the template clean.
20
+	 */
21
+	$question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
22 22
 
23 23
 ?>
24 24
 
25 25
 <?php
26 26
 
27
-    Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ]  ,
28
-                                                'textquestion' . $question_data[ 'ID' ] ,
29
-                                                'sensei_question[' . $question_data[ 'ID' ] . ']' );
27
+	Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ]  ,
28
+												'textquestion' . $question_data[ 'ID' ] ,
29
+												'sensei_question[' . $question_data[ 'ID' ] . ']' );
30 30
 
31 31
 ?>
32 32
 
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit;
2
+if ( ! defined('ABSPATH')) exit;
3 3
 /**
4 4
  * The Template for displaying Multi Line Questions.
5 5
  *
@@ -18,15 +18,15 @@  discard block
 block discarded – undo
18 18
      * Get the question data with the current quiz id
19 19
      * All data is loaded in this array to keep the template clean.
20 20
      */
21
-    $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() );
21
+    $question_data = WooThemes_Sensei_Question::get_template_data(sensei_get_the_question_id(), get_the_ID());
22 22
 
23 23
 ?>
24 24
 
25 25
 <?php
26 26
 
27
-    Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ]  ,
28
-                                                'textquestion' . $question_data[ 'ID' ] ,
29
-                                                'sensei_question[' . $question_data[ 'ID' ] . ']' );
27
+    Sensei_Utils::sensei_text_editor($question_data['user_answer_entry'],
28
+                                                'textquestion'.$question_data['ID'],
29
+                                                'sensei_question['.$question_data['ID'].']');
30 30
 
31 31
 ?>
32 32
 
Please login to merge, or discard this patch.