Completed
Push — master ( 9787ee...c85389 )
by Matty
05:41
created
widgets/widget-woothemes-sensei-course-component.php 3 patches
Indentation   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -66,9 +66,9 @@  discard block
 block discarded – undo
66 66
 
67 67
 		//don't show active or completed course if a user is not logged in
68 68
 		if ( ! in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) )
69
-		     || ( ! is_user_logged_in() && ( 'activecourses' == $instance['component'] || 'completedcourses' == $instance['component'] ) )  ) {
69
+			 || ( ! is_user_logged_in() && ( 'activecourses' == $instance['component'] || 'completedcourses' == $instance['component'] ) )  ) {
70 70
 			// No Output
71
-            return;
71
+			return;
72 72
 
73 73
 		}
74 74
 
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @param  array $instance The settings for this instance.
133 133
 	 * @return void
134 134
 	 */
135
-    public function form( $instance ) {
135
+	public function form( $instance ) {
136 136
 
137 137
 		/* Set up some default widget settings. */
138 138
 		/* Make sure all keys are added here, even with empty string values. */
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 	 * Load the desired component, if a method is available for it.
172 172
 	 *
173 173
 	 * @param array $instance The component to potentially be loaded.
174
-     *
174
+	 *
175 175
 	 * @since  1.0.0
176 176
 	 * @return void
177 177
 	 */
@@ -316,8 +316,8 @@  discard block
 block discarded – undo
316 316
 			if ( 'activecourses' == esc_attr( $this->instance['component'] ) || 'completedcourses' == esc_attr( $this->instance['component'] ) ) {
317 317
 				$my_account_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
318 318
 				echo '<li class="my-account fix"><a href="'. esc_url( get_permalink( $my_account_page_id ) ) .'">'
319
-				     .__('My Courses', 'woothemes-sensei')
320
-				     .'<span class="meta-nav"></span></a></li>';
319
+					 .__('My Courses', 'woothemes-sensei')
320
+					 .'<span class="meta-nav"></span></a></li>';
321 321
 			} // End If Statement
322 322
 
323 323
 			?>
Please login to merge, or discard this patch.
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly.
3 3
 
4 4
 /**
5 5
  * Sensei Course Component Widget
@@ -26,31 +26,31 @@  discard block
 block discarded – undo
26 26
 	public function __construct() {
27 27
 		/* Widget variable settings. */
28 28
 		$this->woo_widget_cssclass = 'widget_sensei_course_component';
29
-		$this->woo_widget_description = __( 'This widget will output a list of Courses - New, Featured, Free, Paid, Active, Completed.', 'woothemes-sensei' );
29
+		$this->woo_widget_description = __('This widget will output a list of Courses - New, Featured, Free, Paid, Active, Completed.', 'woothemes-sensei');
30 30
 		$this->woo_widget_idbase = 'sensei_course_component';
31
-		$this->woo_widget_title = __( 'Sensei - Course Component', 'woothemes-sensei' );
31
+		$this->woo_widget_title = __('Sensei - Course Component', 'woothemes-sensei');
32 32
 
33 33
 		$this->woo_widget_componentslist = array(
34
-												'usercourses' => __( 'New Courses', 'woothemes-sensei' ),
35
-												'featuredcourses' => __( 'Featured Courses', 'woothemes-sensei' ),
36
-												'activecourses' => __( 'My Active Courses', 'woothemes-sensei' ),
37
-												'completedcourses' => __( 'My Completed Courses', 'woothemes-sensei' ),
34
+												'usercourses' => __('New Courses', 'woothemes-sensei'),
35
+												'featuredcourses' => __('Featured Courses', 'woothemes-sensei'),
36
+												'activecourses' => __('My Active Courses', 'woothemes-sensei'),
37
+												'completedcourses' => __('My Completed Courses', 'woothemes-sensei'),
38 38
 												);
39 39
 
40 40
 		// Add support for the WooCommerce shelf.
41
-		if ( Sensei_WC::is_woocommerce_active() ) {
42
-			$this->woo_widget_componentslist['freecourses'] = __( 'Free Courses', 'woothemes-sensei' );
43
-			$this->woo_widget_componentslist['paidcourses'] = __( 'Paid Courses', 'woothemes-sensei' );
41
+		if (Sensei_WC::is_woocommerce_active()) {
42
+			$this->woo_widget_componentslist['freecourses'] = __('Free Courses', 'woothemes-sensei');
43
+			$this->woo_widget_componentslist['paidcourses'] = __('Paid Courses', 'woothemes-sensei');
44 44
 		}
45 45
 
46 46
 		/* Widget settings. */
47
-		$widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description );
47
+		$widget_ops = array('classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description);
48 48
 
49 49
 		/* Widget control settings. */
50
-		$control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase );
50
+		$control_ops = array('width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase);
51 51
 
52 52
 		/* Create the widget. */
53
-		parent::__construct( $this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops );
53
+		parent::__construct($this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops);
54 54
 	} // End __construct()
55 55
 
56 56
 	/**
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
 	 * @param  array $instance Widget settings for this instance.
61 61
 	 * @return void
62 62
 	 */
63
-	public function widget( $args, $instance ) {
63
+	public function widget($args, $instance) {
64 64
 
65
-		remove_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 );
65
+		remove_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1);
66 66
 
67 67
 		//don't show active or completed course if a user is not logged in
68
-		if ( ! in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) )
69
-		     || ( ! is_user_logged_in() && ( 'activecourses' == $instance['component'] || 'completedcourses' == $instance['component'] ) )  ) {
68
+		if ( ! in_array($instance['component'], array_keys($this->woo_widget_componentslist))
69
+		     || ( ! is_user_logged_in() && ('activecourses' == $instance['component'] || 'completedcourses' == $instance['component']))) {
70 70
 			// No Output
71 71
             return;
72 72
 
@@ -75,30 +75,30 @@  discard block
 block discarded – undo
75 75
 		$this->instance = $instance;
76 76
 
77 77
 		/* Our variables from the widget settings. */
78
-		$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base );
78
+		$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
79 79
 
80 80
 		/* Before widget (defined by themes). */
81 81
 		echo $args['before_widget'];
82 82
 
83 83
 		/* Display the widget title if one was input (before and after defined by themes). */
84
-		if ( $title ) { echo $args['before_title'] . $title . $args['after_title']; }
84
+		if ($title) { echo $args['before_title'].$title.$args['after_title']; }
85 85
 
86 86
 		/* Widget content. */
87 87
 		// Add actions for plugins/themes to hook onto.
88
-		do_action( $this->woo_widget_cssclass . '_top' );
88
+		do_action($this->woo_widget_cssclass.'_top');
89 89
 
90
-		if ( in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) ) ) {
91
-			$this->load_component( $instance );
90
+		if (in_array($instance['component'], array_keys($this->woo_widget_componentslist))) {
91
+			$this->load_component($instance);
92 92
 		}
93 93
 
94 94
 		// Add actions for plugins/themes to hook onto.
95
-		do_action( $this->woo_widget_cssclass . '_bottom' );
95
+		do_action($this->woo_widget_cssclass.'_bottom');
96 96
 
97 97
 		/* After widget (defined by themes). */
98 98
 		echo $args['after_widget'];
99 99
 
100 100
 
101
-		add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 );
101
+		add_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1);
102 102
 
103 103
 	} // End widget()
104 104
 
@@ -109,17 +109,17 @@  discard block
 block discarded – undo
109 109
 	 * @param  array $old_instance Previous settings.
110 110
 	 * @return array               Updated settings.
111 111
 	 */
112
-	public function update ( $new_instance, $old_instance ) {
112
+	public function update($new_instance, $old_instance) {
113 113
 		$instance = $old_instance;
114 114
 
115 115
 		/* Strip tags for title and name to remove HTML (important for text inputs). */
116
-		$instance['title'] = strip_tags( $new_instance['title'] );
116
+		$instance['title'] = strip_tags($new_instance['title']);
117 117
 
118 118
 		/* The select box is returning a text value, so we escape it. */
119
-		$instance['component'] = esc_attr( $new_instance['component'] );
119
+		$instance['component'] = esc_attr($new_instance['component']);
120 120
 
121 121
 		/* The select box is returning a text value, so we escape it. */
122
-		$instance['limit'] = esc_attr( $new_instance['limit'] );
122
+		$instance['limit'] = esc_attr($new_instance['limit']);
123 123
 
124 124
 
125 125
 		return $instance;
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 	 * @param  array $instance The settings for this instance.
133 133
 	 * @return void
134 134
 	 */
135
-    public function form( $instance ) {
135
+    public function form($instance) {
136 136
 
137 137
 		/* Set up some default widget settings. */
138 138
 		/* Make sure all keys are added here, even with empty string values. */
@@ -142,26 +142,26 @@  discard block
 block discarded – undo
142 142
 						'limit' => 3
143 143
 					);
144 144
 
145
-		$instance = wp_parse_args( (array) $instance, $defaults );
145
+		$instance = wp_parse_args((array) $instance, $defaults);
146 146
 ?>
147 147
 		<!-- Widget Title: Text Input -->
148 148
 		<p>
149
-			<label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title (optional):', 'woothemes-sensei' ); ?></label>
150
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>"  value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" />
149
+			<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title (optional):', 'woothemes-sensei'); ?></label>
150
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('title')); ?>"  value="<?php echo esc_attr($instance['title']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" />
151 151
 		</p>
152 152
 		<!-- Widget Component: Select Input -->
153 153
 		<p>
154
-			<label for="<?php echo esc_attr( $this->get_field_id( 'component' ) ); ?>"><?php _e( 'Component:', 'woothemes-sensei' ); ?></label>
155
-			<select name="<?php echo esc_attr( $this->get_field_name( 'component' ) ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'component' ) ); ?>">
156
-			<?php foreach ( $this->woo_widget_componentslist as $k => $v ) { ?>
157
-				<option value="<?php echo esc_attr( $k ); ?>"<?php selected( $instance['component'], $k ); ?>><?php echo $v; ?></option>
154
+			<label for="<?php echo esc_attr($this->get_field_id('component')); ?>"><?php _e('Component:', 'woothemes-sensei'); ?></label>
155
+			<select name="<?php echo esc_attr($this->get_field_name('component')); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('component')); ?>">
156
+			<?php foreach ($this->woo_widget_componentslist as $k => $v) { ?>
157
+				<option value="<?php echo esc_attr($k); ?>"<?php selected($instance['component'], $k); ?>><?php echo $v; ?></option>
158 158
 			<?php } ?>
159 159
 			</select>
160 160
 		</p>
161 161
 		<!-- Widget Limit: Text Input -->
162 162
 		<p>
163
-			<label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of Courses (optional):', 'woothemes-sensei' ); ?></label>
164
-			<input type="text" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>"  value="<?php echo esc_attr( $instance['limit'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" />
163
+			<label for="<?php echo esc_attr($this->get_field_id('limit')); ?>"><?php _e('Number of Courses (optional):', 'woothemes-sensei'); ?></label>
164
+			<input type="text" name="<?php echo esc_attr($this->get_field_name('limit')); ?>"  value="<?php echo esc_attr($instance['limit']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('limit')); ?>" />
165 165
 		</p>
166 166
 
167 167
 <?php
@@ -175,36 +175,36 @@  discard block
 block discarded – undo
175 175
 	 * @since  1.0.0
176 176
 	 * @return void
177 177
 	 */
178
-	protected function load_component ( $instance ) {
178
+	protected function load_component($instance) {
179 179
 
180 180
 		$courses = array();
181 181
 
182
-		if ( 'usercourses' == esc_attr( $instance['component'] ) ) {
182
+		if ('usercourses' == esc_attr($instance['component'])) {
183 183
 			// usercourses == new courses
184
-			$courses =  $this->get_new_courses( );
184
+			$courses = $this->get_new_courses( );
185 185
 
186
-		} elseif ( 'activecourses' == esc_attr( $instance['component'] ) ) {
186
+		} elseif ('activecourses' == esc_attr($instance['component'])) {
187 187
 
188
-			$courses =  $this->get_active_courses( );
188
+			$courses = $this->get_active_courses( );
189 189
 
190 190
 
191
-		} elseif ( 'completedcourses' == esc_attr( $instance['component'] ) ) {
191
+		} elseif ('completedcourses' == esc_attr($instance['component'])) {
192 192
 
193
-			$courses =  $this->get_completed_courses();
193
+			$courses = $this->get_completed_courses();
194 194
 
195
-		} elseif ( 'featuredcourses' == esc_attr( $instance['component'] ) ) {
195
+		} elseif ('featuredcourses' == esc_attr($instance['component'])) {
196 196
 
197
-			$courses =  $this->get_featured_courses();
197
+			$courses = $this->get_featured_courses();
198 198
 
199
-		} elseif ( 'paidcourses' == esc_attr( $instance['component'] ) ) {
199
+		} elseif ('paidcourses' == esc_attr($instance['component'])) {
200 200
 
201
-			$args = array( 'posts_per_page' => $this->instance['limit'] );
202
-			$courses =  Sensei_WC::get_paid_courses( $args );
201
+			$args = array('posts_per_page' => $this->instance['limit']);
202
+			$courses = Sensei_WC::get_paid_courses($args);
203 203
 
204
-		} elseif ( 'freecourses' == esc_attr( $instance['component'] ) ) {
204
+		} elseif ('freecourses' == esc_attr($instance['component'])) {
205 205
 
206
-			$args = array( 'posts_per_page' => $this->instance['limit'] );
207
-			$courses =  Sensei_WC::get_free_courses( $args );
206
+			$args = array('posts_per_page' => $this->instance['limit']);
207
+			$courses = Sensei_WC::get_free_courses($args);
208 208
 
209 209
 		} else {
210 210
 
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
 		}
214 214
 
215 215
 		// course_query() is buggy, it doesn't honour the 1st arg if includes are provided, so instead slice the includes
216
-		if ( !empty($instance['limit']) && intval( $instance['limit'] ) >= 1 && intval( $instance['limit'] ) < count($courses) ) {
216
+		if ( ! empty($instance['limit']) && intval($instance['limit']) >= 1 && intval($instance['limit']) < count($courses)) {
217 217
 
218
-			$courses = array_slice( $courses, 0, intval( $instance['limit'] ) );
218
+			$courses = array_slice($courses, 0, intval($instance['limit']));
219 219
 
220 220
 		}
221 221
 
222
-		if ( empty( $courses ) && $instance['limit'] != 0 ) {
222
+		if (empty($courses) && $instance['limit'] != 0) {
223 223
 
224 224
 			$this->display_no_courses_message();
225 225
 			return;
226 226
 
227 227
 		}
228 228
 
229
-		$this->display_courses( $courses );
229
+		$this->display_courses($courses);
230 230
 
231 231
 	} // End load_component()
232 232
 
@@ -237,23 +237,23 @@  discard block
 block discarded – undo
237 237
 	 *
238 238
 	 * @since 1.9.2
239 239
 	 */
240
-	public function display_no_courses_message ( ) {
240
+	public function display_no_courses_message( ) {
241 241
 
242
-		if ( 'featuredcourses' == $this->instance['component'] ) {
242
+		if ('featuredcourses' == $this->instance['component']) {
243 243
 
244
-			_e( 'You have no featured courses.', 'woothemes-sensei' );
244
+			_e('You have no featured courses.', 'woothemes-sensei');
245 245
 
246
-		} elseif ( 'activecourses' == $this->instance['component'] ) {
246
+		} elseif ('activecourses' == $this->instance['component']) {
247 247
 
248
-			_e( 'You have no active courses.', 'woothemes-sensei' );
248
+			_e('You have no active courses.', 'woothemes-sensei');
249 249
 
250
-		} elseif ( 'completedcourses' == $this->instance['component'] ) {
250
+		} elseif ('completedcourses' == $this->instance['component']) {
251 251
 
252
-			_e( 'You have no completed courses.', 'woothemes-sensei' );
252
+			_e('You have no completed courses.', 'woothemes-sensei');
253 253
 
254
-		}else{
254
+		} else {
255 255
 
256
-			_e( 'You have no courses.', 'woothemes-sensei' );
256
+			_e('You have no courses.', 'woothemes-sensei');
257 257
 
258 258
 		}
259 259
 	}
@@ -264,58 +264,58 @@  discard block
 block discarded – undo
264 264
 	 * @since 1.9.2
265 265
 	 * @param array $courses
266 266
 	 */
267
-	public function display_courses( $courses = array() ){ ?>
267
+	public function display_courses($courses = array()) { ?>
268 268
 		<ul>
269 269
 			<?php
270 270
 
271 271
 			foreach ($courses as $course) {
272 272
 
273
-				$post_id = absint( $course->ID );
273
+				$post_id = absint($course->ID);
274 274
 				$post_title = $course->post_title;
275
-				$user_info = get_userdata( absint( $course->post_author ) );
276
-				$author_link = get_author_posts_url( absint( $course->post_author ) );
275
+				$user_info = get_userdata(absint($course->post_author));
276
+				$author_link = get_author_posts_url(absint($course->post_author));
277 277
 				$author_display_name = $user_info->display_name;
278 278
 				$author_id = $course->post_author;
279 279
 				?>
280 280
 
281 281
 				<li class="fix">
282 282
 
283
-					<?php do_action( 'sensei_course_image', $post_id ); ?>
283
+					<?php do_action('sensei_course_image', $post_id); ?>
284 284
 
285
-					<a href="<?php echo esc_url( get_permalink( $post_id ) ); ?>"
286
-					   title="<?php echo esc_attr( $post_title ); ?>">
285
+					<a href="<?php echo esc_url(get_permalink($post_id)); ?>"
286
+					   title="<?php echo esc_attr($post_title); ?>">
287 287
 
288 288
 						<?php echo $post_title; ?>
289 289
 
290 290
 					</a>
291 291
 					<br />
292 292
 
293
-					<?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?>
293
+					<?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?>
294 294
 						<span class="course-author">
295
-							<?php _e( 'by ', 'woothemes-sensei' ); ?>
296
-							<a href="<?php echo esc_url( $author_link ); ?>" title="<?php echo esc_attr( $author_display_name ); ?>">
297
-								<?php echo esc_html( $author_display_name ); ?>
295
+							<?php _e('by ', 'woothemes-sensei'); ?>
296
+							<a href="<?php echo esc_url($author_link); ?>" title="<?php echo esc_attr($author_display_name); ?>">
297
+								<?php echo esc_html($author_display_name); ?>
298 298
 							</a>
299 299
 						</span>
300 300
 						<br />
301 301
 					<?php } // End If Statement ?>
302 302
 
303 303
 					<span class="course-lesson-count">
304
-						<?php echo Sensei()->course->course_lesson_count( $post_id ) . '&nbsp;' . __( 'Lessons', 'woothemes-sensei' ); ?>
304
+						<?php echo Sensei()->course->course_lesson_count($post_id).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?>
305 305
 					</span>
306 306
 
307 307
 					<br />
308 308
 
309
-					<?php sensei_simple_course_price( $post_id ); ?>
309
+					<?php sensei_simple_course_price($post_id); ?>
310 310
 
311 311
 				</li>
312 312
 
313 313
 			<?php
314 314
 			} // End For Loop
315 315
 
316
-			if ( 'activecourses' == esc_attr( $this->instance['component'] ) || 'completedcourses' == esc_attr( $this->instance['component'] ) ) {
317
-				$my_account_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] );
318
-				echo '<li class="my-account fix"><a href="'. esc_url( get_permalink( $my_account_page_id ) ) .'">'
316
+			if ('activecourses' == esc_attr($this->instance['component']) || 'completedcourses' == esc_attr($this->instance['component'])) {
317
+				$my_account_page_id = intval(Sensei()->settings->settings['my_course_page']);
318
+				echo '<li class="my-account fix"><a href="'.esc_url(get_permalink($my_account_page_id)).'">'
319 319
 				     .__('My Courses', 'woothemes-sensei')
320 320
 				     .'<span class="meta-nav"></span></a></li>';
321 321
 			} // End If Statement
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 *
331 331
 	 * @return array
332 332
 	 */
333
-	public function get_default_query_args(){
333
+	public function get_default_query_args() {
334 334
 
335 335
 		return array(
336 336
 				'post_type' => 'course',
@@ -349,9 +349,9 @@  discard block
 block discarded – undo
349 349
 	 *
350 350
 	 * @return array $courses
351 351
 	 */
352
-	public function get_new_courses ( ) {
352
+	public function get_new_courses( ) {
353 353
 
354
-		return get_posts( $this->get_default_query_args( ) );
354
+		return get_posts($this->get_default_query_args( ));
355 355
 
356 356
 	}
357 357
 
@@ -361,14 +361,14 @@  discard block
 block discarded – undo
361 361
 	 *
362 362
 	 * @return array $courses
363 363
 	 */
364
-	public function get_active_courses ( ) {
364
+	public function get_active_courses( ) {
365 365
 
366 366
 		$courses = array();
367
-		$activity_args = array( 'user_id' => get_current_user_id(), 'type' => 'sensei_course_status', 'status' => 'in-progress' );
368
-		$user_courses_activity = (array) Sensei_Utils::sensei_check_for_activity( $activity_args, true );
367
+		$activity_args = array('user_id' => get_current_user_id(), 'type' => 'sensei_course_status', 'status' => 'in-progress');
368
+		$user_courses_activity = (array) Sensei_Utils::sensei_check_for_activity($activity_args, true);
369 369
 
370
-		foreach( $user_courses_activity AS $activity ) {
371
-			$courses[] = get_post( $activity->comment_post_ID );
370
+		foreach ($user_courses_activity AS $activity) {
371
+			$courses[] = get_post($activity->comment_post_ID);
372 372
 		}
373 373
 
374 374
 		return $courses;
@@ -381,14 +381,14 @@  discard block
 block discarded – undo
381 381
 	 *
382 382
 	 * @return array $courses
383 383
 	 */
384
-	public function get_completed_courses ( ) {
384
+	public function get_completed_courses( ) {
385 385
 
386 386
 		$courses = array();
387
-		$activity_args = array( 'user_id' => get_current_user_id(), 'type' => 'sensei_course_status', 'status' => 'complete' );
388
-		$user_courses_activity = (array) Sensei_Utils::sensei_check_for_activity( $activity_args , true );
387
+		$activity_args = array('user_id' => get_current_user_id(), 'type' => 'sensei_course_status', 'status' => 'complete');
388
+		$user_courses_activity = (array) Sensei_Utils::sensei_check_for_activity($activity_args, true);
389 389
 
390
-		foreach( $user_courses_activity AS $activity ) {
391
-			$courses[] = get_post( $activity->comment_post_ID );
390
+		foreach ($user_courses_activity AS $activity) {
391
+			$courses[] = get_post($activity->comment_post_ID);
392 392
 		}
393 393
 		return $courses;
394 394
 	}
@@ -399,14 +399,14 @@  discard block
 block discarded – undo
399 399
 	 *
400 400
 	 * @return array $courses
401 401
 	 */
402
-	public function get_featured_courses ( ) {
402
+	public function get_featured_courses( ) {
403 403
 
404 404
 		$query_args = $this->get_default_query_args();
405
-		$query_args[ 'meta_key' ] = '_course_featured';
406
-		$query_args[ 'meta_value' ] = 'featured';
407
-		$query_args[ 'meta_compare' ] = '=';
405
+		$query_args['meta_key'] = '_course_featured';
406
+		$query_args['meta_value'] = 'featured';
407
+		$query_args['meta_compare'] = '=';
408 408
 
409
-		return get_posts( $query_args );
409
+		return get_posts($query_args);
410 410
 
411 411
 	}
412 412
 } // End Class
413 413
\ No newline at end of file
Please login to merge, or discard this patch.
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly.
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly.
3 6
 
4 7
 /**
5 8
  * Sensei Course Component Widget
@@ -251,7 +254,7 @@  discard block
 block discarded – undo
251 254
 
252 255
 			_e( 'You have no completed courses.', 'woothemes-sensei' );
253 256
 
254
-		}else{
257
+		} else{
255 258
 
256 259
 			_e( 'You have no courses.', 'woothemes-sensei' );
257 260
 
Please login to merge, or discard this patch.
includes/class-sensei-lesson.php 3 patches
Indentation   +1070 added lines, -1070 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
3132 3057
 
3133
-                // update pass percentage
3134
-                if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
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 ){
3135 3070
 
3136
-                        update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
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>';
3137 3078
 
3138
-                }
3079
+		return $html ;
3139 3080
 
3140
-                //
3141
-                // update enable quiz reset
3142
-                //
3143
-                if (-1 != $new_enable_quiz_reset ) {
3081
+	}//end generate_all_lessons_edit_field
3144 3082
 
3145
-                    $checked = $new_enable_quiz_reset ? 'on' : ''  ;
3146
-                    update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3147
-                    unset( $checked );
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() {
3148 3091
 
3149
-                }
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
+		}
3150 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 ) {
3151 3106
 
3152
-            } // end if quiz
3107
+			// get the quiz id needed for the quiz meta
3108
+			$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3153 3109
 
3154
-        }// end for each
3110
+			// do not save the items if the value is -1 as this
3111
+			// means it was not changed
3155 3112
 
3156
-        die();
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
+			}
3157 3121
 
3158
-    } // end save_all_lessons_edit_fields
3122
+			// Quiz Related settings
3123
+			if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3159 3124
 
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 ){
3125
+				// update pass required
3126
+				if (-1 != $new_pass_required) {
3172 3127
 
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 );
3128
+					$checked = $new_pass_required  ? 'on' : '';
3129
+					update_post_meta($quiz_id, '_pass_required', $checked);
3130
+					unset( $checked );
3131
+				}
3179 3132
 
3180
-        // setup the values for all meta fields
3181
-        $data = array();
3182
-        foreach( $this->meta_fields as $field ){
3133
+				// update pass percentage
3134
+				if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3183 3135
 
3184
-            $data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3136
+						update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3185 3137
 
3186
-        }
3187
-        // add quiz meta fields
3188
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3189
-        foreach( Sensei()->quiz->meta_fields as $field ){
3138
+				}
3190 3139
 
3191
-            $data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3140
+				//
3141
+				// update enable quiz reset
3142
+				//
3143
+				if (-1 != $new_enable_quiz_reset ) {
3192 3144
 
3193
-        }
3145
+					$checked = $new_enable_quiz_reset ? 'on' : ''  ;
3146
+					update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3147
+					unset( $checked );
3194 3148
 
3195
-        wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
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
+
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
+
3180
+		// setup the values for all meta fields
3181
+		$data = array();
3182
+		foreach( $this->meta_fields as $field ){
3196 3183
 
3197
-    }// end quick edit admin defaults
3184
+			$data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3198 3185
 
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 ){
3186
+		}
3187
+		// add quiz meta fields
3188
+		$quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3189
+		foreach( Sensei()->quiz->meta_fields as $field ){
3209 3190
 
3210
-        if(  is_singular('course') ){
3191
+			$data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3211 3192
 
3212
-            global $post;
3213
-            $course_id = $post->ID;
3193
+		}
3214 3194
 
3215
-            $lesson_classes = array( 'course', 'post' );
3216
-            if ( is_user_logged_in() ) {
3195
+		wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3217 3196
 
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 ) {
3197
+	}// end quick edit admin defaults
3221 3198
 
3222
-                    $lesson_classes[] = 'lesson-completed';
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 ){
3223 3209
 
3224
-                } // End If Statement
3210
+		if(  is_singular('course') ){
3225 3211
 
3226
-            } // End If Statement
3212
+			global $post;
3213
+			$course_id = $post->ID;
3227 3214
 
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 ) {
3215
+			$lesson_classes = array( 'course', 'post' );
3216
+			if ( is_user_logged_in() ) {
3230 3217
 
3231
-                $lesson_classes[] = 'lesson-preview';
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 ) {
3232 3221
 
3233
-            }
3222
+					$lesson_classes[] = 'lesson-completed';
3234 3223
 
3235
-            $classes = array_merge( $classes, $lesson_classes  );
3224
+				} // End If Statement
3236 3225
 
3237
-        }
3226
+			} // End If Statement
3238 3227
 
3239
-        return $classes;
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 ) {
3240 3230
 
3241
-    }// end single_course_lessons_classes
3231
+				$lesson_classes[] = 'lesson-preview';
3242 3232
 
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 ){
3233
+			}
3234
+
3235
+			$classes = array_merge( $classes, $lesson_classes  );
3236
+
3237
+		}
3238
+
3239
+		return $classes;
3240
+
3241
+	}// end single_course_lessons_classes
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 ){
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,192 +3344,192 @@  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 ) {
3471
+		if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3472 3472
 
3473 3473
 
3474
-        }// end if
3474
+		}// end if
3475 3475
 
3476
-    } // end user_not_taking_course_message
3476
+	} // end user_not_taking_course_message
3477 3477
 
3478
-    /**
3479
-     * Outputs the lessons course signup lingk
3480
-     *
3481
-     * This hook runs inside the single lesson page.
3482
-     *
3483
-     * @since 1.9.0
3484
-     */
3485
-    public static function course_signup_link( ){
3478
+	/**
3479
+	 * Outputs the lessons course signup lingk
3480
+	 *
3481
+	 * This hook runs inside the single lesson page.
3482
+	 *
3483
+	 * @since 1.9.0
3484
+	 */
3485
+	public static function course_signup_link( ){
3486 3486
 
3487
-        $course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3487
+		$course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3488 3488
 
3489
-        if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3489
+		if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3490 3490
 
3491
-            return;
3491
+			return;
3492 3492
 
3493
-        }
3493
+		}
3494 3494
 
3495
-        ?>
3495
+		?>
3496 3496
 
3497 3497
         <section class="course-signup lesson-meta">
3498 3498
 
3499 3499
             <?php
3500 3500
 
3501
-            global $current_user;
3502
-            $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3501
+			global $current_user;
3502
+			$wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3503 3503
 
3504
-            if ( Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable( $course_id ) ) {
3504
+			if ( Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable( $course_id ) ) {
3505 3505
 
3506
-                if( is_user_logged_in() && ! Sensei_Utils::user_started_course( $course_id, $current_user->ID )  ) {
3506
+				if( is_user_logged_in() && ! Sensei_Utils::user_started_course( $course_id, $current_user->ID )  ) {
3507 3507
 
3508
-	                    $a_element = '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Sign Up', 'woothemes-sensei' )  . '">';
3509
-	                    $a_element .= __( 'course', 'woothemes-sensei' );
3510
-	                    $a_element .= '</a>';
3508
+						$a_element = '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Sign Up', 'woothemes-sensei' )  . '">';
3509
+						$a_element .= __( 'course', 'woothemes-sensei' );
3510
+						$a_element .= '</a>';
3511 3511
 
3512
-	                    if( Sensei_Utils::is_preview_lesson( get_the_ID()  ) ){
3512
+						if( Sensei_Utils::is_preview_lesson( get_the_ID()  ) ){
3513 3513
 
3514
-		                    $message = sprintf( __( 'This is a preview lesson. Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3514
+							$message = sprintf( __( 'This is a preview lesson. Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3515 3515
 
3516
-	                    }else{
3516
+						}else{
3517 3517
 
3518
-		                    $message = sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3518
+							$message = sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3519 3519
 
3520
-	                    }
3520
+						}
3521 3521
 
3522
-	                    Sensei()->notices->add_notice( $message, 'info' );
3522
+						Sensei()->notices->add_notice( $message, 'info' );
3523 3523
 
3524
-                }
3524
+				}
3525 3525
 
3526
-	            if( ! is_user_logged_in() ) {
3526
+				if( ! is_user_logged_in() ) {
3527 3527
 
3528
-	                $a_element = '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Sign Up', 'woothemes-sensei' )  . '">';
3529
-	                $a_element .= __( 'course', 'woothemes-sensei' );
3530
-	                $a_element .= '</a>';
3528
+					$a_element = '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Sign Up', 'woothemes-sensei' )  . '">';
3529
+					$a_element .= __( 'course', 'woothemes-sensei' );
3530
+					$a_element .= '</a>';
3531 3531
 
3532
-	                if( Sensei_Utils::is_preview_lesson( get_the_ID()  ) ){
3532
+					if( Sensei_Utils::is_preview_lesson( get_the_ID()  ) ){
3533 3533
 
3534 3534
 						$message = sprintf( __( 'This is a preview lesson. Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3535 3535
 
@@ -3541,19 +3541,19 @@  discard block
 block discarded – undo
3541 3541
 
3542 3542
 					Sensei()->notices->add_notice( $message, 'alert' );
3543 3543
 
3544
-	            }
3544
+				}
3545 3545
 
3546
-            } else { ?>
3546
+			} else { ?>
3547 3547
 
3548 3548
 	            <?php if( ! Sensei_Utils::user_started_course( $course_id, get_current_user_id() ) &&  sensei_is_login_required() )  : ?>
3549 3549
 
3550 3550
 	                <div class="sensei-message alert">
3551 3551
 	                    <?php
3552
-	                    $course_link =  '<a href="'
3553
-	                                        . esc_url( get_permalink( $course_id ) )
3554
-	                                        . '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3555
-	                                        . '">' . __( 'course', 'woothemes-sensei' )
3556
-	                                    . '</a>';
3552
+						$course_link =  '<a href="'
3553
+											. esc_url( get_permalink( $course_id ) )
3554
+											. '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3555
+											. '">' . __( 'course', 'woothemes-sensei' )
3556
+										. '</a>';
3557 3557
 
3558 3558
 						if ( Sensei_Utils::is_preview_lesson( get_the_ID( ) ) ) {
3559 3559
 
@@ -3565,7 +3565,7 @@  discard block
 block discarded – undo
3565 3565
 
3566 3566
 						}
3567 3567
 
3568
-	                    ?>
3568
+						?>
3569 3569
 	                </div>
3570 3570
 
3571 3571
 	            <?php endif; ?>
@@ -3575,75 +3575,75 @@  discard block
 block discarded – undo
3575 3575
         </section>
3576 3576
 
3577 3577
         <?php
3578
-    }// end course_signup_link
3578
+	}// end course_signup_link
3579 3579
 
3580
-    /**
3581
-     * Show a message telling the user to complete the previous message if they haven't done so yet
3582
-     *
3583
-     * @since 1.9.0
3584
-     */
3585
-    public  static function prerequisite_complete_message(){
3580
+	/**
3581
+	 * Show a message telling the user to complete the previous message if they haven't done so yet
3582
+	 *
3583
+	 * @since 1.9.0
3584
+	 */
3585
+	public  static function prerequisite_complete_message(){
3586 3586
 
3587
-        $lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3588
-        $lesson_has_pre_requisite = $lesson_prerequisite > 0;
3589
-        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3587
+		$lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3588
+		$lesson_has_pre_requisite = $lesson_prerequisite > 0;
3589
+		if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3590 3590
 
3591
-            $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>';
3592
-            echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3591
+			$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>';
3592
+			echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3593 3593
 
3594
-        }
3594
+		}
3595 3595
 
3596
-    }
3596
+	}
3597 3597
 
3598
-    /**
3599
-     * Deprecate the sensei_lesson_archive_header hook but keep it
3600
-     * active for backwards compatibility.
3601
-     *
3602
-     * @deprecated since 1.9.0
3603
-     */
3604
-    public static function deprecate_sensei_lesson_archive_header_hook(){
3598
+	/**
3599
+	 * Deprecate the sensei_lesson_archive_header hook but keep it
3600
+	 * active for backwards compatibility.
3601
+	 *
3602
+	 * @deprecated since 1.9.0
3603
+	 */
3604
+	public static function deprecate_sensei_lesson_archive_header_hook(){
3605 3605
 
3606
-        sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3606
+		sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3607 3607
 
3608
-    }
3608
+	}
3609 3609
 
3610
-    /**
3611
-     * Outputs the the lesson archive header.
3612
-     *
3613
-     * @since  1.9.0
3614
-     * @return void
3615
-     */
3616
-    public function the_archive_header( ) {
3610
+	/**
3611
+	 * Outputs the the lesson archive header.
3612
+	 *
3613
+	 * @since  1.9.0
3614
+	 * @return void
3615
+	 */
3616
+	public function the_archive_header( ) {
3617 3617
 
3618
-        $before_html = '<header class="archive-header"><h1>';
3619
-        $after_html = '</h1></header>';
3620
-        $html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3618
+		$before_html = '<header class="archive-header"><h1>';
3619
+		$after_html = '</h1></header>';
3620
+		$html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3621 3621
 
3622
-        echo apply_filters( 'sensei_lesson_archive_title', $html );
3622
+		echo apply_filters( 'sensei_lesson_archive_title', $html );
3623 3623
 
3624
-    } // sensei_course_archive_header()
3624
+	} // sensei_course_archive_header()
3625 3625
 
3626
-    /**
3627
-     * Output the title for the single lesson page
3628
-     *
3629
-     * @global $post
3630
-     * @since 1.9.0
3631
-     */
3632
-    public static function the_title(){
3626
+	/**
3627
+	 * Output the title for the single lesson page
3628
+	 *
3629
+	 * @global $post
3630
+	 * @since 1.9.0
3631
+	 */
3632
+	public static function the_title(){
3633 3633
 
3634
-        global $post;
3634
+		global $post;
3635 3635
 
3636
-        ?>
3636
+		?>
3637 3637
         <header>
3638 3638
 
3639 3639
             <h1>
3640 3640
 
3641 3641
                 <?php
3642
-                /**
3643
-                 * Filter documented in class-sensei-messages.php the_title
3644
-                 */
3645
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3646
-                ?>
3642
+				/**
3643
+				 * Filter documented in class-sensei-messages.php the_title
3644
+				 */
3645
+				echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3646
+				?>
3647 3647
 
3648 3648
             </h1>
3649 3649
 
@@ -3651,75 +3651,75 @@  discard block
 block discarded – undo
3651 3651
 
3652 3652
         <?php
3653 3653
 
3654
-    }//the_title
3654
+	}//the_title
3655 3655
 
3656
-    /**
3657
-     * Flush the rewrite rules for a lesson post type
3658
-     *
3659
-     * @since 1.9.0
3660
-     *
3661
-     * @param $post_id
3662
-     */
3663
-    public static function flush_rewrite_rules( $post_id ){
3656
+	/**
3657
+	 * Flush the rewrite rules for a lesson post type
3658
+	 *
3659
+	 * @since 1.9.0
3660
+	 *
3661
+	 * @param $post_id
3662
+	 */
3663
+	public static function flush_rewrite_rules( $post_id ){
3664 3664
 
3665
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3665
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3666 3666
 
3667
-            return;
3667
+			return;
3668 3668
 
3669
-        }
3669
+		}
3670 3670
 
3671 3671
 
3672
-        if( 'lesson' == get_post_type( $post_id )  ){
3672
+		if( 'lesson' == get_post_type( $post_id )  ){
3673 3673
 
3674
-            Sensei()->initiate_rewrite_rules_flush();
3674
+			Sensei()->initiate_rewrite_rules_flush();
3675 3675
 
3676
-        }
3676
+		}
3677 3677
 
3678
-    }
3678
+	}
3679 3679
 
3680
-    /**
3681
-     * Output the quiz specific buttons and messaging on the single lesson page
3682
-     *
3683
-     *
3684
-     * @since 1.0.0 moved here from frontend class
3685
-     *
3686
-     * @param int $lesson_id
3687
-     * @param int $user_id
3688
-     */
3689
-    public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3680
+	/**
3681
+	 * Output the quiz specific buttons and messaging on the single lesson page
3682
+	 *
3683
+	 *
3684
+	 * @since 1.0.0 moved here from frontend class
3685
+	 *
3686
+	 * @param int $lesson_id
3687
+	 * @param int $user_id
3688
+	 */
3689
+	public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3690 3690
 
3691 3691
 
3692
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3693
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3692
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3693
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3694 3694
 
3695 3695
 
3696
-	    if ( ! sensei_can_user_view_lesson( $lesson_id, $user_id ) ) {
3697
-		    return;
3698
-	    }
3696
+		if ( ! sensei_can_user_view_lesson( $lesson_id, $user_id ) ) {
3697
+			return;
3698
+		}
3699 3699
 
3700
-        $lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3701
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3702
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3703
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3704
-        $show_actions              = is_user_logged_in() ? true : false;
3700
+		$lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3701
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3702
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3703
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3704
+		$show_actions              = is_user_logged_in() ? true : false;
3705 3705
 
3706
-        if( intval( $lesson_prerequisite ) > 0 ) {
3706
+		if( intval( $lesson_prerequisite ) > 0 ) {
3707 3707
 
3708
-            // If the user hasn't completed the prereq then hide the current actions
3709
-            $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3708
+			// If the user hasn't completed the prereq then hide the current actions
3709
+			$show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3710 3710
 
3711
-        }
3711
+		}
3712 3712
 
3713
-        ?>
3713
+		?>
3714 3714
 
3715 3715
         <footer>
3716 3716
 
3717 3717
             <?php
3718
-            if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3718
+			if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3719 3719
 
3720
-                $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3721
-                if( $has_quiz_questions ) {
3722
-                    ?>
3720
+				$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3721
+				if( $has_quiz_questions ) {
3722
+					?>
3723 3723
 
3724 3724
                     <p>
3725 3725
 
@@ -3734,123 +3734,123 @@  discard block
 block discarded – undo
3734 3734
                     </p>
3735 3735
 
3736 3736
                     <?php
3737
-                }
3737
+				}
3738 3738
 
3739
-            } // End If Statement
3739
+			} // End If Statement
3740 3740
 
3741
-            if ( $show_actions && ! $has_user_completed_lesson ) {
3741
+			if ( $show_actions && ! $has_user_completed_lesson ) {
3742 3742
 
3743
-                sensei_complete_lesson_button();
3743
+				sensei_complete_lesson_button();
3744 3744
 
3745
-            } elseif( $show_actions ) {
3745
+			} elseif( $show_actions ) {
3746 3746
 
3747
-                sensei_reset_lesson_button();
3747
+				sensei_reset_lesson_button();
3748 3748
 
3749
-            } // End If Statement
3750
-            ?>
3749
+			} // End If Statement
3750
+			?>
3751 3751
 
3752 3752
         </footer>
3753 3753
 
3754 3754
         <?php
3755
-    } // End sensei_lesson_quiz_meta()
3755
+	} // End sensei_lesson_quiz_meta()
3756 3756
 
3757
-    /**
3758
-     * Show the lesson comments. This should be used in the loop.
3759
-     *
3760
-     * @since 1.9.0
3761
-     */
3762
-    public static function output_comments(){
3757
+	/**
3758
+	 * Show the lesson comments. This should be used in the loop.
3759
+	 *
3760
+	 * @since 1.9.0
3761
+	 */
3762
+	public static function output_comments(){
3763 3763
 
3764
-        if( ! is_user_logged_in() ){
3765
-            return;
3766
-        }
3764
+		if( ! is_user_logged_in() ){
3765
+			return;
3766
+		}
3767 3767
 
3768
-        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3769
-        $course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3770
-        $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3771
-        $user_taking_course = Sensei_Utils::user_started_course($course_id );
3768
+		$pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3769
+		$course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3770
+		$allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3771
+		$user_taking_course = Sensei_Utils::user_started_course($course_id );
3772 3772
 
3773
-        $lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3773
+		$lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3774 3774
 
3775
-        if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3775
+		if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3776 3776
 
3777
-            comments_template();
3777
+			comments_template();
3778 3778
 
3779
-        } // End If Statement
3779
+		} // End If Statement
3780 3780
 
3781
-    } //output_comments
3781
+	} //output_comments
3782 3782
 
3783
-    /**
3784
-     * Display the leeson quiz status if it should be shown
3785
-     *
3786
-     * @param int $lesson_id defaults to the global lesson id
3787
-     * @param int $user_id defaults to the current user id
3788
-     *
3789
-     * @since 1.9.0
3790
-     */
3791
-    public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3783
+	/**
3784
+	 * Display the leeson quiz status if it should be shown
3785
+	 *
3786
+	 * @param int $lesson_id defaults to the global lesson id
3787
+	 * @param int $user_id defaults to the current user id
3788
+	 *
3789
+	 * @since 1.9.0
3790
+	 */
3791
+	public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3792 3792
 
3793
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3794
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3795
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3796
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3797
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3793
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3794
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3795
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3796
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3797
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3798 3798
 
3799 3799
 
3800
-        if ( $quiz_id && is_user_logged_in()
3801
-            && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3800
+		if ( $quiz_id && is_user_logged_in()
3801
+			&& Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3802 3802
 
3803
-            $no_quiz_count = 0;
3804
-            $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3803
+			$no_quiz_count = 0;
3804
+			$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3805 3805
 
3806
-            // Display lesson quiz status message
3807
-            if ( $has_user_completed_lesson || $has_quiz_questions ) {
3808
-                $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3809
-                echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3810
-                if( $has_quiz_questions ) {
3811
-                   // echo $status['extra'];
3812
-                } // End If Statement
3813
-            } // End If Statement
3806
+			// Display lesson quiz status message
3807
+			if ( $has_user_completed_lesson || $has_quiz_questions ) {
3808
+				$status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3809
+				echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3810
+				if( $has_quiz_questions ) {
3811
+				   // echo $status['extra'];
3812
+				} // End If Statement
3813
+			} // End If Statement
3814 3814
 
3815
-        }
3815
+		}
3816 3816
 
3817
-    }
3817
+	}
3818 3818
 
3819
-    /**
3820
-     * On the lesson archive limit the number of words the show up if the access settings are enabled
3821
-     *
3822
-     * @since 1.9.0
3823
-     * @param $content
3824
-     * @return string
3825
-     */
3826
-    public static function limit_archive_content ( $content ){
3819
+	/**
3820
+	 * On the lesson archive limit the number of words the show up if the access settings are enabled
3821
+	 *
3822
+	 * @since 1.9.0
3823
+	 * @param $content
3824
+	 * @return string
3825
+	 */
3826
+	public static function limit_archive_content ( $content ){
3827 3827
 
3828
-        if( is_archive('lesson') && Sensei()->settings->get('access_permission') ){
3828
+		if( is_archive('lesson') && Sensei()->settings->get('access_permission') ){
3829 3829
 
3830
-            return wp_trim_words( $content, $num_words = 30, $more = '…' );
3831
-        }
3830
+			return wp_trim_words( $content, $num_words = 30, $more = '…' );
3831
+		}
3832 3832
 
3833
-        return $content;
3833
+		return $content;
3834 3834
 
3835
-    } // end limit_archive_content
3835
+	} // end limit_archive_content
3836 3836
 
3837
-    /**
3838
-     * Returns all publised lesson ID's
3839
-     *
3840
-     * @since 1.9.0
3841
-     * @return array
3842
-     */
3843
-    public static function get_all_lesson_ids(){
3837
+	/**
3838
+	 * Returns all publised lesson ID's
3839
+	 *
3840
+	 * @since 1.9.0
3841
+	 * @return array
3842
+	 */
3843
+	public static function get_all_lesson_ids(){
3844 3844
 
3845
-        return get_posts( array(
3846
-            'post_type'=>'lesson',
3847
-            'fields'=>'ids',
3848
-            'post_status' => 'publish',
3849
-            'numberposts' => 4000, // legacy support
3850
-            'post_per_page' => 4000
3851
-        ));
3845
+		return get_posts( array(
3846
+			'post_type'=>'lesson',
3847
+			'fields'=>'ids',
3848
+			'post_status' => 'publish',
3849
+			'numberposts' => 4000, // legacy support
3850
+			'post_per_page' => 4000
3851
+		));
3852 3852
 
3853
-    }
3853
+	}
3854 3854
 
3855 3855
 } // End Class
3856 3856
 
Please login to merge, or discard this patch.
Braces   +30 added lines, -18 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
@@ -380,8 +383,7 @@  discard block
 block discarded – undo
380 383
 		$quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
381 384
 		if( 0 < count( $quiz_questions ) ) {
382 385
 			update_post_meta( $post_id, '_quiz_has_questions', '1' );
383
-		}
384
-		else {
386
+		} else {
385 387
 			delete_post_meta( $post_id, '_quiz_has_questions' );
386 388
 		}
387 389
 
@@ -392,7 +394,9 @@  discard block
 block discarded – undo
392 394
 
393 395
 	public function get_submitted_setting_value( $field = false ) {
394 396
 
395
-		if( ! $field ) return;
397
+		if( ! $field ) {
398
+			return;
399
+		}
396 400
 
397 401
 		$value = false;
398 402
 
@@ -1509,7 +1513,7 @@  discard block
 block discarded – undo
1509 1513
 
1510 1514
             $field_name = 'answer_feedback_boolean';
1511 1515
 
1512
-        }elseif( 'multiple-choice' == $question_type ){
1516
+        } elseif( 'multiple-choice' == $question_type ){
1513 1517
 
1514 1518
             $field_name = 'answer_feedback_multiple_choice';
1515 1519
 
@@ -1605,7 +1609,9 @@  discard block
 block discarded – undo
1605 1609
 
1606 1610
 		$html = '';
1607 1611
 
1608
-		if( ! $lesson_id && ! $quiz_id ) return $html;
1612
+		if( ! $lesson_id && ! $quiz_id ) {
1613
+			return $html;
1614
+		}
1609 1615
 
1610 1616
 		$settings = $this->get_quiz_settings( $quiz_id );
1611 1617
 
@@ -2281,11 +2287,11 @@  discard block
 block discarded – undo
2281 2287
 
2282 2288
             $answer_feedback = $data[ 'answer_feedback_boolean' ];
2283 2289
 
2284
-		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2290
+		} elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2285 2291
 
2286 2292
             $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2287 2293
 
2288
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2294
+        } elseif( isset( $data[ 'answer_feedback' ] )  ){
2289 2295
 
2290 2296
             $answer_feedback = $data[ 'answer_feedback' ];
2291 2297
 
@@ -2298,8 +2304,7 @@  discard block
 block discarded – undo
2298 2304
 		// Handle the extended question text
2299 2305
 		if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) {
2300 2306
 			$post_content = $data[ 'question_description' ];
2301
-		}
2302
-		else {
2307
+		} else {
2303 2308
 			$post_content = '';
2304 2309
 		}
2305 2310
 		// Question Query Arguments
@@ -2507,8 +2512,7 @@  discard block
 block discarded – undo
2507 2512
 				'key' => '_lesson_course',
2508 2513
 				'value' => $course_id,
2509 2514
 			);
2510
-		}
2511
-		else {
2515
+		} else {
2512 2516
 			// Simple check for connection to a Course
2513 2517
 			$post_args['meta_query'][] = array(
2514 2518
 				'key' => '_lesson_course',
@@ -2636,9 +2640,13 @@  discard block
 block discarded – undo
2636 2640
 				// Fetch each question in the order in which they were asked
2637 2641
 				$questions = array();
2638 2642
 				foreach( $selected_questions as $question_id ) {
2639
-					if( ! $question_id ) continue;
2643
+					if( ! $question_id ) {
2644
+						continue;
2645
+					}
2640 2646
 					$question = get_post( $question_id );
2641
-					if( ! isset( $question ) || ! isset( $question->ID ) ) continue;
2647
+					if( ! isset( $question ) || ! isset( $question->ID ) ) {
2648
+						continue;
2649
+					}
2642 2650
 					$questions[] = $question;
2643 2651
 				}
2644 2652
 
@@ -2651,7 +2659,9 @@  discard block
 block discarded – undo
2651 2659
 
2652 2660
 				// Set array of questions that already exist so we can prevent duplicates from appearing
2653 2661
 				foreach( $questions_array as $question ) {
2654
-					if( 'question' != $question->post_type ) continue;
2662
+					if( 'question' != $question->post_type ) {
2663
+						continue;
2664
+					}
2655 2665
 					$existing_questions[] = $question->ID;
2656 2666
 				}
2657 2667
 
@@ -2691,7 +2701,9 @@  discard block
 block discarded – undo
2691 2701
 
2692 2702
 						// Add selected questions to existing questions array to prevent duplicates from being added
2693 2703
 						foreach( $questions_array as $cat_question ) {
2694
-							if( in_array( $cat_question->ID, $existing_questions ) ) continue;
2704
+							if( in_array( $cat_question->ID, $existing_questions ) ) {
2705
+								continue;
2706
+							}
2695 2707
 							$existing_questions[] = $cat_question->ID;
2696 2708
 						}
2697 2709
 					}
@@ -3513,7 +3525,7 @@  discard block
 block discarded – undo
3513 3525
 
3514 3526
 		                    $message = sprintf( __( 'This is a preview lesson. Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3515 3527
 
3516
-	                    }else{
3528
+	                    } else{
3517 3529
 
3518 3530
 		                    $message = sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3519 3531
 
@@ -3533,7 +3545,7 @@  discard block
 block discarded – undo
3533 3545
 
3534 3546
 						$message = sprintf( __( 'This is a preview lesson. Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3535 3547
 
3536
-					}else{
3548
+					} else{
3537 3549
 
3538 3550
 						$message = sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3539 3551
 
Please login to merge, or discard this patch.
Spacing   +1105 added lines, -1105 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,40 +243,40 @@  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
 
259 259
 		// Check if the current post type is a page
260
-		if ( 'page' == $_POST[ 'post_type' ] ) {
260
+		if ('page' == $_POST['post_type']) {
261 261
 
262
-			if ( ! current_user_can( 'edit_page', $post_id ) ) {
262
+			if ( ! current_user_can('edit_page', $post_id)) {
263 263
 
264 264
 				return $post_id;
265 265
 
266 266
 			} // End If Statement
267 267
 		} else {
268
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
268
+			if ( ! current_user_can('edit_post', $post_id)) {
269 269
 				return $post_id;
270 270
 			} // End If Statement
271 271
 		} // End If Statement
272 272
 
273 273
 		// Save the post meta data fields
274
-		if ( isset($this->meta_fields) && is_array($this->meta_fields) ) {
274
+		if (isset($this->meta_fields) && is_array($this->meta_fields)) {
275 275
 
276
-			foreach ( $this->meta_fields as $meta_key ) {
276
+			foreach ($this->meta_fields as $meta_key) {
277 277
 
278
-				remove_action( 'save_post', array( $this, 'meta_box_save') );
279
-				$this->save_post_meta( $meta_key, $post_id );
278
+				remove_action('save_post', array($this, 'meta_box_save'));
279
+				$this->save_post_meta($meta_key, $post_id);
280 280
 
281 281
 			} // End For Loop
282 282
 		} // End If Statement
@@ -289,37 +289,37 @@  discard block
 block discarded – undo
289 289
 	 * @access public
290 290
 	 * @return integer|boolean $post_id or false
291 291
 	 */
292
-	public function quiz_update( $post_id ) {
292
+	public function quiz_update($post_id) {
293 293
 		global $post;
294 294
 		// Verify the nonce before proceeding.
295
-		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') ) {
296
-			if ( isset($post->ID) ) {
295
+		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')) {
296
+			if (isset($post->ID)) {
297 297
 				return $post->ID;
298 298
 			} else {
299 299
 				return false;
300 300
 			} // End If Statement
301 301
 		} // End If Statement
302 302
 
303
-		if( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
303
+		if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
304 304
 			return false;
305 305
 		}
306 306
 
307 307
 		// Temporarily disable the filter
308
-        remove_action( 'save_post', array( $this, 'quiz_update' ) );
308
+        remove_action('save_post', array($this, 'quiz_update'));
309 309
 		// Save the Quiz
310
-		$quiz_id = $this->lesson_quizzes( $post_id, 'any');
310
+		$quiz_id = $this->lesson_quizzes($post_id, 'any');
311 311
 
312 312
 		 // Sanitize and setup the post data
313
-		$_POST = stripslashes_deep( $_POST );
314
-		if ( isset( $_POST[ 'quiz_id' ] ) && ( 0 < absint( $_POST[ 'quiz_id' ] ) ) ) {
315
-			$quiz_id = absint( $_POST[ 'quiz_id' ] );
313
+		$_POST = stripslashes_deep($_POST);
314
+		if (isset($_POST['quiz_id']) && (0 < absint($_POST['quiz_id']))) {
315
+			$quiz_id = absint($_POST['quiz_id']);
316 316
 		} // End If Statement
317
-		$post_title = esc_html( $_POST[ 'post_title' ] );
318
-		$post_status = esc_html( $_POST[ 'post_status' ] );
317
+		$post_title = esc_html($_POST['post_title']);
318
+		$post_status = esc_html($_POST['post_status']);
319 319
 		$post_content = '';
320 320
 
321 321
 		// Setup Query Arguments
322
-		$post_type_args = array(	'post_content' => $post_content,
322
+		$post_type_args = array('post_content' => $post_content,
323 323
   		    						'post_status' => $post_status,
324 324
   		    						'post_title' => $post_title,
325 325
   		    						'post_type' => 'quiz',
@@ -329,84 +329,84 @@  discard block
 block discarded – undo
329 329
 		$settings = $this->get_quiz_settings();
330 330
 
331 331
   		// Update or Insert the Lesson Quiz
332
-		if ( 0 < $quiz_id ) {
332
+		if (0 < $quiz_id) {
333 333
 			// Update the Quiz
334
-			$post_type_args[ 'ID' ] = $quiz_id;
334
+			$post_type_args['ID'] = $quiz_id;
335 335
 		    wp_update_post($post_type_args);
336 336
 
337 337
 		    // Update the post meta data
338
-		    update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
338
+		    update_post_meta($quiz_id, '_quiz_lesson', $post_id);
339 339
 
340
-		    foreach( $settings as $field ) {
341
-		    	if( 'random_question_order' != $field['id'] ) {
342
-			    	$value = $this->get_submitted_setting_value( $field );
343
-			    	if( isset( $value ) ) {
344
-			    		update_post_meta( $quiz_id, '_' . $field['id'], $value );
340
+		    foreach ($settings as $field) {
341
+		    	if ('random_question_order' != $field['id']) {
342
+			    	$value = $this->get_submitted_setting_value($field);
343
+			    	if (isset($value)) {
344
+			    		update_post_meta($quiz_id, '_'.$field['id'], $value);
345 345
 			    	}
346 346
 			    }
347 347
 		    }
348 348
 
349 349
 		    // Set the post terms for quiz-type
350
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
350
+		    wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type');
351 351
 		} else {
352 352
 			// Create the Quiz
353 353
 		    $quiz_id = wp_insert_post($post_type_args);
354 354
 
355 355
 		    // Add the post meta data WP will add it if it doesn't exist
356
-            update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
356
+            update_post_meta($quiz_id, '_quiz_lesson', $post_id);
357 357
 
358
-		    foreach( $settings as $field ) {
359
-		    	if( 'random_question_order' != $field['id'] ) {
358
+		    foreach ($settings as $field) {
359
+		    	if ('random_question_order' != $field['id']) {
360 360
 
361 361
                     //ignore values not posted to avoid
362 362
                     // overwriting with empty or default values
363 363
                     // when the values are posted from bulk edit or quick edit
364
-                    if( !isset( $_POST[ $field['id'] ] ) ){
364
+                    if ( ! isset($_POST[$field['id']])) {
365 365
                         continue;
366 366
                     }
367 367
 
368
-			    	$value = $this->get_submitted_setting_value( $field );
369
-			    	if( isset( $value ) ) {
370
-			    		add_post_meta( $quiz_id, '_' . $field['id'], $value );
368
+			    	$value = $this->get_submitted_setting_value($field);
369
+			    	if (isset($value)) {
370
+			    		add_post_meta($quiz_id, '_'.$field['id'], $value);
371 371
 			    	}
372 372
 			    }
373 373
 		    }
374 374
 
375 375
 		    // Set the post terms for quiz-type
376
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
376
+		    wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type');
377 377
 		} // End If Statement
378 378
 
379 379
 		// Add default lesson order meta value
380
-		$course_id = get_post_meta( $post_id, '_lesson_course', true );
381
-		if( $course_id ) {
382
-			if( ! get_post_meta( $post_id, '_order_' . $course_id, true ) ) {
383
-				update_post_meta( $post_id, '_order_' . $course_id, 0 );
380
+		$course_id = get_post_meta($post_id, '_lesson_course', true);
381
+		if ($course_id) {
382
+			if ( ! get_post_meta($post_id, '_order_'.$course_id, true)) {
383
+				update_post_meta($post_id, '_order_'.$course_id, 0);
384 384
 			}
385 385
 		}
386 386
 		// Add reference back to the Quiz
387
-		update_post_meta( $post_id, '_lesson_quiz', $quiz_id );
387
+		update_post_meta($post_id, '_lesson_quiz', $quiz_id);
388 388
 		// Mark if the Lesson Quiz has questions
389
-		$quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
390
-		if( 0 < count( $quiz_questions ) ) {
391
-			update_post_meta( $post_id, '_quiz_has_questions', '1' );
389
+		$quiz_questions = Sensei()->lesson->lesson_quiz_questions($quiz_id);
390
+		if (0 < count($quiz_questions)) {
391
+			update_post_meta($post_id, '_quiz_has_questions', '1');
392 392
 		}
393 393
 		else {
394
-			delete_post_meta( $post_id, '_quiz_has_questions' );
394
+			delete_post_meta($post_id, '_quiz_has_questions');
395 395
 		}
396 396
 
397 397
 		// Restore the previously disabled filter
398
-        add_action( 'save_post', array( $this, 'quiz_update' ) );
398
+        add_action('save_post', array($this, 'quiz_update'));
399 399
 
400 400
 	} // End post_updated()
401 401
 
402
-	public function get_submitted_setting_value( $field = false ) {
402
+	public function get_submitted_setting_value($field = false) {
403 403
 
404
-		if( ! $field ) return;
404
+		if ( ! $field) return;
405 405
 
406 406
 		$value = false;
407 407
 
408
-		if( 'quiz_grade_type' == $field['id'] ) {
409
-			if( isset( $_POST[ $field['id'] ] ) && 'on' == $_POST[ $field['id'] ] ) {
408
+		if ('quiz_grade_type' == $field['id']) {
409
+			if (isset($_POST[$field['id']]) && 'on' == $_POST[$field['id']]) {
410 410
 				$value = 'auto';
411 411
 			} else {
412 412
 				$value = 'manual';
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 			return $value;
415 415
 		}
416 416
 
417
-		if ( isset( $_POST[ $field['id'] ] ) ) {
418
-			$value = $_POST[ $field['id'] ];
417
+		if (isset($_POST[$field['id']])) {
418
+			$value = $_POST[$field['id']];
419 419
 		} else {
420 420
 			$value = $field['default'];
421 421
 		}
@@ -431,18 +431,18 @@  discard block
 block discarded – undo
431 431
 	 * @param int $post_id (default: 0)
432 432
 	 * @return int|bool meta id or saved status
433 433
 	 */
434
-	private function save_post_meta( $post_key = '', $post_id = 0 ) {
434
+	private function save_post_meta($post_key = '', $post_id = 0) {
435 435
 		// Get the meta key.
436
-		$meta_key = '_' . $post_key;
436
+		$meta_key = '_'.$post_key;
437 437
 
438 438
         //ignore fields are not posted
439 439
 
440
-        if( !isset( $_POST[ $post_key ] ) ){
440
+        if ( ! isset($_POST[$post_key])) {
441 441
 
442 442
             // except for lesson preview checkbox field
443
-            if( 'lesson_preview' == $post_key ){
443
+            if ('lesson_preview' == $post_key) {
444 444
 
445
-                $_POST[ $post_key ] = '';
445
+                $_POST[$post_key] = '';
446 446
 
447 447
             } else {
448 448
 
@@ -453,15 +453,15 @@  discard block
 block discarded – undo
453 453
         }
454 454
 
455 455
 		// Get the posted data and sanitize it for use as an HTML class.
456
-		if ( 'lesson_video_embed' == $post_key) {
457
-			$new_meta_value = esc_html( $_POST[$post_key] );
456
+		if ('lesson_video_embed' == $post_key) {
457
+			$new_meta_value = esc_html($_POST[$post_key]);
458 458
 		} else {
459
-			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
459
+			$new_meta_value = (isset($_POST[$post_key]) ? sanitize_html_class($_POST[$post_key]) : '');
460 460
 		} // End If Statement
461 461
 
462 462
         // update field with the new value
463
-        if( -1 != $new_meta_value  ){
464
-            return update_post_meta( $post_id, $meta_key, $new_meta_value );
463
+        if ( -1 != $new_meta_value  ) {
464
+            return update_post_meta($post_id, $meta_key, $new_meta_value);
465 465
         }
466 466
 
467 467
 	} // End save_post_meta()
@@ -472,30 +472,30 @@  discard block
 block discarded – undo
472 472
 	 * @access public
473 473
 	 * @return void
474 474
 	 */
475
-	public function lesson_course_meta_box_content () {
475
+	public function lesson_course_meta_box_content() {
476 476
 		global $post;
477 477
 		// Setup Lesson Meta Data
478 478
 		$selected_lesson_course = 0;
479
-		if ( 0 < $post->ID ) {
480
-			$selected_lesson_course = get_post_meta( $post->ID, '_lesson_course', true );
479
+		if (0 < $post->ID) {
480
+			$selected_lesson_course = get_post_meta($post->ID, '_lesson_course', true);
481 481
 		} // End If Statement
482 482
 		// Handle preselected course
483
-		if ( isset( $_GET[ 'course_id' ] ) && ( 0 < absint( $_GET[ 'course_id' ] ) ) ) {
484
-			$selected_lesson_course = absint( $_GET[ 'course_id' ] );
483
+		if (isset($_GET['course_id']) && (0 < absint($_GET['course_id']))) {
484
+			$selected_lesson_course = absint($_GET['course_id']);
485 485
 		} // End If Statement
486 486
 		// Get the Lesson Posts
487
-		$post_args = array(	'post_type' 		=> 'course',
487
+		$post_args = array('post_type' 		=> 'course',
488 488
 							'posts_per_page' 		=> -1,
489 489
 							'orderby'         	=> 'title',
490 490
     						'order'           	=> 'ASC',
491 491
     						'post_status'      	=> 'any',
492 492
     						'suppress_filters' 	=> 0,
493 493
 							);
494
-		$posts_array = get_posts( $post_args );
494
+		$posts_array = get_posts($post_args);
495 495
 		// Buid the HTML to Output
496 496
 		$html = '';
497 497
 		// Nonce
498
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
498
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
499 499
 
500 500
         // Select the course for the lesson
501 501
         $drop_down_args = array(
@@ -505,67 +505,67 @@  discard block
 block discarded – undo
505 505
 
506 506
         $courses = WooThemes_Sensei_Course::get_all_courses();
507 507
         $courses_options = array();
508
-        foreach( $courses as $course ){
509
-            $courses_options[ $course->ID ] = get_the_title( $course ) ;
508
+        foreach ($courses as $course) {
509
+            $courses_options[$course->ID] = get_the_title($course);
510 510
         }
511
-        $html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args );
511
+        $html .= Sensei_Utils::generate_drop_down($selected_lesson_course, $courses_options, $drop_down_args);
512 512
 
513 513
         // Course Actions Panel
514
-		if ( current_user_can( 'publish_courses' )) {
514
+		if (current_user_can('publish_courses')) {
515 515
 				$html .= '<div id="lesson-course-actions">';
516 516
 					$html .= '<p>';
517 517
 						// Add a course action link
518
-						$html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ ' . __('Add New Course', 'woothemes-sensei' ) . '</a>';
518
+						$html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ '.__('Add New Course', 'woothemes-sensei').'</a>';
519 519
 					$html .= '</p>';
520 520
 				$html .= '</div>';
521 521
 				// Add a course input fields
522 522
 				$html .= '<div id="lesson-course-details" class="hidden">';
523 523
 					$html .= '<p>';
524 524
 						// Course Title input
525
-						$html .= '<label>' . __( 'Course Title' , 'woothemes-sensei' ) . '</label> ';
525
+						$html .= '<label>'.__('Course Title', 'woothemes-sensei').'</label> ';
526 526
 	  					$html .= '<input type="text" id="course-title" name="course_title" value="" size="25" class="widefat" />';
527 527
 	  					// Course Description input
528
-	  					$html .= '<label>' . __( 'Description' , 'woothemes-sensei' ) . '</label> ';
528
+	  					$html .= '<label>'.__('Description', 'woothemes-sensei').'</label> ';
529 529
 	  					$html .= '<textarea rows="10" cols="40" id="course-content" name="course_content" value="" size="300" class="widefat"></textarea>';
530 530
 	  					// Course Prerequisite
531
-	  					$html .= '<label>' . __( 'Course Prerequisite' , 'woothemes-sensei' ) . '</label> ';
532
-	  					$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n";
533
-							$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
534
-							foreach ($posts_array as $post_item){
535
-								$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '">' . esc_html( $post_item->post_title ) . '</option>' . "\n";
531
+	  					$html .= '<label>'.__('Course Prerequisite', 'woothemes-sensei').'</label> ';
532
+	  					$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">'."\n";
533
+							$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
534
+							foreach ($posts_array as $post_item) {
535
+								$html .= '<option value="'.esc_attr(absint($post_item->ID)).'">'.esc_html($post_item->post_title).'</option>'."\n";
536 536
 							} // End For Loop
537
-						$html .= '</select>' . "\n";
537
+						$html .= '</select>'."\n";
538 538
 						// Course Product
539
-                        if ( Sensei_WC::is_woocommerce_active() ) {
539
+                        if (Sensei_WC::is_woocommerce_active()) {
540 540
 	  						// Get the Products
541
-							$select_course_woocommerce_product = get_post_meta( $post_item->ID, '_course_woocommerce_product', true );
541
+							$select_course_woocommerce_product = get_post_meta($post_item->ID, '_course_woocommerce_product', true);
542 542
 
543
-							$product_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
543
+							$product_args = array('post_type' 		=> array('product', 'product_variation'),
544 544
 													'posts_per_page' 		=> -1,
545 545
 													'orderby'         	=> 'title',
546 546
 	    											'order'           	=> 'DESC',
547
-	    											'post_status'		=> array( 'publish', 'private', 'draft' ),
547
+	    											'post_status'		=> array('publish', 'private', 'draft'),
548 548
 	    											'tax_query'			=> array(
549 549
 														array(
550 550
 															'taxonomy'	=> 'product_type',
551 551
 															'field'		=> 'slug',
552
-															'terms'		=> array( 'variable', 'grouped' ),
552
+															'terms'		=> array('variable', 'grouped'),
553 553
 															'operator'	=> 'NOT IN'
554 554
 														)
555 555
 													),
556 556
 	    											'suppress_filters' 	=> 0
557 557
 													);
558
-							$products_array = get_posts( $product_args );
559
-							$html .= '<label>' . __( 'WooCommerce Product' , 'woothemes-sensei' ) . '</label> ';
560
-	  						$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n";
561
-								$html .= '<option value="-">' . __( 'None', 'woothemes-sensei' ) . '</option>';
558
+							$products_array = get_posts($product_args);
559
+							$html .= '<label>'.__('WooCommerce Product', 'woothemes-sensei').'</label> ';
560
+	  						$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">'."\n";
561
+								$html .= '<option value="-">'.__('None', 'woothemes-sensei').'</option>';
562 562
 								$prev_parent_id = 0;
563
-								foreach ($products_array as $products_item){
563
+								foreach ($products_array as $products_item) {
564 564
 
565
-									if ( 'product_variation' == $products_item->post_type ) {
566
-										$product_object = get_product( $products_item->ID );
567
-										$parent_id = wp_get_post_parent_id( $products_item->ID );
568
-										$product_name = ucwords( woocommerce_get_formatted_variation( $product_object->variation_data, true ) );
565
+									if ('product_variation' == $products_item->post_type) {
566
+										$product_object = get_product($products_item->ID);
567
+										$parent_id = wp_get_post_parent_id($products_item->ID);
568
+										$product_name = ucwords(woocommerce_get_formatted_variation($product_object->variation_data, true));
569 569
 									} else {
570 570
 										$parent_id = false;
571 571
 										$prev_parent_id = 0;
@@ -573,32 +573,32 @@  discard block
 block discarded – undo
573 573
 									}
574 574
 
575 575
 									// Show variations in groups
576
-									if( $parent_id && $parent_id != $prev_parent_id ) {
577
-										if( 0 != $prev_parent_id ) {
576
+									if ($parent_id && $parent_id != $prev_parent_id) {
577
+										if (0 != $prev_parent_id) {
578 578
 											$html .= '</optgroup>';
579 579
 										}
580
-										$html .= '<optgroup label="' . get_the_title( $parent_id ) . '">';
580
+										$html .= '<optgroup label="'.get_the_title($parent_id).'">';
581 581
 										$prev_parent_id = $parent_id;
582
-									} elseif( ! $parent_id && 0 == $prev_parent_id ) {
582
+									} elseif ( ! $parent_id && 0 == $prev_parent_id) {
583 583
 										$html .= '</optgroup>';
584 584
 									}
585 585
 
586
-									$html .= '<option value="' . esc_attr( absint( $products_item->ID ) ) . '">' . esc_html( $products_item->post_title ) . '</option>' . "\n";
586
+									$html .= '<option value="'.esc_attr(absint($products_item->ID)).'">'.esc_html($products_item->post_title).'</option>'."\n";
587 587
 								} // End For Loop
588
-							$html .= '</select>' . "\n";
588
+							$html .= '</select>'."\n";
589 589
 						} else {
590 590
 							// Default
591 591
 							$html .= '<input type="hidden" name="course_woocommerce_product" id="course-woocommerce-product-options" value="-" />';
592 592
 						}
593 593
 						// Course Category
594
-	  					$html .= '<label>' . __( 'Course Category' , 'woothemes-sensei' ) . '</label> ';
595
-	  					$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' );
596
-						$html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args)) . "\n";
594
+	  					$html .= '<label>'.__('Course Category', 'woothemes-sensei').'</label> ';
595
+	  					$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');
596
+						$html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args))."\n";
597 597
 	  					// Save the course action button
598
-	  					$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>';
598
+	  					$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>';
599 599
 						$html .= '&nbsp;&nbsp;&nbsp;';
600 600
 						// Cancel action link
601
-						$html .= '<a href="#course-add-cancel" class="lesson_course_cancel">' . __( 'Cancel', 'woothemes-sensei' ) . '</a>';
601
+						$html .= '<a href="#course-add-cancel" class="lesson_course_cancel">'.__('Cancel', 'woothemes-sensei').'</a>';
602 602
 					$html .= '</p>';
603 603
 				$html .= '</div>';
604 604
 			} // End If Statement
@@ -607,20 +607,20 @@  discard block
 block discarded – undo
607 607
 		echo $html;
608 608
 	} // End lesson_course_meta_box_content()
609 609
 
610
-	public function quiz_panel( $quiz_id = 0 ) {
610
+	public function quiz_panel($quiz_id = 0) {
611 611
 
612
-		$html = wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
612
+		$html = wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
613 613
 		$html .= '<div id="add-quiz-main">';
614
-			if ( 0 == $quiz_id ) {
614
+			if (0 == $quiz_id) {
615 615
 				$html .= '<p>';
616 616
 					// Default message and Add a Quiz button
617
-					$html .= esc_html( __( 'Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei' ) );
617
+					$html .= esc_html(__('Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei'));
618 618
 				$html .= '</p>';
619 619
 			}
620 620
 
621 621
 			// Quiz Panel CSS Class
622 622
 			$quiz_class = '';
623
-			if ( 0 == $quiz_id ) {
623
+			if (0 == $quiz_id) {
624 624
 				$quiz_class = ' class="hidden"';
625 625
 			} // End If Statement
626 626
 			// Build the HTML to Output
@@ -628,15 +628,15 @@  discard block
 block discarded – undo
628 628
 
629 629
 			// Setup Questions Query
630 630
 			$questions = array();
631
-			if ( 0 < $quiz_id ) {
632
-				$questions = $this->lesson_quiz_questions( $quiz_id );
631
+			if (0 < $quiz_id) {
632
+				$questions = $this->lesson_quiz_questions($quiz_id);
633 633
 			} // End If Statement
634 634
 
635 635
 			$question_count = 0;
636
-			foreach( $questions as $question ) {
636
+			foreach ($questions as $question) {
637 637
 
638
-				if( $question->post_type == 'multiple_question' ) {
639
-					$question_number = get_post_meta( $question->ID, 'number', true );
638
+				if ($question->post_type == 'multiple_question') {
639
+					$question_number = get_post_meta($question->ID, 'number', true);
640 640
 					$question_count += $question_number;
641 641
 				} else {
642 642
 					++$question_count;
@@ -645,68 +645,68 @@  discard block
 block discarded – undo
645 645
 			}
646 646
 
647 647
 			// Inner DIV
648
-			$html .= '<div id="add-quiz-metadata"' . $quiz_class . '>';
648
+			$html .= '<div id="add-quiz-metadata"'.$quiz_class.'>';
649 649
 
650 650
 				// Quiz ID
651
-				$html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="' . esc_attr( $quiz_id ) . '" />';
651
+				$html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="'.esc_attr($quiz_id).'" />';
652 652
 
653 653
 				// Default Message
654
-				if ( 0 == $quiz_id ) {
654
+				if (0 == $quiz_id) {
655 655
 					$html .= '<p class="save-note">';
656
-						$html .= esc_html( __( 'Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei' ) );
656
+						$html .= esc_html(__('Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei'));
657 657
 					$html .= '</p>';
658 658
 				} // End If Statement
659 659
 
660 660
 			$html .= '</div>';
661 661
 
662 662
 			// Question Container DIV
663
-			$html .= '<div id="add-question-main"' . $quiz_class . '>';
663
+			$html .= '<div id="add-question-main"'.$quiz_class.'>';
664 664
 				// Inner DIV
665 665
 				$html .= '<div id="add-question-metadata">';
666 666
 
667 667
 					// Count of questions
668
-					$html .= '<input type="hidden" name="question_counter" id="question_counter" value="' . esc_attr( $question_count ) . '" />';
668
+					$html .= '<input type="hidden" name="question_counter" id="question_counter" value="'.esc_attr($question_count).'" />';
669 669
 					// Table headers
670 670
 					$html .= '<table class="widefat" id="sortable-questions">
671 671
 								<thead>
672 672
 								    <tr>
673 673
 								        <th class="question-count-column">#</th>
674
-								        <th>' . __( 'Question', 'woothemes-sensei' ) . '</th>
675
-								        <th style="width:45px;">' . __( 'Grade', 'woothemes-sensei' ) . '</th>
676
-								        <th style="width:125px;">' . __( 'Type', 'woothemes-sensei' ) . '</th>
677
-								        <th style="width:125px;">' . __( 'Action', 'woothemes-sensei' ) . '</th>
674
+								        <th>' . __('Question', 'woothemes-sensei').'</th>
675
+								        <th style="width:45px;">' . __('Grade', 'woothemes-sensei').'</th>
676
+								        <th style="width:125px;">' . __('Type', 'woothemes-sensei').'</th>
677
+								        <th style="width:125px;">' . __('Action', 'woothemes-sensei').'</th>
678 678
 								    </tr>
679 679
 								</thead>
680 680
 								<tfoot>
681 681
 								    <tr>
682 682
 									    <th class="question-count-column">#</th>
683
-									    <th>' . __( 'Question', 'woothemes-sensei' ) . '</th>
684
-									    <th>' . __( 'Grade', 'woothemes-sensei' ) . '</th>
685
-									    <th>' . __( 'Type', 'woothemes-sensei' ) . '</th>
686
-									    <th>' . __( 'Action', 'woothemes-sensei' ) . '</th>
683
+									    <th>' . __('Question', 'woothemes-sensei').'</th>
684
+									    <th>' . __('Grade', 'woothemes-sensei').'</th>
685
+									    <th>' . __('Type', 'woothemes-sensei').'</th>
686
+									    <th>' . __('Action', 'woothemes-sensei').'</th>
687 687
 								    </tr>
688 688
 								</tfoot>';
689 689
 
690 690
 					$message_class = '';
691
-					if ( 0 < $question_count ) { $message_class = 'hidden'; }
691
+					if (0 < $question_count) { $message_class = 'hidden'; }
692 692
 
693
-					$html .= '<tbody id="no-questions-message" class="' . esc_attr( $message_class ) . '">';
693
+					$html .= '<tbody id="no-questions-message" class="'.esc_attr($message_class).'">';
694 694
 						$html .= '<tr>';
695
-							$html .= '<td colspan="5">' . __( 'There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei' ) . '</td>';
695
+							$html .= '<td colspan="5">'.__('There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei').'</td>';
696 696
 						$html .= '</tr>';
697 697
 					$html .= '</tbody>';
698 698
 
699
-					if( 0 < $question_count ) {
700
-						$html .= $this->quiz_panel_questions( $questions );
699
+					if (0 < $question_count) {
700
+						$html .= $this->quiz_panel_questions($questions);
701 701
 					}
702 702
 
703 703
 					$html .= '</table>';
704 704
 
705
-					if( ! isset( $this->question_order ) ) {
705
+					if ( ! isset($this->question_order)) {
706 706
 						$this->question_order = '';
707 707
 					}
708 708
 
709
-					$html .= '<input type="hidden" id="question-order" name="question-order" value="' . $this->question_order . '" />';
709
+					$html .= '<input type="hidden" id="question-order" name="question-order" value="'.$this->question_order.'" />';
710 710
 
711 711
 				$html .= '</div>';
712 712
 
@@ -725,47 +725,47 @@  discard block
 block discarded – undo
725 725
 
726 726
 	}
727 727
 
728
-	public function quiz_panel_questions( $questions = array() ) {
728
+	public function quiz_panel_questions($questions = array()) {
729 729
 		global $quiz_questions;
730 730
 
731 731
 		$quiz_questions = $questions;
732 732
 
733 733
 		$html = '';
734 734
 
735
-		if( count( $questions ) > 0 ) {
735
+		if (count($questions) > 0) {
736 736
 
737 737
 			$question_class = '';
738 738
 			$question_counter = 1;
739 739
 
740
-			foreach ( $questions as $question ) {
740
+			foreach ($questions as $question) {
741 741
 
742 742
 				$question_id = $question->ID;
743 743
 
744
-				$question_type = Sensei()->question->get_question_type( $question_id );
744
+				$question_type = Sensei()->question->get_question_type($question_id);
745 745
 
746 746
 				$multiple_data = array();
747 747
 				$question_increment = 1;
748
-				if( 'multiple_question' == $question->post_type ) {
748
+				if ('multiple_question' == $question->post_type) {
749 749
 					$question_type = 'category';
750 750
 
751
-					$question_category = get_post_meta( $question->ID, 'category', true );
752
-					$question_cat = get_term( $question_category, 'question-category' );
751
+					$question_category = get_post_meta($question->ID, 'category', true);
752
+					$question_cat = get_term($question_category, 'question-category');
753 753
 
754
-					$question_number = get_post_meta( $question->ID, 'number', true );
754
+					$question_number = get_post_meta($question->ID, 'number', true);
755 755
 					$question_increment = $question_number;
756 756
 
757
-					$multiple_data = array( $question_cat->name, $question_number );
757
+					$multiple_data = array($question_cat->name, $question_number);
758 758
 				}
759 759
 
760
-				if( ! $question_type ) {
760
+				if ( ! $question_type) {
761 761
 					$question_type = 'multiple-choice';
762 762
 				}
763 763
 
764 764
 				// Row with question and actions
765
-				$html .= $this->quiz_panel_question( $question_type, $question_counter, $question_id, 'quiz', $multiple_data );
765
+				$html .= $this->quiz_panel_question($question_type, $question_counter, $question_id, 'quiz', $multiple_data);
766 766
 				$question_counter += $question_increment;
767 767
 
768
-				if( isset( $this->question_order ) && strlen( $this->question_order ) > 0 ) { $this->question_order .= ','; }
768
+				if (isset($this->question_order) && strlen($this->question_order) > 0) { $this->question_order .= ','; }
769 769
 				$this->question_order .= $question_id;
770 770
 			} // End For Loop
771 771
 		}
@@ -774,161 +774,161 @@  discard block
 block discarded – undo
774 774
 
775 775
 	}
776 776
 
777
-	public function quiz_panel_question( $question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array() ) {
778
-		global $row_counter,  $quiz_questions;
777
+	public function quiz_panel_question($question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array()) {
778
+		global $row_counter, $quiz_questions;
779 779
 
780 780
 		$html = '';
781 781
 
782 782
 		$question_class = '';
783
-		if( 'quiz' == $context ) {
784
-			if( ! $row_counter || ! isset( $row_counter ) ) {
783
+		if ('quiz' == $context) {
784
+			if ( ! $row_counter || ! isset($row_counter)) {
785 785
 				$row_counter = 1;
786 786
 			}
787
-			if( $row_counter % 2 ) { $question_class = 'alternate'; }
787
+			if ($row_counter % 2) { $question_class = 'alternate'; }
788 788
 			++$row_counter;
789 789
 		}
790 790
 
791
-		if( $question_id ) {
791
+		if ($question_id) {
792 792
 
793
-			if( $question_type != 'category' ) {
793
+			if ($question_type != 'category') {
794 794
 
795
-				$question_grade = Sensei()->question->get_question_grade( $question_id );
795
+				$question_grade = Sensei()->question->get_question_grade($question_id);
796 796
 
797
-				$question_media = get_post_meta( $question_id, '_question_media', true );
797
+				$question_media = get_post_meta($question_id, '_question_media', true);
798 798
 				$question_media_type = $question_media_thumb = $question_media_link = $question_media_title = '';
799 799
 				$question_media_thumb_class = $question_media_link_class = $question_media_delete_class = 'hidden';
800
-				$question_media_add_button = __( 'Add file', 'woothemes-sensei' );
801
-				if( 0 < intval( $question_media ) ) {
802
-					$mimetype = get_post_mime_type( $question_media );
803
-					if( $mimetype ) {
804
-						$mimetype_array = explode( '/', $mimetype);
805
-						if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) {
800
+				$question_media_add_button = __('Add file', 'woothemes-sensei');
801
+				if (0 < intval($question_media)) {
802
+					$mimetype = get_post_mime_type($question_media);
803
+					if ($mimetype) {
804
+						$mimetype_array = explode('/', $mimetype);
805
+						if (isset($mimetype_array[0]) && $mimetype_array[0]) {
806 806
 							$question_media_delete_class = '';
807 807
 							$question_media_type = $mimetype_array[0];
808
-							if( 'image' == $question_media_type ) {
809
-								$question_media_thumb = wp_get_attachment_thumb_url( $question_media );
810
-								if( $question_media_thumb ) {
808
+							if ('image' == $question_media_type) {
809
+								$question_media_thumb = wp_get_attachment_thumb_url($question_media);
810
+								if ($question_media_thumb) {
811 811
 									$question_media_thumb_class = '';
812 812
 								}
813 813
 							}
814
-							$question_media_url = wp_get_attachment_url( $question_media );
815
-							if( $question_media_url ) {
816
-								$attachment = get_post( $question_media );
814
+							$question_media_url = wp_get_attachment_url($question_media);
815
+							if ($question_media_url) {
816
+								$attachment = get_post($question_media);
817 817
 								$question_media_title = $attachment->post_title;
818 818
 
819
-								if( ! $question_media_title ) {
820
-									$question_media_filename = basename( $question_media_url );
819
+								if ( ! $question_media_title) {
820
+									$question_media_filename = basename($question_media_url);
821 821
 									$question_media_title = $question_media_filename;
822 822
 								}
823
-								$question_media_link = '<a class="' . $question_media_type . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_title . '</a>';
823
+								$question_media_link = '<a class="'.$question_media_type.'" href="'.esc_url($question_media_url).'" target="_blank">'.$question_media_title.'</a>';
824 824
 								$question_media_link_class = '';
825 825
 							}
826 826
 
827
-							$question_media_add_button = __( 'Change file', 'woothemes-sensei' );
827
+							$question_media_add_button = __('Change file', 'woothemes-sensei');
828 828
 						}
829 829
 					}
830 830
 				}
831 831
 
832
-				$random_order = get_post_meta( $question_id, '_random_order', true );
833
-				if( ! $random_order ) {
832
+				$random_order = get_post_meta($question_id, '_random_order', true);
833
+				if ( ! $random_order) {
834 834
 					$random_order = 'yes';
835 835
 				}
836 836
 
837
-				if( ! $question_type ) { $question_type = 'multiple-choice'; }
837
+				if ( ! $question_type) { $question_type = 'multiple-choice'; }
838 838
 			}
839 839
 
840
-			$html .= '<tbody class="' . $question_class . '">';
840
+			$html .= '<tbody class="'.$question_class.'">';
841 841
 
842
-				if( 'quiz' == $context ) {
842
+				if ('quiz' == $context) {
843 843
 					$html .= '<tr>';
844
-						if( $question_type != 'category' ) {
845
-							$question = get_post( $question_id );
846
-							$html .= '<td class="table-count question-number question-count-column"><span class="number">' . $question_counter . '</span></td>';
847
-							$html .= '<td>' . esc_html( $question->post_title ) . '</td>';
848
-							$html .= '<td class="question-grade-column">' . esc_html( $question_grade ) . '</td>';
849
-							$question_types_filtered = ucwords( str_replace( array( '-', 'boolean' ), array( ' ', __( 'True/False', 'woothemes-sensei' ) ), $question_type ) );
850
-							$html .= '<td>' . esc_html( $question_types_filtered ) . '</td>';
851
-							$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>';
844
+						if ($question_type != 'category') {
845
+							$question = get_post($question_id);
846
+							$html .= '<td class="table-count question-number question-count-column"><span class="number">'.$question_counter.'</span></td>';
847
+							$html .= '<td>'.esc_html($question->post_title).'</td>';
848
+							$html .= '<td class="question-grade-column">'.esc_html($question_grade).'</td>';
849
+							$question_types_filtered = ucwords(str_replace(array('-', 'boolean'), array(' ', __('True/False', 'woothemes-sensei')), $question_type));
850
+							$html .= '<td>'.esc_html($question_types_filtered).'</td>';
851
+							$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>';
852 852
 
853 853
 						} else {
854 854
 
855
-							$end_number = intval( $question_counter ) + intval( $multiple_data[1] ) - 1;
856
-							if( $question_counter == $end_number ) {
855
+							$end_number = intval($question_counter) + intval($multiple_data[1]) - 1;
856
+							if ($question_counter == $end_number) {
857 857
 								$row_numbers = $question_counter;
858 858
 							} else {
859
-								$row_numbers = $question_counter . ' - ' . $end_number;
859
+								$row_numbers = $question_counter.' - '.$end_number;
860 860
 							}
861
-							$row_title = sprintf( __( 'Selected from \'%1$s\' ', 'woothemes-sensei' ), $multiple_data[0] );
861
+							$row_title = sprintf(__('Selected from \'%1$s\' ', 'woothemes-sensei'), $multiple_data[0]);
862 862
 
863
-							$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>';
864
-							$html .= '<td>' . esc_html( $row_title ) . '</td>';
863
+							$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>';
864
+							$html .= '<td>'.esc_html($row_title).'</td>';
865 865
 							$html .= '<td class="question-grade-column"></td>';
866
-							$html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" /></td>';
867
-							$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>';
866
+							$html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" /></td>';
867
+							$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>';
868 868
 
869 869
 						}
870 870
 					$html .= '</tr>';
871 871
 				}
872 872
 
873
-				if( $question_type != 'category' ) {
873
+				if ($question_type != 'category') {
874 874
 
875 875
 					$edit_class = '';
876
-					if( 'quiz' == $context ) {
876
+					if ('quiz' == $context) {
877 877
 						$edit_class = 'hidden';
878 878
 					}
879 879
 
880
-					$question = get_post( $question_id );
881
-					$html .= '<tr class="question-quick-edit ' . esc_attr( $edit_class ) . '">';
880
+					$question = get_post($question_id);
881
+					$html .= '<tr class="question-quick-edit '.esc_attr($edit_class).'">';
882 882
 						$html .= '<td colspan="5">';
883
-							$html .= '<span class="hidden question_original_counter">' . $question_counter . '</span>';
883
+							$html .= '<span class="hidden question_original_counter">'.$question_counter.'</span>';
884 884
 					    	$html .= '<div class="question_required_fields">';
885 885
 
886 886
 						    	// Question title
887 887
 						    	$html .= '<div>';
888
-							    	$html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> ';
889
-							    	$html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />';
888
+							    	$html .= '<label for="question_'.$question_counter.'">'.__('Question:', 'woothemes-sensei').'</label> ';
889
+							    	$html .= '<input type="text" id="question_'.$question_counter.'" name="question" value="'.esc_attr(htmlspecialchars($question->post_title)).'" size="25" class="widefat" />';
890 890
 						    	$html .= '</div>';
891 891
 
892 892
 						    	// Question description
893 893
 						    	$html .= '<div>';
894
-							    	$html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
894
+							    	$html .= '<label for="question_'.$question_counter.'_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> ';
895 895
 						    	$html .= '</div>';
896
-							    	$html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>';
896
+							    	$html .= '<textarea id="question_'.$question_counter.'_desc" name="question_description" class="widefat" rows="4">'.esc_textarea($question->post_content).'</textarea>';
897 897
 
898 898
 						    	// Question grade
899 899
 						    	$html .= '<div>';
900
-							    	$html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> ';
901
-							    	$html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />';
900
+							    	$html .= '<label for="question_'.$question_counter.'_grade">'.__('Question grade:', 'woothemes-sensei').'</label> ';
901
+							    	$html .= '<input type="number" id="question_'.$question_counter.'_grade" class="question_grade small-text" name="question_grade" min="0" value="'.$question_grade.'" />';
902 902
 						    	$html .= '</div>';
903 903
 
904 904
 						    	// Random order
905
-						    	if( $question_type == 'multiple-choice' ) {
905
+						    	if ($question_type == 'multiple-choice') {
906 906
 						    		$html .= '<div>';
907
-						    			$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>';
907
+						    			$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>';
908 908
 						    		$html .= '</div>';
909 909
 						    	}
910 910
 
911 911
 						    	// Question media
912 912
 						    	$html .= '<div>';
913
-							    	$html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
914
-							    	$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>';
915
-							    	$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/>';
916
-							    	$html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>';
917
-							    	$html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>';
918
-							    	$html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />';
913
+							    	$html .= '<label for="question_'.$question_counter.'_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>';
914
+							    	$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>';
915
+							    	$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/>';
916
+							    	$html .= '<span id="question_'.$question_counter.'_media_link" class="question_media_link '.$question_media_link_class.'">'.$question_media_link.'</span>';
917
+							    	$html .= '<br/><img id="question_'.$question_counter.'_media_preview" class="question_media_preview '.$question_media_thumb_class.'" src="'.$question_media_thumb.'" /><br/>';
918
+							    	$html .= '<input type="hidden" id="question_'.$question_counter.'_media" class="question_media" name="question_media" value="'.$question_media.'" />';
919 919
 						    	$html .= '</div>';
920 920
 
921 921
 						    $html .= '</div>';
922 922
 
923
-						    $html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter );
923
+						    $html .= $this->quiz_panel_question_field($question_type, $question_id, $question_counter);
924 924
 
925
-						    $html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />';
926
-							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" />';
925
+						    $html .= '<input type="hidden" id="question_'.$question_counter.'_question_type" class="question_type" name="question_type" value="'.$question_type.'" />';
926
+							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" />';
927 927
 
928
-							if( 'quiz' == $context ) {
928
+							if ('quiz' == $context) {
929 929
 					    		$html .= '<div class="update-question">';
930
-						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> ';
931
-						    		$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>';
930
+						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="'.esc_attr(__('Cancel', 'woothemes-sensei')).'">'.__('Cancel', 'woothemes-sensei').'</a> ';
931
+						    		$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>';
932 932
 					    		$html .= '</div>';
933 933
 					    	}
934 934
 
@@ -943,79 +943,79 @@  discard block
 block discarded – undo
943 943
 		return $html;
944 944
 	}
945 945
 
946
-	public function quiz_panel_add( $context = 'quiz' ) {
946
+	public function quiz_panel_add($context = 'quiz') {
947 947
 
948 948
 
949 949
 		$html = '<div id="add-new-question">';
950 950
 
951 951
 			$question_types = Sensei()->question->question_types();
952 952
 
953
-			$question_cats = get_terms( 'question-category', array( 'hide_empty' => false ) );
953
+			$question_cats = get_terms('question-category', array('hide_empty' => false));
954 954
 
955
-			if( 'quiz' == $context ) {
955
+			if ('quiz' == $context) {
956 956
 	    		$html .= '<h2 class="nav-tab-wrapper add-question-tabs">';
957
-	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question'  , 'woothemes-sensei' ) . '</a>';
958
-	    			$html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions'  , 'woothemes-sensei' ) . '</a>';
959
-                    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats )  && ! Sensei()->teacher->is_admin_teacher() ) {
960
-	    				$html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions'  , 'woothemes-sensei' ) . '</a>';
957
+	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">'.__('New Question', 'woothemes-sensei').'</a>';
958
+	    			$html .= '<a id="tab-existing" class="nav-tab">'.__('Existing Questions', 'woothemes-sensei').'</a>';
959
+                    if ( ! empty($question_cats) && ! is_wp_error($question_cats) && ! Sensei()->teacher->is_admin_teacher()) {
960
+	    				$html .= '<a id="tab-multiple" class="nav-tab">'.__('Category Questions', 'woothemes-sensei').'</a>';
961 961
 	    			}
962 962
 	    		$html .= '</h2>';
963 963
 	    	}
964 964
 
965 965
 	    	$html .= '<div class="tab-content" id="tab-new-content">';
966 966
 
967
-	    		if( 'quiz' == $context ) {
968
-	    			$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>';
967
+	    		if ('quiz' == $context) {
968
+	    			$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>';
969 969
 	    		}
970 970
 
971 971
 				$html .= '<div class="question">';
972 972
 					$html .= '<div class="question_required_fields">';
973 973
 
974 974
 						// Question title
975
-						$html .= '<p><label>' . __( 'Question:'  , 'woothemes-sensei' ) . '</label> ';
975
+						$html .= '<p><label>'.__('Question:', 'woothemes-sensei').'</label> ';
976 976
 	  					$html .= '<input type="text" id="add_question" name="question" value="" size="25" class="widefat" /></p>';
977 977
 
978 978
 						// Question description
979 979
 						$html .= '<p>';
980
-							$html .= '<label for="question_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
980
+							$html .= '<label for="question_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> ';
981 981
 						$html .= '</p>';
982 982
 						$html .= '<textarea id="question_desc" name="question_description" class="widefat" rows="4"></textarea>';
983 983
 
984 984
 	  					// Question type
985
-						$html .= '<p><label>' . __( 'Question Type:' , 'woothemes-sensei' ) . '</label> ';
986
-						$html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">' . "\n";
987
-							foreach ( $question_types as $type => $label ) {
988
-								$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>' . "\n";
985
+						$html .= '<p><label>'.__('Question Type:', 'woothemes-sensei').'</label> ';
986
+						$html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">'."\n";
987
+							foreach ($question_types as $type => $label) {
988
+								$html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>'."\n";
989 989
 							} // End For Loop
990
-						$html .= '</select></p>' . "\n";
990
+						$html .= '</select></p>'."\n";
991 991
 
992 992
 						// Question category
993
-						if( 'quiz' == $context ) {
994
-							if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
995
-								$html .= '<p><label>' . __( 'Question Category:' , 'woothemes-sensei' ) . '</label> ';
996
-								$html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">' . "\n";
997
-								$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>' . "\n";
998
-								foreach( $question_cats as $cat ) {
999
-									$html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>';
993
+						if ('quiz' == $context) {
994
+							if ( ! empty($question_cats) && ! is_wp_error($question_cats)) {
995
+								$html .= '<p><label>'.__('Question Category:', 'woothemes-sensei').'</label> ';
996
+								$html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">'."\n";
997
+								$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'."\n";
998
+								foreach ($question_cats as $cat) {
999
+									$html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>';
1000 1000
 								} // End For Loop
1001
-								$html .= '</select></p>' . "\n";
1001
+								$html .= '</select></p>'."\n";
1002 1002
 							}
1003 1003
 						}
1004 1004
 
1005 1005
 	  					// Question grade
1006
-						$html .= '<p><label>' . __( 'Question Grade:'  , 'woothemes-sensei' ) . '</label> ';
1007
-						$html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>' . "\n";
1006
+						$html .= '<p><label>'.__('Question Grade:', 'woothemes-sensei').'</label> ';
1007
+						$html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>'."\n";
1008 1008
 
1009 1009
 						// Random order
1010 1010
 						$html .= '<p class="add_question_random_order">';
1011
-			    			$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>';
1011
+			    			$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>';
1012 1012
 			    		$html .= '</p>';
1013 1013
 
1014 1014
 			    		// Question media
1015 1015
 						$html .= '<p>';
1016
-					    	$html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
1017
-					    	$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>';
1018
-					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
1016
+					    	$html .= '<label for="question_add_new_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>';
1017
+					    	$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>';
1018
+					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">'.__('Delete file', 'woothemes-sensei').'</button><br/>';
1019 1019
 					    	$html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>';
1020 1020
 					    	$html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>';
1021 1021
 					    	$html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />';
@@ -1024,44 +1024,44 @@  discard block
 block discarded – undo
1024 1024
 					$html .= '</div>';
1025 1025
 				$html .= '</div>';
1026 1026
 
1027
-				foreach ( $question_types as $type => $label ) {
1028
-					$html .= $this->quiz_panel_question_field( $type );
1027
+				foreach ($question_types as $type => $label) {
1028
+					$html .= $this->quiz_panel_question_field($type);
1029 1029
 				}
1030 1030
 
1031
-				if( 'quiz' == $context ) {
1031
+				if ('quiz' == $context) {
1032 1032
 					$html .= '<div class="add-question">';
1033
-			    		$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>';
1033
+			    		$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>';
1034 1034
 		    		$html .= '</div>';
1035 1035
 		    	}
1036 1036
 
1037 1037
 		    $html .= '</div>';
1038 1038
 
1039
-		    if( 'quiz' == $context ) {
1039
+		    if ('quiz' == $context) {
1040 1040
 
1041 1041
 			    $html .= '<div class="tab-content hidden" id="tab-existing-content">';
1042 1042
 
1043
-			    	$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>';
1043
+			    	$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>';
1044 1044
 
1045 1045
 			    	$html .= '<div id="existing-filters" class="alignleft actions">
1046 1046
 			    				<select id="existing-status">
1047
-			    					<option value="all">' . __( 'All', 'woothemes-sensei' ) . '</option>
1048
-			    					<option value="unused">' . __( 'Unused', 'woothemes-sensei' ) . '</option>
1049
-			    					<option value="used">' . __( 'Used', 'woothemes-sensei' ) . '</option>
1047
+			    					<option value="all">' . __('All', 'woothemes-sensei').'</option>
1048
+			    					<option value="unused">' . __('Unused', 'woothemes-sensei').'</option>
1049
+			    					<option value="used">' . __('Used', 'woothemes-sensei').'</option>
1050 1050
 			    				</select>
1051 1051
 			    				<select id="existing-type">
1052
-			    					<option value="">' . __( 'All Types', 'woothemes-sensei' ) . '</option>';
1053
-							    	foreach ( $question_types as $type => $label ) {
1054
-										$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>';
1052
+			    					<option value="">' . __('All Types', 'woothemes-sensei').'</option>';
1053
+							    	foreach ($question_types as $type => $label) {
1054
+										$html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>';
1055 1055
 									}
1056 1056
     				$html .= '</select>
1057 1057
     							<select id="existing-category">
1058
-			    					<option value="">' . __( 'All Categories', 'woothemes-sensei' ) . '</option>';
1059
-				    				foreach( $question_cats as $cat ) {
1060
-										$html .= '<option value="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat->name ) . '</option>';
1058
+			    					<option value="">' . __('All Categories', 'woothemes-sensei').'</option>';
1059
+				    				foreach ($question_cats as $cat) {
1060
+										$html .= '<option value="'.esc_attr($cat->slug).'">'.esc_html($cat->name).'</option>';
1061 1061
 									}
1062 1062
     				$html .= '</select>
1063
-    							<input type="text" id="existing-search" placeholder="' . __( 'Search', 'woothemes-sensei' ) . '" />
1064
-    							<a class="button" id="existing-filter-button">' . __( 'Filter', 'woothemes-sensei' ) . '</a>
1063
+    							<input type="text" id="existing-search" placeholder="' . __('Search', 'woothemes-sensei').'" />
1064
+    							<a class="button" id="existing-filter-button">' . __('Filter', 'woothemes-sensei').'</a>
1065 1065
 			    			</div>';
1066 1066
 
1067 1067
 			    	$html .= '<table id="existing-table" class="widefat">';
@@ -1069,17 +1069,17 @@  discard block
 block discarded – undo
1069 1069
 			    		$html .= '<thead>
1070 1070
 									    <tr>
1071 1071
 									        <th scope="col" class="column-cb check-column"><input type="checkbox" /></th>
1072
-									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
1073
-									        <th scope="col">' . __( 'Type', 'woothemes-sensei' ) . '</th>
1074
-									        <th scope="col">' . __( 'Category', 'woothemes-sensei' ) . '</th>
1072
+									        <th scope="col">' . __('Question', 'woothemes-sensei').'</th>
1073
+									        <th scope="col">' . __('Type', 'woothemes-sensei').'</th>
1074
+									        <th scope="col">' . __('Category', 'woothemes-sensei').'</th>
1075 1075
 									    </tr>
1076 1076
 									</thead>
1077 1077
 									<tfoot>
1078 1078
 									    <tr>
1079 1079
 										    <th scope="col" class="check-column"><input type="checkbox" /></th>
1080
-									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
1081
-									        <th scope="col">' . __( 'Type', 'woothemes-sensei' ) . '</th>
1082
-									        <th scope="col">' . __( 'Category', 'woothemes-sensei' ) . '</th>
1080
+									        <th scope="col">' . __('Question', 'woothemes-sensei').'</th>
1081
+									        <th scope="col">' . __('Type', 'woothemes-sensei').'</th>
1082
+									        <th scope="col">' . __('Category', 'woothemes-sensei').'</th>
1083 1083
 									    </tr>
1084 1084
 									</tfoot>';
1085 1085
 						$html .= '<tbody id="existing-questions">';
@@ -1087,8 +1087,8 @@  discard block
 block discarded – undo
1087 1087
 						$questions = $this->quiz_panel_get_existing_questions();
1088 1088
 
1089 1089
 						$row = 1;
1090
-						foreach( $questions['questions'] as $question ) {
1091
-							$html .= $this->quiz_panel_add_existing_question( $question->ID, $row );
1090
+						foreach ($questions['questions'] as $question) {
1091
+							$html .= $this->quiz_panel_add_existing_question($question->ID, $row);
1092 1092
 							++$row;
1093 1093
 						}
1094 1094
 
@@ -1097,36 +1097,36 @@  discard block
 block discarded – undo
1097 1097
 			    	$html .= '</table>';
1098 1098
 
1099 1099
 			    	$next_class = '';
1100
-			    	if( $questions['count'] <= 10 ) {
1100
+			    	if ($questions['count'] <= 10) {
1101 1101
 			    		$next_class = 'hidden';
1102 1102
 			    	}
1103 1103
 
1104 1104
 			    	$html .= '<div id="existing-pagination">';
1105 1105
 			    		$html .= '<input type="hidden" id="existing-page" value="1" />';
1106
-			    		$html .= '<a class="prev no-paging">&larr; ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' &rarr;</a>';
1106
+			    		$html .= '<a class="prev no-paging">&larr; '.__('Previous', 'woothemes-sensei').'</a> <a class="next '.esc_attr($next_class).'">'.__('Next', 'woothemes-sensei').' &rarr;</a>';
1107 1107
 			    	$html .= '</div>';
1108 1108
 
1109 1109
 			    	$html .= '<div class="existing-actions">';
1110
-			    		$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>';
1110
+			    		$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>';
1111 1111
 			    	$html .= '</div>';
1112 1112
 
1113 1113
 			    $html .= '</div>';
1114 1114
 
1115
-			    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
1115
+			    if ( ! empty($question_cats) && ! is_wp_error($question_cats)) {
1116 1116
 				    $html .= '<div class="tab-content hidden" id="tab-multiple-content">';
1117 1117
 
1118
-				    	$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>';
1118
+				    	$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>';
1119 1119
 
1120
-						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">' . "\n";
1121
-						$html .= '<option value="">' . __( 'Select a Question Category', 'woothemes-sensei' ) . '</option>' . "\n";
1122
-						foreach( $question_cats as $cat ) {
1123
-							$html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>';
1120
+						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">'."\n";
1121
+						$html .= '<option value="">'.__('Select a Question Category', 'woothemes-sensei').'</option>'."\n";
1122
+						foreach ($question_cats as $cat) {
1123
+							$html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>';
1124 1124
 						} // End For Loop
1125
-						$html .= '</select></p>' . "\n";
1125
+						$html .= '</select></p>'."\n";
1126 1126
 
1127
-						$html .= '<p>' . __( 'Number of questions:', 'woothemes-sensei' ) . ' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>';
1127
+						$html .= '<p>'.__('Number of questions:', 'woothemes-sensei').' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>';
1128 1128
 
1129
-						$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>';
1129
+						$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>';
1130 1130
 
1131 1131
 				    $html .= '</div>';
1132 1132
 				}
@@ -1137,7 +1137,7 @@  discard block
 block discarded – undo
1137 1137
 		return $html;
1138 1138
 	}
1139 1139
 
1140
-	public function quiz_panel_get_existing_questions( $question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1 ) {
1140
+	public function quiz_panel_get_existing_questions($question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1) {
1141 1141
 
1142 1142
 		$args = array(
1143 1143
 			'post_type' => 'question',
@@ -1146,14 +1146,14 @@  discard block
 block discarded – undo
1146 1146
 			'suppress_filters' => 0,
1147 1147
 		);
1148 1148
 
1149
-		switch( $question_status ) {
1149
+		switch ($question_status) {
1150 1150
 			case 'unused': $quiz_status = 'NOT EXISTS'; break;
1151 1151
 			case 'used': $quiz_status = 'EXISTS'; break;
1152 1152
 			default: $quiz_status = ''; break;
1153 1153
 		}
1154 1154
 
1155
-		if( $quiz_status ) {
1156
-			switch( $quiz_status ) {
1155
+		if ($quiz_status) {
1156
+			switch ($quiz_status) {
1157 1157
 				case 'EXISTS':
1158 1158
 					$args['meta_query'][] = array(
1159 1159
 						'key' => '_quiz_id',
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 			}
1172 1172
 		}
1173 1173
 
1174
-		if( $question_type ) {
1174
+		if ($question_type) {
1175 1175
 			$args['tax_query'][] = array(
1176 1176
 				'taxonomy' => 'question-type',
1177 1177
 				'field' => 'slug',
@@ -1179,7 +1179,7 @@  discard block
 block discarded – undo
1179 1179
 			);
1180 1180
 		}
1181 1181
 
1182
-		if( $question_category ) {
1182
+		if ($question_category) {
1183 1183
 			$args['tax_query'][] = array(
1184 1184
 				'taxonomy' => 'question-category',
1185 1185
 				'field' => 'slug',
@@ -1187,19 +1187,19 @@  discard block
 block discarded – undo
1187 1187
 			);
1188 1188
 		}
1189 1189
 
1190
-		if( $question_type && $question_category ) {
1190
+		if ($question_type && $question_category) {
1191 1191
 			$args['tax_query']['relation'] = 'AND';
1192 1192
 		}
1193 1193
 
1194
-		if( $question_search ) {
1194
+		if ($question_search) {
1195 1195
 			$args['s'] = $question_search;
1196 1196
 		}
1197 1197
 
1198
-		if( $page ) {
1198
+		if ($page) {
1199 1199
 			$args['paged'] = $page;
1200 1200
 		}
1201 1201
 
1202
-		$qry = new WP_Query( $args );
1202
+		$qry = new WP_Query($args);
1203 1203
 
1204 1204
         /**
1205 1205
          * Filter existing questions query
@@ -1208,39 +1208,39 @@  discard block
 block discarded – undo
1208 1208
          *
1209 1209
          * @param WP_Query $wp_query
1210 1210
          */
1211
-        $qry = apply_filters( 'sensei_existing_questions_query_results', $qry );
1211
+        $qry = apply_filters('sensei_existing_questions_query_results', $qry);
1212 1212
 
1213 1213
 		$questions['questions'] = $qry->posts;
1214
-		$questions['count'] = intval( $qry->found_posts );
1214
+		$questions['count'] = intval($qry->found_posts);
1215 1215
 		$questions['page'] = $page;
1216 1216
 
1217 1217
 		return $questions;
1218 1218
 	}
1219 1219
 
1220
-	public function quiz_panel_add_existing_question( $question_id = 0, $row = 1 ) {
1220
+	public function quiz_panel_add_existing_question($question_id = 0, $row = 1) {
1221 1221
 
1222 1222
 		$html = '';
1223 1223
 
1224
-		if( ! $question_id ) {
1224
+		if ( ! $question_id) {
1225 1225
 
1226 1226
             return;
1227 1227
 
1228 1228
         }
1229 1229
 
1230 1230
 		$existing_class = '';
1231
-		if( $row % 2 ) {
1231
+		if ($row % 2) {
1232 1232
             $existing_class = 'alternate';
1233 1233
         }
1234 1234
 
1235
-		$question_type = Sensei()->question->get_question_type( $question_id );
1235
+		$question_type = Sensei()->question->get_question_type($question_id);
1236 1236
 
1237
-		$question_cat_list = strip_tags( get_the_term_list( $question_id, 'question-category', '', ', ', '' ) );
1237
+		$question_cat_list = strip_tags(get_the_term_list($question_id, 'question-category', '', ', ', ''));
1238 1238
 
1239
-		$html .= '<tr class="' . esc_attr( $existing_class ) . '">
1240
-					<td class="cb"><input type="checkbox" value="' . $question_id . '" class="existing-item" /></td>
1241
-					<td>' . get_the_title( $question_id ) . '</td>
1242
-					<td>' . esc_html( $question_type ) . '</td>
1243
-					<td>' . esc_html( $question_cat_list ) . '</td>
1239
+		$html .= '<tr class="'.esc_attr($existing_class).'">
1240
+					<td class="cb"><input type="checkbox" value="' . $question_id.'" class="existing-item" /></td>
1241
+					<td>' . get_the_title($question_id).'</td>
1242
+					<td>' . esc_html($question_type).'</td>
1243
+					<td>' . esc_html($question_cat_list).'</td>
1244 1244
 				  </tr>';
1245 1245
 
1246 1246
 		return $html;
@@ -1253,58 +1253,58 @@  discard block
 block discarded – undo
1253 1253
 
1254 1254
 		//Add nonce security to the request
1255 1255
 		$nonce = '';
1256
-		if( isset( $_POST['filter_existing_questions_nonce'] ) ) {
1257
-			$nonce = esc_html( $_POST['filter_existing_questions_nonce'] );
1256
+		if (isset($_POST['filter_existing_questions_nonce'])) {
1257
+			$nonce = esc_html($_POST['filter_existing_questions_nonce']);
1258 1258
 		} // End If Statement
1259 1259
 
1260
-		if( ! wp_verify_nonce( $nonce, 'filter_existing_questions_nonce' ) ) {
1261
-			die( $return );
1260
+		if ( ! wp_verify_nonce($nonce, 'filter_existing_questions_nonce')) {
1261
+			die($return);
1262 1262
 		} // End If Statement
1263 1263
 
1264 1264
 		// Parse POST data
1265 1265
 		$data = $_POST['data'];
1266 1266
 		$question_data = array();
1267
-		parse_str( $data, $question_data );
1267
+		parse_str($data, $question_data);
1268 1268
 
1269
-		if( 0 < count( $question_data ) ) {
1269
+		if (0 < count($question_data)) {
1270 1270
 
1271 1271
 			$question_status = '';
1272
-			if( isset( $question_data['question_status'] ) ) {
1272
+			if (isset($question_data['question_status'])) {
1273 1273
 				$question_status = $question_data['question_status'];
1274 1274
 			}
1275 1275
 
1276 1276
 			$question_type = '';
1277
-			if( isset( $question_data['question_type'] ) ) {
1277
+			if (isset($question_data['question_type'])) {
1278 1278
 				$question_type = $question_data['question_type'];
1279 1279
 			}
1280 1280
 
1281 1281
 			$question_category = '';
1282
-			if( isset( $question_data['question_category'] ) ) {
1282
+			if (isset($question_data['question_category'])) {
1283 1283
 				$question_category = $question_data['question_category'];
1284 1284
 			}
1285 1285
 
1286 1286
 			$question_search = '';
1287
-			if( isset( $question_data['question_search'] ) ) {
1287
+			if (isset($question_data['question_search'])) {
1288 1288
 				$question_search = $question_data['question_search'];
1289 1289
 			}
1290 1290
 
1291 1291
 			$question_page = 1;
1292
-			if( isset( $question_data['question_page'] ) ) {
1293
-				$question_page = intval( $question_data['question_page'] );
1292
+			if (isset($question_data['question_page'])) {
1293
+				$question_page = intval($question_data['question_page']);
1294 1294
 			}
1295 1295
 
1296
-			$questions = $this->quiz_panel_get_existing_questions( $question_status, $question_type, $question_category, $question_search, $question_page );
1296
+			$questions = $this->quiz_panel_get_existing_questions($question_status, $question_type, $question_category, $question_search, $question_page);
1297 1297
 
1298 1298
 			$row = 1;
1299 1299
 			$html = '';
1300
-			foreach( $questions['questions'] as $question ) {
1301
-				$html .= $this->quiz_panel_add_existing_question( $question->ID, $row );
1300
+			foreach ($questions['questions'] as $question) {
1301
+				$html .= $this->quiz_panel_add_existing_question($question->ID, $row);
1302 1302
 				++$row;
1303 1303
 			}
1304 1304
 
1305
-			if( ! $html ) {
1305
+			if ( ! $html) {
1306 1306
 				$html = '<tr class="alternate">
1307
-								<td class="no-results" colspan="4"><em>' . __( 'There are no questions matching your search.', 'woothemes-sensei' ) . '</em></td>
1307
+								<td class="no-results" colspan="4"><em>' . __('There are no questions matching your search.', 'woothemes-sensei').'</em></td>
1308 1308
 							  </tr>';
1309 1309
 			}
1310 1310
 
@@ -1312,53 +1312,53 @@  discard block
 block discarded – undo
1312 1312
 			$return['count'] = $questions['count'];
1313 1313
 			$return['page'] = $questions['page'];
1314 1314
 
1315
-			wp_send_json( $return );
1315
+			wp_send_json($return);
1316 1316
 		}
1317 1317
 
1318
-		die( $return );
1318
+		die($return);
1319 1319
 	}
1320 1320
 
1321
-	public function quiz_panel_question_field( $question_type = '', $question_id = 0, $question_counter = 0 ) {
1321
+	public function quiz_panel_question_field($question_type = '', $question_id = 0, $question_counter = 0) {
1322 1322
 
1323 1323
 		$html = '';
1324 1324
 
1325
-		if( $question_type ) {
1325
+		if ($question_type) {
1326 1326
 
1327 1327
 			$right_answer = '';
1328 1328
 			$wrong_answers = array();
1329 1329
 			$answer_order_string = '';
1330 1330
 			$answer_order = array();
1331
-			if( $question_id ) {
1332
-				$right_answer = get_post_meta( $question_id, '_question_right_answer', true);
1333
-				$wrong_answers = get_post_meta( $question_id, '_question_wrong_answers', true);
1334
-				$answer_order_string = get_post_meta( $question_id, '_answer_order', true );
1335
-				$answer_order = array_filter( explode( ',', $answer_order_string ) );
1331
+			if ($question_id) {
1332
+				$right_answer = get_post_meta($question_id, '_question_right_answer', true);
1333
+				$wrong_answers = get_post_meta($question_id, '_question_wrong_answers', true);
1334
+				$answer_order_string = get_post_meta($question_id, '_answer_order', true);
1335
+				$answer_order = array_filter(explode(',', $answer_order_string));
1336 1336
 				$question_class = '';
1337 1337
 			} else {
1338 1338
 				$question_id = '';
1339 1339
 				$question_class = 'answer-fields question_required_fields hidden';
1340 1340
 			}
1341 1341
 
1342
-			switch ( $question_type ) {
1342
+			switch ($question_type) {
1343 1343
 				case 'multiple-choice':
1344
-					$html .= '<div class="question_default_fields multiple-choice-answers ' . str_replace( ' hidden', '', $question_class ) . '">';
1344
+					$html .= '<div class="question_default_fields multiple-choice-answers '.str_replace(' hidden', '', $question_class).'">';
1345 1345
 
1346 1346
 						$right_answers = (array) $right_answer;
1347 1347
 						// Calculate total right answers available (defaults to 1)
1348 1348
 						$total_right = 0;
1349
-						if( $question_id ) {
1350
-							$total_right = get_post_meta( $question_id, '_right_answer_count', true );
1349
+						if ($question_id) {
1350
+							$total_right = get_post_meta($question_id, '_right_answer_count', true);
1351 1351
 						}
1352
-						if( 0 == intval( $total_right ) ) {
1352
+						if (0 == intval($total_right)) {
1353 1353
 							$total_right = 1;
1354 1354
 						}
1355
-						for ( $i = 0; $i < $total_right; $i++ ) {
1356
-							if ( !isset( $right_answers[ $i ] ) ) { $right_answers[ $i ] = ''; }
1357
-							$right_answer_id = $this->get_answer_id( $right_answers[ $i ] );
1355
+						for ($i = 0; $i < $total_right; $i++) {
1356
+							if ( ! isset($right_answers[$i])) { $right_answers[$i] = ''; }
1357
+							$right_answer_id = $this->get_answer_id($right_answers[$i]);
1358 1358
 							// Right Answer
1359
-							$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>';
1360
-							if( $question_id ) {
1361
-								$answers[ $right_answer_id ] = $right_answer;
1359
+							$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>';
1360
+							if ($question_id) {
1361
+								$answers[$right_answer_id] = $right_answer;
1362 1362
 							} else {
1363 1363
 								$answers[] = $right_answer;
1364 1364
 							}
@@ -1366,23 +1366,23 @@  discard block
 block discarded – undo
1366 1366
 
1367 1367
 				    	// Calculate total wrong answers available (defaults to 4)
1368 1368
 				    	$total_wrong = 0;
1369
-				    	if( $question_id ) {
1370
-				    		$total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true );
1369
+				    	if ($question_id) {
1370
+				    		$total_wrong = get_post_meta($question_id, '_wrong_answer_count', true);
1371 1371
 				    	}
1372
-				    	if( 0 == intval( $total_wrong ) ) {
1372
+				    	if (0 == intval($total_wrong)) {
1373 1373
 				    		$total_wrong = 1;
1374 1374
 				    	}
1375 1375
 
1376 1376
                         // Setup Wrong Answer HTML
1377
-                        foreach ( $wrong_answers as $i => $answer ){
1377
+                        foreach ($wrong_answers as $i => $answer) {
1378 1378
 
1379
-                            $answer_id = $this->get_answer_id( $answer );
1380
-                            $wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
1381
-                            $wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
1382
-                            $wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1383
-                            if( $question_id ) {
1379
+                            $answer_id = $this->get_answer_id($answer);
1380
+                            $wrong_answer = '<label class="answer" for="question_'.$question_counter.'_wrong_answer_'.$i.'"><span>'.__('Wrong:', 'woothemes-sensei');
1381
+                            $wrong_answer .= '</span> <input rel="'.esc_attr($answer_id).'" type="text" id="question_'.$question_counter.'_wrong_answer_'.$i;
1382
+                            $wrong_answer .= '" name="question_wrong_answers[]" value="'.esc_attr($answer).'" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1383
+                            if ($question_id) {
1384 1384
 
1385
-                                $answers[ $answer_id ] = $wrong_answer;
1385
+                                $answers[$answer_id] = $wrong_answer;
1386 1386
 
1387 1387
                             } else {
1388 1388
 
@@ -1393,115 +1393,115 @@  discard block
 block discarded – undo
1393 1393
                         } // end for each
1394 1394
 
1395 1395
 				    	$answers_sorted = $answers;
1396
-				    	if( $question_id && count( $answer_order ) > 0 ) {
1396
+				    	if ($question_id && count($answer_order) > 0) {
1397 1397
 				    		$answers_sorted = array();
1398
-				    		foreach( $answer_order as $answer_id ) {
1399
-				    			if( isset( $answers[ $answer_id ] ) ) {
1400
-				    				$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1401
-				    				unset( $answers[ $answer_id ] );
1398
+				    		foreach ($answer_order as $answer_id) {
1399
+				    			if (isset($answers[$answer_id])) {
1400
+				    				$answers_sorted[$answer_id] = $answers[$answer_id];
1401
+				    				unset($answers[$answer_id]);
1402 1402
 				    			}
1403 1403
 				    		}
1404 1404
 
1405
-				    		if( count( $answers ) > 0 ) {
1406
-						    	foreach( $answers as $id => $answer ) {
1407
-						    		$answers_sorted[ $id ] = $answer;
1405
+				    		if (count($answers) > 0) {
1406
+						    	foreach ($answers as $id => $answer) {
1407
+						    		$answers_sorted[$id] = $answer;
1408 1408
 						    	}
1409 1409
 						    }
1410 1410
 				    	}
1411 1411
 
1412
-						foreach( $answers_sorted as $id => $answer ) {
1412
+						foreach ($answers_sorted as $id => $answer) {
1413 1413
 				    		$html .= $answer;
1414 1414
 				    	}
1415 1415
 
1416
-				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />';
1417
-				    	$html .= '<span class="hidden right_answer_count">' . $total_right . '</span>';
1418
-				    	$html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>';
1416
+				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="'.$answer_order_string.'" />';
1417
+				    	$html .= '<span class="hidden right_answer_count">'.$total_right.'</span>';
1418
+				    	$html .= '<span class="hidden wrong_answer_count">'.$total_wrong.'</span>';
1419 1419
 
1420 1420
 				    	$html .= '<div class="add_answer_options">';
1421
-					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>';
1422
-					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>';
1421
+					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add right answer', 'woothemes-sensei').'</a>';
1422
+					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add wrong answer', 'woothemes-sensei').'</a>';
1423 1423
 				    	$html .= '</div>';
1424 1424
 
1425
-                        $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' );
1425
+                        $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'multiple-choice');
1426 1426
 
1427 1427
 			    	$html .= '</div>';
1428 1428
 				break;
1429 1429
 				case 'boolean':
1430
-					$html .= '<div class="question_boolean_fields ' . $question_class . '">';
1431
-						if( $question_id ) {
1432
-							$field_name = 'question_' . $question_id . '_right_answer_boolean';
1430
+					$html .= '<div class="question_boolean_fields '.$question_class.'">';
1431
+						if ($question_id) {
1432
+							$field_name = 'question_'.$question_id.'_right_answer_boolean';
1433 1433
 						} else {
1434 1434
 							$field_name = 'question_right_answer_boolean';
1435 1435
 							$right_answer = 'true';
1436 1436
 						}
1437
-						$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>';
1438
-						$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>';
1437
+						$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>';
1438
+						$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>';
1439 1439
 
1440
-                    $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' );
1440
+                    $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'boolean');
1441 1441
 
1442 1442
 					$html .= '</div>';
1443 1443
 				break;
1444 1444
 				case 'gap-fill':
1445
-					$gapfill_array = explode( '||', $right_answer );
1446
-					if ( isset( $gapfill_array[0] ) ) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; }
1447
-					if ( isset( $gapfill_array[1] ) ) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; }
1448
-					if ( isset( $gapfill_array[2] ) ) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; }
1449
-					$html .= '<div class="question_gapfill_fields ' . $question_class . '">';
1445
+					$gapfill_array = explode('||', $right_answer);
1446
+					if (isset($gapfill_array[0])) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; }
1447
+					if (isset($gapfill_array[1])) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; }
1448
+					if (isset($gapfill_array[2])) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; }
1449
+					$html .= '<div class="question_gapfill_fields '.$question_class.'">';
1450 1450
 						// Fill in the Gaps
1451
-						$html .= '<label>' . __( 'Text before the Gap:' , 'woothemes-sensei' ) . '</label> ';
1452
-						$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" />';
1453
-	  					$html .= '<label>' . __( 'The Gap:' , 'woothemes-sensei' ) . '</label> ';
1454
-	  					$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" />';
1455
-	  					$html .= '<label>' . __( 'Text after the Gap:' , 'woothemes-sensei' ) . '</label> ';
1456
-	  					$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" />';
1457
-	  					$html .= '<label>' . __( 'Preview:' , 'woothemes-sensei' ) . '</label> ';
1458
-	  					$html .= '<p class="gapfill-preview">' . $gapfill_pre . '&nbsp;<u>' . $gapfill_gap . '</u>&nbsp;' . $gapfill_post . '</p>';
1451
+						$html .= '<label>'.__('Text before the Gap:', 'woothemes-sensei').'</label> ';
1452
+						$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" />';
1453
+	  					$html .= '<label>'.__('The Gap:', 'woothemes-sensei').'</label> ';
1454
+	  					$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" />';
1455
+	  					$html .= '<label>'.__('Text after the Gap:', 'woothemes-sensei').'</label> ';
1456
+	  					$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" />';
1457
+	  					$html .= '<label>'.__('Preview:', 'woothemes-sensei').'</label> ';
1458
+	  					$html .= '<p class="gapfill-preview">'.$gapfill_pre.'&nbsp;<u>'.$gapfill_gap.'</u>&nbsp;'.$gapfill_post.'</p>';
1459 1459
 	  				$html .= '</div>';
1460 1460
 				break;
1461 1461
 				case 'multi-line':
1462
-					$html .= '<div class="question_multiline_fields ' . $question_class . '">';
1462
+					$html .= '<div class="question_multiline_fields '.$question_class.'">';
1463 1463
 						// Guides for grading
1464
-						if( $question_counter ) {
1465
-							$field_id = 'question_' . $question_counter . '_add_question_right_answer_multiline';
1464
+						if ($question_counter) {
1465
+							$field_id = 'question_'.$question_counter.'_add_question_right_answer_multiline';
1466 1466
 						} else {
1467 1467
 							$field_id = 'add_question_right_answer_multiline';
1468 1468
 						}
1469
-						$html .= '<label>' . __( 'Guide/Teacher Notes for grading the answer' , 'woothemes-sensei' ) . '</label> ';
1470
-						$html .= '<textarea id="' . $field_id . '" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>';
1469
+						$html .= '<label>'.__('Guide/Teacher Notes for grading the answer', 'woothemes-sensei').'</label> ';
1470
+						$html .= '<textarea id="'.$field_id.'" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>';
1471 1471
 					$html .= '</div>';
1472 1472
 				break;
1473 1473
 				case 'single-line':
1474
-					$html .= '<div class="question_singleline_fields ' . $question_class . '">';
1474
+					$html .= '<div class="question_singleline_fields '.$question_class.'">';
1475 1475
 						// Recommended Answer
1476
-						if( $question_counter ) {
1477
-							$field_id = 'question_' . $question_counter . '_add_question_right_answer_singleline';
1476
+						if ($question_counter) {
1477
+							$field_id = 'question_'.$question_counter.'_add_question_right_answer_singleline';
1478 1478
 						} else {
1479 1479
 							$field_id = 'add_question_right_answer_singleline';
1480 1480
 						}
1481
-						$html .= '<label>' . __( 'Recommended Answer' , 'woothemes-sensei' ) . '</label> ';
1482
-						$html .= '<input type="text" id="' . $field_id . '" name="add_question_right_answer_singleline" value="' . $right_answer . '" size="25" class="widefat" />';
1481
+						$html .= '<label>'.__('Recommended Answer', 'woothemes-sensei').'</label> ';
1482
+						$html .= '<input type="text" id="'.$field_id.'" name="add_question_right_answer_singleline" value="'.$right_answer.'" size="25" class="widefat" />';
1483 1483
 					$html .= '</div>';
1484 1484
 				break;
1485 1485
 				case 'file-upload':
1486
-					$html .= '<div class="question_fileupload_fields ' . $question_class . '">';
1487
-						if( $question_counter ) {
1488
-							$right_field_id = 'question_' . $question_counter . '_add_question_right_answer_fileupload';
1489
-							$wrong_field_id = 'question_' . $question_counter . '_add_question_wrong_answer_fileupload';
1486
+					$html .= '<div class="question_fileupload_fields '.$question_class.'">';
1487
+						if ($question_counter) {
1488
+							$right_field_id = 'question_'.$question_counter.'_add_question_right_answer_fileupload';
1489
+							$wrong_field_id = 'question_'.$question_counter.'_add_question_wrong_answer_fileupload';
1490 1490
 						} else {
1491 1491
 							$right_field_id = 'add_question_right_answer_fileupload';
1492 1492
 							$wrong_field_id = 'add_question_wrong_answer_fileupload';
1493 1493
 						}
1494 1494
 
1495 1495
 						$wrong_answer = '';
1496
-						if( isset( $wrong_answers[0] ) ) {
1496
+						if (isset($wrong_answers[0])) {
1497 1497
 							$wrong_answer = $wrong_answers[0];
1498 1498
 						}
1499
-						$html .= '<label>' . __( 'Description for student explaining what needs to be uploaded' , 'woothemes-sensei' ) . '</label> ';
1500
-						$html .= '<textarea id="' . $wrong_field_id . '" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">' . $wrong_answer . '</textarea>';
1499
+						$html .= '<label>'.__('Description for student explaining what needs to be uploaded', 'woothemes-sensei').'</label> ';
1500
+						$html .= '<textarea id="'.$wrong_field_id.'" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">'.$wrong_answer.'</textarea>';
1501 1501
 
1502 1502
 						// Guides for grading
1503
-						$html .= '<label>' . __( 'Guide/Teacher Notes for grading the upload' , 'woothemes-sensei' ) . '</label> ';
1504
-						$html .= '<textarea id="' . $right_field_id . '" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>';
1503
+						$html .= '<label>'.__('Guide/Teacher Notes for grading the upload', 'woothemes-sensei').'</label> ';
1504
+						$html .= '<textarea id="'.$right_field_id.'" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>';
1505 1505
 					$html .= '</div>';
1506 1506
 				break;
1507 1507
 			}
@@ -1510,32 +1510,32 @@  discard block
 block discarded – undo
1510 1510
 		return $html;
1511 1511
 	}
1512 1512
 
1513
-	public function quiz_panel_question_feedback( $question_counter = 0, $question_id = 0, $question_type = '' ) {
1513
+	public function quiz_panel_question_feedback($question_counter = 0, $question_id = 0, $question_type = '') {
1514 1514
 
1515 1515
         // default field name
1516 1516
         $field_name = 'answer_feedback';
1517
-        if( 'boolean' == $question_type ){
1517
+        if ('boolean' == $question_type) {
1518 1518
 
1519 1519
             $field_name = 'answer_feedback_boolean';
1520 1520
 
1521
-        }elseif( 'multiple-choice' == $question_type ){
1521
+        }elseif ('multiple-choice' == $question_type) {
1522 1522
 
1523 1523
             $field_name = 'answer_feedback_multiple_choice';
1524 1524
 
1525 1525
         }// end if
1526 1526
 
1527
-		if( $question_counter ) {
1528
-			$field_name = 'answer_' . $question_counter . '_feedback';
1527
+		if ($question_counter) {
1528
+			$field_name = 'answer_'.$question_counter.'_feedback';
1529 1529
 		}
1530 1530
 
1531 1531
 		$feedback = '';
1532
-		if( $question_id ) {
1533
-			$feedback = get_post_meta( $question_id, '_answer_feedback', true );
1532
+		if ($question_id) {
1533
+			$feedback = get_post_meta($question_id, '_answer_feedback', true);
1534 1534
 		}
1535 1535
 
1536
-		$html = '<p title="' . __( 'This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei' ) . '">';
1537
-		$html .= '<label for="' . $field_name . '">' . __( 'Answer Feedback' , 'woothemes-sensei' ) . ':</label>';
1538
-		$html .= '<textarea id="' . $field_name . '" name="' . $field_name . '" rows="4" cols="40" class="answer_feedback widefat">' . $feedback . '</textarea>';
1536
+		$html = '<p title="'.__('This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei').'">';
1537
+		$html .= '<label for="'.$field_name.'">'.__('Answer Feedback', 'woothemes-sensei').':</label>';
1538
+		$html .= '<textarea id="'.$field_name.'" name="'.$field_name.'" rows="4" cols="40" class="answer_feedback widefat">'.$feedback.'</textarea>';
1539 1539
 		$html .= '</p>';
1540 1540
 
1541 1541
 		return $html;
@@ -1544,19 +1544,19 @@  discard block
 block discarded – undo
1544 1544
 	public function question_get_answer_id() {
1545 1545
 		$data = $_POST['data'];
1546 1546
 		$answer_data = array();
1547
-		parse_str( $data, $answer_data );
1547
+		parse_str($data, $answer_data);
1548 1548
 		$answer = $answer_data['answer_value'];
1549
-		$answer_id = $this->get_answer_id( $answer );
1549
+		$answer_id = $this->get_answer_id($answer);
1550 1550
 		echo $answer_id;
1551 1551
 		die();
1552 1552
 	}
1553 1553
 
1554
-	public function get_answer_id( $answer = '' ) {
1554
+	public function get_answer_id($answer = '') {
1555 1555
 
1556 1556
 		$answer_id = '';
1557 1557
 
1558
-		if( $answer ) {
1559
-			$answer_id = md5( $answer );
1558
+		if ($answer) {
1559
+			$answer_id = md5($answer);
1560 1560
 		}
1561 1561
 
1562 1562
 		return $answer_id;
@@ -1569,17 +1569,17 @@  discard block
 block discarded – undo
1569 1569
 	 * @access public
1570 1570
 	 * @return void
1571 1571
 	 */
1572
-	public function lesson_quiz_meta_box_content () {
1572
+	public function lesson_quiz_meta_box_content() {
1573 1573
 		global $post;
1574 1574
 
1575 1575
 		// Get quiz panel
1576 1576
 		$quiz_id = 0;
1577 1577
 		$quizzes = array();
1578
-		if ( 0 < $post->ID ) {
1579
-			$quiz_id = $this->lesson_quizzes( $post->ID, 'any' );
1578
+		if (0 < $post->ID) {
1579
+			$quiz_id = $this->lesson_quizzes($post->ID, 'any');
1580 1580
 		}
1581 1581
 
1582
-		echo $this->quiz_panel( $quiz_id );
1582
+		echo $this->quiz_panel($quiz_id);
1583 1583
 
1584 1584
 	} // End lesson_quiz_meta_box_content()
1585 1585
 
@@ -1596,53 +1596,53 @@  discard block
 block discarded – undo
1596 1596
 		$quiz_id = 0;
1597 1597
 		$lesson_id = $post->ID;
1598 1598
 		$quizzes = array();
1599
-		if ( 0 < $lesson_id ) {
1600
-			$quiz_id = $this->lesson_quizzes( $lesson_id, 'any' );
1599
+		if (0 < $lesson_id) {
1600
+			$quiz_id = $this->lesson_quizzes($lesson_id, 'any');
1601 1601
 		}
1602 1602
 
1603
-		if( $quiz_id ) {
1604
-			$html .= $this->quiz_settings_panel( $lesson_id, $quiz_id );
1603
+		if ($quiz_id) {
1604
+			$html .= $this->quiz_settings_panel($lesson_id, $quiz_id);
1605 1605
 		} else {
1606
-			$html .= '<p><em>' . __( 'There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei' ) . '</em></p>';
1606
+			$html .= '<p><em>'.__('There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei').'</em></p>';
1607 1607
 		}
1608 1608
 
1609 1609
 		echo $html;
1610 1610
 	}
1611 1611
 
1612
-	public function quiz_settings_panel( $lesson_id = 0, $quiz_id = 0 ) {
1612
+	public function quiz_settings_panel($lesson_id = 0, $quiz_id = 0) {
1613 1613
 
1614 1614
 
1615 1615
 		$html = '';
1616 1616
 
1617
-		if( ! $lesson_id && ! $quiz_id ) return $html;
1617
+		if ( ! $lesson_id && ! $quiz_id) return $html;
1618 1618
 
1619
-		$settings = $this->get_quiz_settings( $quiz_id );
1619
+		$settings = $this->get_quiz_settings($quiz_id);
1620 1620
 
1621
-		$html = Sensei()->admin->render_settings( $settings, $quiz_id, 'quiz-settings' );
1621
+		$html = Sensei()->admin->render_settings($settings, $quiz_id, 'quiz-settings');
1622 1622
 
1623 1623
 		return $html;
1624 1624
 
1625 1625
 	}
1626 1626
 
1627
-	public function get_quiz_settings( $quiz_id = 0 ) {
1627
+	public function get_quiz_settings($quiz_id = 0) {
1628 1628
 
1629 1629
 		$disable_passmark = '';
1630
-		$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
1631
-		if( ! $pass_required ) {
1630
+		$pass_required = get_post_meta($quiz_id, '_pass_required', true);
1631
+		if ( ! $pass_required) {
1632 1632
 			$disable_passmark = 'hidden';
1633 1633
 		}
1634 1634
 
1635 1635
 		// Setup Questions Query
1636 1636
 		$questions = array();
1637
-		if ( 0 < $quiz_id ) {
1638
-			$questions = $this->lesson_quiz_questions( $quiz_id );
1637
+		if (0 < $quiz_id) {
1638
+			$questions = $this->lesson_quiz_questions($quiz_id);
1639 1639
 		}
1640 1640
 
1641 1641
 		// Count questions
1642 1642
 		$question_count = 0;
1643
-		foreach( $questions as $question ) {
1644
-			if( $question->post_type == 'multiple_question' ) {
1645
-				$question_number = get_post_meta( $question->ID, 'number', true );
1643
+		foreach ($questions as $question) {
1644
+			if ($question->post_type == 'multiple_question') {
1645
+				$question_number = get_post_meta($question->ID, 'number', true);
1646 1646
 				$question_count += $question_number;
1647 1647
 			} else {
1648 1648
 				++$question_count;
@@ -1652,15 +1652,15 @@  discard block
 block discarded – undo
1652 1652
 		$settings = array(
1653 1653
 			array(
1654 1654
 				'id' 			=> 'pass_required',
1655
-				'label'			=> __( 'Pass required to complete lesson', 'woothemes-sensei' ),
1656
-				'description'	=> __( 'The passmark must be achieved before the lesson is complete.', 'woothemes-sensei' ),
1655
+				'label'			=> __('Pass required to complete lesson', 'woothemes-sensei'),
1656
+				'description'	=> __('The passmark must be achieved before the lesson is complete.', 'woothemes-sensei'),
1657 1657
 				'type'			=> 'checkbox',
1658 1658
 				'default'		=> '',
1659 1659
 				'checked'		=> 'on',
1660 1660
 			),
1661 1661
 			array(
1662 1662
 				'id' 			=> 'quiz_passmark',
1663
-				'label'			=> __( 'Quiz passmark percentage', 'woothemes-sensei' ),
1663
+				'label'			=> __('Quiz passmark percentage', 'woothemes-sensei'),
1664 1664
 				'description'	=> '',
1665 1665
 				'type'			=> 'number',
1666 1666
 				'default'		=> 0,
@@ -1671,17 +1671,17 @@  discard block
 block discarded – undo
1671 1671
 			),
1672 1672
 			array(
1673 1673
 				'id' 			=> 'show_questions',
1674
-				'label'			=> __( 'Number of questions to show', 'woothemes-sensei' ),
1675
-				'description'	=> __( 'Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei' ),
1674
+				'label'			=> __('Number of questions to show', 'woothemes-sensei'),
1675
+				'description'	=> __('Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei'),
1676 1676
 				'type'			=> 'number',
1677 1677
 				'default'		=> '',
1678
-				'placeholder'	=> __( 'All', 'woothemes-sensei' ),
1678
+				'placeholder'	=> __('All', 'woothemes-sensei'),
1679 1679
 				'min'			=> 1,
1680 1680
 				'max'			=> $question_count,
1681 1681
 			),
1682 1682
 			array(
1683 1683
 				'id' 			=> 'random_question_order',
1684
-				'label'			=> __( 'Randomise question order', 'woothemes-sensei' ),
1684
+				'label'			=> __('Randomise question order', 'woothemes-sensei'),
1685 1685
 				'description'	=> '',
1686 1686
 				'type'			=> 'checkbox',
1687 1687
 				'default'		=> 'no',
@@ -1689,23 +1689,23 @@  discard block
 block discarded – undo
1689 1689
 			),
1690 1690
 			array(
1691 1691
 				'id' 			=> 'quiz_grade_type',
1692
-				'label'			=> __( 'Grade quiz automatically', 'woothemes-sensei' ),
1693
-				'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' ),
1692
+				'label'			=> __('Grade quiz automatically', 'woothemes-sensei'),
1693
+				'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'),
1694 1694
 				'type'			=> 'checkbox',
1695 1695
 				'default'		=> 'auto',
1696 1696
 				'checked'		=> 'auto',
1697 1697
 			),
1698 1698
 			array(
1699 1699
 				'id' 			=> 'enable_quiz_reset',
1700
-				'label'			=> __( 'Allow user to retake the quiz', 'woothemes-sensei' ),
1701
-				'description'	=> __( 'Enables the quiz reset button.', 'woothemes-sensei' ),
1700
+				'label'			=> __('Allow user to retake the quiz', 'woothemes-sensei'),
1701
+				'description'	=> __('Enables the quiz reset button.', 'woothemes-sensei'),
1702 1702
 				'type'			=> 'checkbox',
1703 1703
 				'default'		=> '',
1704 1704
 				'checked'		=> 'on',
1705 1705
 			),
1706 1706
 		);
1707 1707
 
1708
-		return apply_filters( 'sensei_quiz_settings', $settings );
1708
+		return apply_filters('sensei_quiz_settings', $settings);
1709 1709
 	}
1710 1710
 
1711 1711
 	/**
@@ -1714,38 +1714,38 @@  discard block
 block discarded – undo
1714 1714
 	 * @access public
1715 1715
 	 * @return void
1716 1716
 	 */
1717
-	public function enqueue_scripts( $hook ) {
1717
+	public function enqueue_scripts($hook) {
1718 1718
 		global  $post_type;
1719 1719
 
1720
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) );
1721
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
1722
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order' ) );
1720
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question'));
1721
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
1722
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order'));
1723 1723
 
1724 1724
 		// Test for Write Panel Pages
1725
-		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 ) ) ) {
1725
+		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))) {
1726 1726
 
1727
-			$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
1727
+			$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
1728 1728
 
1729 1729
 			// Load the lessons script
1730 1730
             wp_enqueue_media();
1731
-			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 );
1732
-			wp_enqueue_script( 'sensei-lesson-chosen', Sensei()->plugin_url . 'assets/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1733
-			wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'sensei-lesson-chosen' ), Sensei()->version, true );
1731
+			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);
1732
+			wp_enqueue_script('sensei-lesson-chosen', Sensei()->plugin_url.'assets/chosen/chosen.jquery'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1733
+			wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery'.$suffix.'.js', array('jquery', 'sensei-lesson-chosen'), Sensei()->version, true);
1734 1734
 
1735 1735
             // Load the bulk edit screen script
1736
-            if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) {
1737
-                wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true);
1736
+            if ('edit.php' == $hook && 'lesson' == $_GET['post_type']) {
1737
+                wp_enqueue_script('sensei-lessons-bulk-edit', Sensei()->plugin_url.'assets/js/admin/lesson-bulk-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1738 1738
             }
1739 1739
 
1740 1740
 			// Localise script
1741
-			$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' ) );
1742
-			$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' ) );
1743
-			$data = array_merge( $translation_strings, $ajax_vars );
1744
-			wp_localize_script( 'sensei-lesson-metadata', 'woo_localized_data', $data );
1741
+			$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'));
1742
+			$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'));
1743
+			$data = array_merge($translation_strings, $ajax_vars);
1744
+			wp_localize_script('sensei-lesson-metadata', 'woo_localized_data', $data);
1745 1745
 
1746 1746
 			// Chosen RTL
1747
-			if ( is_rtl() ) {
1748
-				wp_enqueue_script( 'sensei-chosen-rtl', Sensei()->plugin_url . 'assets/chosen/chosen-rtl' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1747
+			if (is_rtl()) {
1748
+				wp_enqueue_script('sensei-chosen-rtl', Sensei()->plugin_url.'assets/chosen/chosen-rtl'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1749 1749
 			}
1750 1750
 
1751 1751
 		}
@@ -1759,16 +1759,16 @@  discard block
 block discarded – undo
1759 1759
 	 * @since  1.4.0
1760 1760
 	 * @return void
1761 1761
 	 */
1762
-	public function enqueue_styles ( $hook ) {
1762
+	public function enqueue_styles($hook) {
1763 1763
 		global  $post_type;
1764 1764
 
1765
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question', 'sensei_message' ) );
1766
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
1767
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings' ) );
1765
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question', 'sensei_message'));
1766
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
1767
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings'));
1768 1768
 
1769 1769
 		// Test for Write Panel Pages
1770
-		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 ) ) ) {
1771
-			wp_enqueue_style( 'woothemes-sensei-settings-api', esc_url( Sensei()->plugin_url . 'assets/css/settings.css' ), '', Sensei()->version );
1770
+		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))) {
1771
+			wp_enqueue_style('woothemes-sensei-settings-api', esc_url(Sensei()->plugin_url.'assets/css/settings.css'), '', Sensei()->version);
1772 1772
 		}
1773 1773
 
1774 1774
 	} // End enqueue_styles()
@@ -1780,12 +1780,12 @@  discard block
 block discarded – undo
1780 1780
 	 * @param  array $defaults
1781 1781
 	 * @return array $new_columns
1782 1782
 	 */
1783
-	public function add_column_headings ( $defaults ) {
1783
+	public function add_column_headings($defaults) {
1784 1784
 		$new_columns['cb'] = '<input type="checkbox" />';
1785
-		$new_columns['title'] = _x( 'Lesson Title', 'column name', 'woothemes-sensei' );
1786
-		$new_columns['lesson-course'] = _x( 'Course', 'column name', 'woothemes-sensei' );
1787
-		$new_columns['lesson-prerequisite'] = _x( 'Pre-requisite Lesson', 'column name', 'woothemes-sensei' );
1788
-		if ( isset( $defaults['date'] ) ) {
1785
+		$new_columns['title'] = _x('Lesson Title', 'column name', 'woothemes-sensei');
1786
+		$new_columns['lesson-course'] = _x('Course', 'column name', 'woothemes-sensei');
1787
+		$new_columns['lesson-prerequisite'] = _x('Pre-requisite Lesson', 'column name', 'woothemes-sensei');
1788
+		if (isset($defaults['date'])) {
1789 1789
 			$new_columns['date'] = $defaults['date'];
1790 1790
 		}
1791 1791
 		return $new_columns;
@@ -1799,23 +1799,23 @@  discard block
 block discarded – undo
1799 1799
 	 * @param  int $id
1800 1800
 	 * @return void
1801 1801
 	 */
1802
-	public function add_column_data ( $column_name, $id ) {
1802
+	public function add_column_data($column_name, $id) {
1803 1803
 		global $wpdb, $post;
1804 1804
 
1805
-		switch ( $column_name ) {
1805
+		switch ($column_name) {
1806 1806
 			case 'id':
1807 1807
 				echo $id;
1808 1808
 			break;
1809 1809
 			case 'lesson-course':
1810
-				$lesson_course_id = get_post_meta( $id, '_lesson_course', true);
1811
-				if ( 0 < absint( $lesson_course_id ) ) {
1812
-					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>';
1810
+				$lesson_course_id = get_post_meta($id, '_lesson_course', true);
1811
+				if (0 < absint($lesson_course_id)) {
1812
+					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>';
1813 1813
 				} // End If Statement
1814 1814
 			break;
1815 1815
 			case 'lesson-prerequisite':
1816
-				$lesson_prerequisite_id = get_post_meta( $id, '_lesson_prerequisite', true);
1817
-				if ( 0 < absint( $lesson_prerequisite_id ) ) {
1818
-					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>';
1816
+				$lesson_prerequisite_id = get_post_meta($id, '_lesson_prerequisite', true);
1817
+				if (0 < absint($lesson_prerequisite_id)) {
1818
+					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>';
1819 1819
 				} // End If Statement
1820 1820
 			break;
1821 1821
 			default:
@@ -1829,14 +1829,14 @@  discard block
 block discarded – undo
1829 1829
 	 * @access public
1830 1830
 	 * @return void
1831 1831
 	 */
1832
-	public function lesson_add_course () {
1832
+	public function lesson_add_course() {
1833 1833
 		global $current_user;
1834 1834
 		//Add nonce security to the request
1835
-		if ( isset($_POST['lesson_add_course_nonce']) ) {
1836
-			$nonce = esc_html( $_POST['lesson_add_course_nonce'] );
1835
+		if (isset($_POST['lesson_add_course_nonce'])) {
1836
+			$nonce = esc_html($_POST['lesson_add_course_nonce']);
1837 1837
 		} // End If Statement
1838
-		if ( ! wp_verify_nonce( $nonce, 'lesson_add_course_nonce' )
1839
-            || ! current_user_can( 'edit_lessons' ) ) {
1838
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_course_nonce')
1839
+            || ! current_user_can('edit_lessons')) {
1840 1840
 			die('');
1841 1841
 		} // End If Statement
1842 1842
 		// Parse POST data
@@ -1858,14 +1858,14 @@  discard block
 block discarded – undo
1858 1858
 	 * @access public
1859 1859
 	 * @return void
1860 1860
 	 */
1861
-	public function lesson_update_question () {
1861
+	public function lesson_update_question() {
1862 1862
 		global $current_user;
1863 1863
 		//Add nonce security to the request
1864
-		if ( isset($_POST['lesson_update_question_nonce']) ) {
1865
-			$nonce = esc_html( $_POST['lesson_update_question_nonce'] );
1864
+		if (isset($_POST['lesson_update_question_nonce'])) {
1865
+			$nonce = esc_html($_POST['lesson_update_question_nonce']);
1866 1866
 		} // End If Statement
1867
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_nonce' )
1868
-            ||  ! current_user_can( 'edit_questions' )) {
1867
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_nonce')
1868
+            ||  ! current_user_can('edit_questions')) {
1869 1869
 
1870 1870
 			die('');
1871 1871
 
@@ -1875,30 +1875,30 @@  discard block
 block discarded – undo
1875 1875
 		// WP slashes all incoming data regardless of Magic Quotes setting (see wp_magic_quotes()), which means that
1876 1876
 		// even the $_POST['data'] encoded with encodeURIComponent has it's apostrophes slashed.
1877 1877
 		// So first restore the original unslashed apostrophes by removing those slashes
1878
-		$data = wp_unslash( $_POST['data'] );
1878
+		$data = wp_unslash($_POST['data']);
1879 1879
 		// Then parse the string to an array (note that parse_str automatically urldecodes all the variables)
1880 1880
 		$question_data = array();
1881 1881
 		parse_str($data, $question_data);
1882 1882
 		// Finally re-slash all elements to ensure consistancy for lesson_save_question()
1883
-		$question_data = wp_slash( $question_data );
1883
+		$question_data = wp_slash($question_data);
1884 1884
 		// Save the question
1885 1885
 		$return = false;
1886 1886
 		// Question Save and Delete logic
1887
-		if ( isset( $question_data['action'] ) && ( $question_data['action'] == 'delete' ) ) {
1887
+		if (isset($question_data['action']) && ($question_data['action'] == 'delete')) {
1888 1888
 			// Delete the Question
1889 1889
 			$return = $this->lesson_delete_question($question_data);
1890 1890
 		} else {
1891 1891
 			// Save the Question
1892
-			if ( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) {
1892
+			if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) {
1893 1893
 				$current_user = wp_get_current_user();
1894 1894
 				$question_data['post_author'] = $current_user->ID;
1895
-				$question_id = $this->lesson_save_question( $question_data );
1896
-				$question_type = Sensei()->question->get_question_type( $question_id );
1895
+				$question_id = $this->lesson_save_question($question_data);
1896
+				$question_type = Sensei()->question->get_question_type($question_id);
1897 1897
 
1898
-				$question_count = intval( $question_data['question_count'] );
1898
+				$question_count = intval($question_data['question_count']);
1899 1899
 				++$question_count;
1900 1900
 
1901
-				$return = $this->quiz_panel_question( $question_type, $question_count, $question_id );
1901
+				$return = $this->quiz_panel_question($question_type, $question_count, $question_id);
1902 1902
 			} // End If Statement
1903 1903
 		} // End If Statement
1904 1904
 
@@ -1913,49 +1913,49 @@  discard block
 block discarded – undo
1913 1913
 
1914 1914
 		//Add nonce security to the request
1915 1915
 		$nonce = '';
1916
-		if( isset( $_POST['lesson_add_multiple_questions_nonce'] ) ) {
1917
-			$nonce = esc_html( $_POST['lesson_add_multiple_questions_nonce'] );
1916
+		if (isset($_POST['lesson_add_multiple_questions_nonce'])) {
1917
+			$nonce = esc_html($_POST['lesson_add_multiple_questions_nonce']);
1918 1918
 		} // End If Statement
1919 1919
 
1920
-		if( ! wp_verify_nonce( $nonce, 'lesson_add_multiple_questions_nonce' )
1921
-            || ! current_user_can( 'edit_lessons' ) ) {
1922
-			die( $return );
1920
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_multiple_questions_nonce')
1921
+            || ! current_user_can('edit_lessons')) {
1922
+			die($return);
1923 1923
 		} // End If Statement
1924 1924
 
1925 1925
 		// Parse POST data
1926 1926
 		$data = $_POST['data'];
1927 1927
 		$question_data = array();
1928
-		parse_str( $data, $question_data );
1928
+		parse_str($data, $question_data);
1929 1929
 
1930
-		if( is_array( $question_data ) ) {
1931
-			if( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) {
1930
+		if (is_array($question_data)) {
1931
+			if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) {
1932 1932
 
1933
-				$quiz_id = intval( $question_data['quiz_id'] );
1934
-				$question_number = intval( $question_data['question_number'] );
1935
-				$question_category = intval( $question_data['question_category'] );
1933
+				$quiz_id = intval($question_data['quiz_id']);
1934
+				$question_number = intval($question_data['question_number']);
1935
+				$question_category = intval($question_data['question_category']);
1936 1936
 
1937
-				$question_counter = intval( $question_data['question_count'] );
1937
+				$question_counter = intval($question_data['question_count']);
1938 1938
 				++$question_counter;
1939 1939
 
1940
-				$cat = get_term( $question_category, 'question-category' );
1940
+				$cat = get_term($question_category, 'question-category');
1941 1941
 
1942 1942
 				$post_data = array(
1943 1943
 					'post_content' => '',
1944 1944
 					'post_status' => 'publish',
1945
-					'post_title' => sprintf( __( '%1$s Question(s) from %2$s', 'woothemes-sensei' ), $question_number, $cat->name ),
1945
+					'post_title' => sprintf(__('%1$s Question(s) from %2$s', 'woothemes-sensei'), $question_number, $cat->name),
1946 1946
 					'post_type' => 'multiple_question'
1947 1947
 				);
1948 1948
 
1949
-				$multiple_id = wp_insert_post( $post_data );
1949
+				$multiple_id = wp_insert_post($post_data);
1950 1950
 
1951
-				if( $multiple_id && ! is_wp_error( $multiple_id ) ) {
1952
-					add_post_meta( $multiple_id, 'category', $question_category );
1953
-					add_post_meta( $multiple_id, 'number', $question_number );
1954
-					add_post_meta( $multiple_id, '_quiz_id', $quiz_id, false );
1955
-					add_post_meta( $multiple_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_counter );
1956
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
1957
-					update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
1958
-					$return = $this->quiz_panel_question( 'category', $question_counter, $multiple_id, 'quiz', array( $cat->name, $question_number ) );
1951
+				if ($multiple_id && ! is_wp_error($multiple_id)) {
1952
+					add_post_meta($multiple_id, 'category', $question_category);
1953
+					add_post_meta($multiple_id, 'number', $question_number);
1954
+					add_post_meta($multiple_id, '_quiz_id', $quiz_id, false);
1955
+					add_post_meta($multiple_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_counter);
1956
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
1957
+					update_post_meta($lesson_id, '_quiz_has_questions', '1');
1958
+					$return = $this->quiz_panel_question('category', $question_counter, $multiple_id, 'quiz', array($cat->name, $question_number));
1959 1959
 				}
1960 1960
 			}
1961 1961
 		}
@@ -1969,25 +1969,25 @@  discard block
 block discarded – undo
1969 1969
 
1970 1970
 		//Add nonce security to the request
1971 1971
 		$nonce = '';
1972
-		if( isset( $_POST['lesson_remove_multiple_questions_nonce'] ) ) {
1973
-			$nonce = esc_html( $_POST['lesson_remove_multiple_questions_nonce'] );
1972
+		if (isset($_POST['lesson_remove_multiple_questions_nonce'])) {
1973
+			$nonce = esc_html($_POST['lesson_remove_multiple_questions_nonce']);
1974 1974
 		} // End If Statement
1975 1975
 
1976
-		if( ! wp_verify_nonce( $nonce, 'lesson_remove_multiple_questions_nonce' )
1977
-        || ! current_user_can( 'edit_lessons' ) ) {
1976
+		if ( ! wp_verify_nonce($nonce, 'lesson_remove_multiple_questions_nonce')
1977
+        || ! current_user_can('edit_lessons')) {
1978 1978
 			die('');
1979 1979
 		} // End If Statement
1980 1980
 
1981 1981
 		// Parse POST data
1982 1982
 		$data = $_POST['data'];
1983 1983
 		$question_data = array();
1984
-		parse_str( $data, $question_data );
1984
+		parse_str($data, $question_data);
1985 1985
 
1986
-		if( is_array( $question_data ) ) {
1987
-			wp_delete_post( $question_data['question_id'], true );
1986
+		if (is_array($question_data)) {
1987
+			wp_delete_post($question_data['question_id'], true);
1988 1988
 		}
1989 1989
 
1990
-		die( 'Deleted' );
1990
+		die('Deleted');
1991 1991
 	}
1992 1992
 
1993 1993
 	public function get_question_category_limit() {
@@ -1998,11 +1998,11 @@  discard block
 block discarded – undo
1998 1998
 		// Parse POST data
1999 1999
 		$data = $_POST['data'];
2000 2000
 		$cat_data = array();
2001
-		parse_str( $data, $cat_data );
2001
+		parse_str($data, $cat_data);
2002 2002
 
2003
-		if( isset( $cat_data['cat'] ) && '' != $cat_data['cat'] ) {
2004
-			$cat = get_term( $cat_data['cat'], 'question-category' );
2005
-			if( isset( $cat->count ) ) {
2003
+		if (isset($cat_data['cat']) && '' != $cat_data['cat']) {
2004
+			$cat = get_term($cat_data['cat'], 'question-category');
2005
+			if (isset($cat->count)) {
2006 2006
 				$return = $cat->count;
2007 2007
 			}
2008 2008
 		}
@@ -2016,45 +2016,45 @@  discard block
 block discarded – undo
2016 2016
 
2017 2017
 		//Add nonce security to the request
2018 2018
 		$nonce = '';
2019
-		if( isset( $_POST['lesson_add_existing_questions_nonce'] ) ) {
2020
-			$nonce = esc_html( $_POST['lesson_add_existing_questions_nonce'] );
2019
+		if (isset($_POST['lesson_add_existing_questions_nonce'])) {
2020
+			$nonce = esc_html($_POST['lesson_add_existing_questions_nonce']);
2021 2021
 		} // End If Statement
2022 2022
 
2023
-		if( ! wp_verify_nonce( $nonce, 'lesson_add_existing_questions_nonce' )
2024
-        || ! current_user_can( 'edit_lessons' ) ) {
2023
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_existing_questions_nonce')
2024
+        || ! current_user_can('edit_lessons')) {
2025 2025
 			die('');
2026 2026
 		} // End If Statement
2027 2027
 
2028 2028
 		// Parse POST data
2029 2029
 		$data = $_POST['data'];
2030 2030
 		$question_data = array();
2031
-		parse_str( $data, $question_data );
2031
+		parse_str($data, $question_data);
2032 2032
 
2033 2033
 		$return = '';
2034 2034
 
2035
-		if( is_array( $question_data ) ) {
2035
+		if (is_array($question_data)) {
2036 2036
 
2037
-			if( isset( $question_data['questions'] ) && '' != $question_data['questions'] ) {
2037
+			if (isset($question_data['questions']) && '' != $question_data['questions']) {
2038 2038
 
2039
-				$questions = explode( ',', trim( $question_data['questions'], ',' ) );
2039
+				$questions = explode(',', trim($question_data['questions'], ','));
2040 2040
 				$quiz_id = $question_data['quiz_id'];
2041
-				$question_count = intval( $question_data['question_count'] );
2041
+				$question_count = intval($question_data['question_count']);
2042 2042
 
2043
-				foreach( $questions as $question_id ) {
2043
+				foreach ($questions as $question_id) {
2044 2044
 
2045 2045
 					++$question_count;
2046 2046
 
2047
-					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2048
-					if( ! in_array( $quiz_id, $quizzes ) ) {
2049
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2050
-						$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2051
-						update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2047
+					$quizzes = get_post_meta($question_id, '_quiz_id', false);
2048
+					if ( ! in_array($quiz_id, $quizzes)) {
2049
+			    		add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2050
+						$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
2051
+						update_post_meta($lesson_id, '_quiz_has_questions', '1');
2052 2052
 			    	}
2053 2053
 
2054
-			    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2055
-					$question_type = Sensei()->question->get_question_type( $question_id );
2054
+			    	add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count);
2055
+					$question_type = Sensei()->question->get_question_type($question_id);
2056 2056
 
2057
-					$return .= $this->quiz_panel_question( $question_type, $question_count, $question_id );
2057
+					$return .= $this->quiz_panel_question($question_type, $question_count, $question_id);
2058 2058
 				}
2059 2059
 			}
2060 2060
 		}
@@ -2066,14 +2066,14 @@  discard block
 block discarded – undo
2066 2066
 
2067 2067
 	public function lesson_update_grade_type() {
2068 2068
 		//Add nonce security to the request
2069
-		if ( isset($_POST['lesson_update_grade_type_nonce']) ) {
2069
+		if (isset($_POST['lesson_update_grade_type_nonce'])) {
2070 2070
 
2071
-			$nonce = esc_html( $_POST['lesson_update_grade_type_nonce'] );
2071
+			$nonce = esc_html($_POST['lesson_update_grade_type_nonce']);
2072 2072
 
2073 2073
 		} // End If Statement
2074 2074
 
2075
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_grade_type_nonce' )
2076
-        || ! current_user_can( 'edit_lessons' ) ) {
2075
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_grade_type_nonce')
2076
+        || ! current_user_can('edit_lessons')) {
2077 2077
 
2078 2078
 			die('');
2079 2079
 
@@ -2083,18 +2083,18 @@  discard block
 block discarded – undo
2083 2083
 		$data = $_POST['data'];
2084 2084
 		$quiz_data = array();
2085 2085
 		parse_str($data, $quiz_data);
2086
-		update_post_meta( $quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type'] );
2086
+		update_post_meta($quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type']);
2087 2087
 		die();
2088 2088
 	}
2089 2089
 
2090 2090
 	public function lesson_update_question_order() {
2091 2091
 		// Add nonce security to the request
2092
-		if ( isset($_POST['lesson_update_question_order_nonce']) ) {
2093
-			$nonce = esc_html( $_POST['lesson_update_question_order_nonce'] );
2092
+		if (isset($_POST['lesson_update_question_order_nonce'])) {
2093
+			$nonce = esc_html($_POST['lesson_update_question_order_nonce']);
2094 2094
 		} // End If Statement
2095 2095
 
2096
-        if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_nonce' )
2097
-            ||! current_user_can( 'edit_lessons' ) ) {
2096
+        if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_nonce')
2097
+            ||! current_user_can('edit_lessons')) {
2098 2098
 			die('');
2099 2099
 		} // End If Statement
2100 2100
 
@@ -2102,25 +2102,25 @@  discard block
 block discarded – undo
2102 2102
 		$data = $_POST['data'];
2103 2103
 		$quiz_data = array();
2104 2104
 		parse_str($data, $quiz_data);
2105
-		if( strlen( $quiz_data['question_order'] ) > 0 ) {
2106
-			$questions = explode( ',', $quiz_data['question_order'] );
2105
+		if (strlen($quiz_data['question_order']) > 0) {
2106
+			$questions = explode(',', $quiz_data['question_order']);
2107 2107
 			$o = 1;
2108
-			foreach( $questions as $question_id ) {
2109
-				update_post_meta( $question_id, '_quiz_question_order' . $quiz_data['quiz_id'], $quiz_data['quiz_id'] . '000' . $o );
2108
+			foreach ($questions as $question_id) {
2109
+				update_post_meta($question_id, '_quiz_question_order'.$quiz_data['quiz_id'], $quiz_data['quiz_id'].'000'.$o);
2110 2110
 				++$o;
2111 2111
 			}
2112
-			update_post_meta( $quiz_data['quiz_id'], '_question_order', $questions );
2112
+			update_post_meta($quiz_data['quiz_id'], '_question_order', $questions);
2113 2113
 		}
2114 2114
 		die();
2115 2115
 	}
2116 2116
 
2117 2117
 	public function lesson_update_question_order_random() {
2118 2118
 		//Add nonce security to the request
2119
-		if ( isset($_POST['lesson_update_question_order_random_nonce']) ) {
2120
-			$nonce = esc_html( $_POST['lesson_update_question_order_random_nonce'] );
2119
+		if (isset($_POST['lesson_update_question_order_random_nonce'])) {
2120
+			$nonce = esc_html($_POST['lesson_update_question_order_random_nonce']);
2121 2121
 		} // End If Statement
2122
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_random_nonce' )
2123
-            || ! current_user_can( 'edit_lessons' ) ) {
2122
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_random_nonce')
2123
+            || ! current_user_can('edit_lessons')) {
2124 2124
 
2125 2125
 			die('');
2126 2126
 
@@ -2129,7 +2129,7 @@  discard block
 block discarded – undo
2129 2129
 		$data = $_POST['data'];
2130 2130
 		$quiz_data = array();
2131 2131
 		parse_str($data, $quiz_data);
2132
-		update_post_meta( $quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order'] );
2132
+		update_post_meta($quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order']);
2133 2133
 		die();
2134 2134
 	}
2135 2135
 
@@ -2140,7 +2140,7 @@  discard block
 block discarded – undo
2140 2140
 	 * @param array $data (default: array())
2141 2141
 	 * @return integer|boolean $course_id or false
2142 2142
 	 */
2143
-	private function lesson_save_course( $data = array() ) {
2143
+	private function lesson_save_course($data = array()) {
2144 2144
 		global $current_user;
2145 2145
 		$return = false;
2146 2146
 		// Setup the course data
@@ -2149,58 +2149,58 @@  discard block
 block discarded – undo
2149 2149
 		$course_title = '';
2150 2150
 		$course_prerequisite = 0;
2151 2151
 		$course_category = 0;
2152
-		if ( isset( $data[ 'course_id' ] ) && ( 0 < absint( $data[ 'course_id' ] ) ) ) {
2153
-			$course_id = absint( $data[ 'course_id' ] );
2152
+		if (isset($data['course_id']) && (0 < absint($data['course_id']))) {
2153
+			$course_id = absint($data['course_id']);
2154 2154
 		} // End If Statement
2155
-		if ( isset( $data[ 'course_title' ] ) && ( '' != $data[ 'course_title' ] ) ) {
2156
-			$course_title = $data[ 'course_title' ];
2155
+		if (isset($data['course_title']) && ('' != $data['course_title'])) {
2156
+			$course_title = $data['course_title'];
2157 2157
 		} // End If Statement
2158 2158
 		$post_title = $course_title;
2159
-		if ( isset($data[ 'post_author' ]) ) {
2160
-			$post_author = $data[ 'post_author' ];
2159
+		if (isset($data['post_author'])) {
2160
+			$post_author = $data['post_author'];
2161 2161
 		} else {
2162 2162
 			$current_user = wp_get_current_user();
2163 2163
 			$post_author = $current_user->ID;
2164 2164
 		} // End If Statement
2165 2165
 		$post_status = 'publish';
2166 2166
 		$post_type = 'course';
2167
-		if ( isset( $data[ 'course_content' ] ) && ( '' != $data[ 'course_content' ] ) ) {
2168
-			$course_content = $data[ 'course_content' ];
2167
+		if (isset($data['course_content']) && ('' != $data['course_content'])) {
2168
+			$course_content = $data['course_content'];
2169 2169
 		} // End If Statement
2170 2170
 		$post_content = $course_content;
2171 2171
 		// Course Query Arguments
2172
-		$post_type_args = array(	'post_content' => $post_content,
2172
+		$post_type_args = array('post_content' => $post_content,
2173 2173
   		    						'post_status' => $post_status,
2174 2174
   		    						'post_title' => $post_title,
2175 2175
   		    						'post_type' => $post_type
2176 2176
   		    						);
2177 2177
   		// Only save if there is a valid title
2178
-  		if ( $post_title != '' ) {
2178
+  		if ($post_title != '') {
2179 2179
   		    // Check for prerequisite courses & product id
2180
-  		    $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2181
-  		    $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2182
-  		    $course_category_id = absint( $data[ 'course_category' ] );
2183
-  		    if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2180
+  		    $course_prerequisite_id = absint($data['course_prerequisite']);
2181
+  		    $course_woocommerce_product_id = absint($data['course_woocommerce_product']);
2182
+  		    $course_category_id = absint($data['course_category']);
2183
+  		    if (0 == $course_woocommerce_product_id) { $course_woocommerce_product_id = '-'; }
2184 2184
   		    // Insert or Update the Lesson Quiz
2185
-		    if ( 0 < $course_id ) {
2186
-		    	$post_type_args[ 'ID' ] = $course_id;
2185
+		    if (0 < $course_id) {
2186
+		    	$post_type_args['ID'] = $course_id;
2187 2187
 		    	$course_id = wp_update_post($post_type_args);
2188
-		    	update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2189
-		    	update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2190
-		    	if ( 0 < $course_category_id ) {
2191
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2188
+		    	update_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id);
2189
+		    	update_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id);
2190
+		    	if (0 < $course_category_id) {
2191
+		    		wp_set_object_terms($course_id, $course_category_id, 'course-category');
2192 2192
 		    	} // End If Statement
2193 2193
 		    } else {
2194 2194
 		    	$course_id = wp_insert_post($post_type_args);
2195
-		    	add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2196
-		    	add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2197
-		    	if ( 0 < $course_category_id ) {
2198
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2195
+		    	add_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id);
2196
+		    	add_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id);
2197
+		    	if (0 < $course_category_id) {
2198
+		    		wp_set_object_terms($course_id, $course_category_id, 'course-category');
2199 2199
 		    	} // End If Statement
2200 2200
 		    } // End If Statement
2201 2201
 		} // End If Statement
2202 2202
   		// Check that the insert or update saved by testing the post id
2203
-  		if ( 0 < $course_id ) {
2203
+  		if (0 < $course_id) {
2204 2204
   			$return = $course_id;
2205 2205
   		} // End If Statement
2206 2206
   		return $return;
@@ -2214,7 +2214,7 @@  discard block
 block discarded – undo
2214 2214
 	 * @param array $data (default: array())
2215 2215
 	 * @return integer|boolean $question_id or false
2216 2216
 	 */
2217
-	public function lesson_save_question( $data = array(), $context = 'quiz' ) {
2217
+	public function lesson_save_question($data = array(), $context = 'quiz') {
2218 2218
 		$return = false;
2219 2219
 		// Save the Questions
2220 2220
 		// Setup the Question data
@@ -2226,130 +2226,130 @@  discard block
 block discarded – undo
2226 2226
 		$question_category = '';
2227 2227
 
2228 2228
 		// Handle Question Type
2229
-		if ( isset( $data[ 'question_type' ] ) && ( '' != $data[ 'question_type' ] ) ) {
2230
-			$question_type = $data[ 'question_type' ];
2229
+		if (isset($data['question_type']) && ('' != $data['question_type'])) {
2230
+			$question_type = $data['question_type'];
2231 2231
 		} // End If Statement
2232 2232
 
2233
-		if ( isset( $data[ 'question_category' ] ) && ( '' != $data[ 'question_category' ] ) ) {
2234
-			$question_category = $data[ 'question_category' ];
2233
+		if (isset($data['question_category']) && ('' != $data['question_category'])) {
2234
+			$question_category = $data['question_category'];
2235 2235
 		} // End If Statement
2236 2236
 
2237
-		if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) {
2238
-			$question_id = absint( $data[ 'question_id' ] );
2237
+		if (isset($data['question_id']) && (0 < absint($data['question_id']))) {
2238
+			$question_id = absint($data['question_id']);
2239 2239
 		} // End If Statement
2240
-		if ( isset( $data[ 'question' ] ) && ( '' != $data[ 'question' ] ) ) {
2241
-			$question_text = $data[ 'question' ];
2240
+		if (isset($data['question']) && ('' != $data['question'])) {
2241
+			$question_text = $data['question'];
2242 2242
 		} // End If Statement
2243 2243
 		$post_title = $question_text;
2244 2244
 		// Handle Default Fields (multiple choice)
2245
-		if ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answers' ] ) && ( '' != $data[ 'question_right_answers' ] ) ) {
2246
-			$question_right_answers = $data[ 'question_right_answers' ];
2245
+		if ('multiple-choice' == $question_type && isset($data['question_right_answers']) && ('' != $data['question_right_answers'])) {
2246
+			$question_right_answers = $data['question_right_answers'];
2247 2247
 		} // End If Statement
2248
-		elseif ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answer' ] ) && ( '' != $data[ 'question_right_answer' ] ) ) {
2249
-			$question_right_answer = $data[ 'question_right_answer' ];
2248
+		elseif ('multiple-choice' == $question_type && isset($data['question_right_answer']) && ('' != $data['question_right_answer'])) {
2249
+			$question_right_answer = $data['question_right_answer'];
2250 2250
 		} // End If Statement
2251
-		if ( 'multiple-choice' == $question_type && isset( $data[ 'question_wrong_answers' ] ) && ( '' != $data[ 'question_wrong_answers' ] ) ) {
2252
-			$question_wrong_answers = $data[ 'question_wrong_answers' ];
2251
+		if ('multiple-choice' == $question_type && isset($data['question_wrong_answers']) && ('' != $data['question_wrong_answers'])) {
2252
+			$question_wrong_answers = $data['question_wrong_answers'];
2253 2253
 		} // End If Statement
2254 2254
 		// Handle Boolean Fields - Edit
2255
-		if ( 'boolean' == $question_type && isset( $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) && ( '' != $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) ) {
2256
-			$question_right_answer = $data[ 'question_' . $question_id . '_right_answer_boolean' ];
2255
+		if ('boolean' == $question_type && isset($data['question_'.$question_id.'_right_answer_boolean']) && ('' != $data['question_'.$question_id.'_right_answer_boolean'])) {
2256
+			$question_right_answer = $data['question_'.$question_id.'_right_answer_boolean'];
2257 2257
 		} // End If Statement
2258 2258
 		// Handle Boolean Fields - Add
2259
-		if ( 'boolean' == $question_type && isset( $data[ 'question_right_answer_boolean' ] ) && ( '' != $data[ 'question_right_answer_boolean' ] ) ) {
2260
-			$question_right_answer = $data[ 'question_right_answer_boolean' ];
2259
+		if ('boolean' == $question_type && isset($data['question_right_answer_boolean']) && ('' != $data['question_right_answer_boolean'])) {
2260
+			$question_right_answer = $data['question_right_answer_boolean'];
2261 2261
 		} // End If Statement
2262 2262
 		// Handle Gap Fill Fields
2263
-		if ( 'gap-fill' == $question_type && isset( $data[ 'add_question_right_answer_gapfill_gap' ] ) && '' != $data[ 'add_question_right_answer_gapfill_gap' ] ) {
2264
-			$question_right_answer = $data[ 'add_question_right_answer_gapfill_pre' ] . '||' . $data[ 'add_question_right_answer_gapfill_gap' ] . '||' . $data[ 'add_question_right_answer_gapfill_post' ];
2263
+		if ('gap-fill' == $question_type && isset($data['add_question_right_answer_gapfill_gap']) && '' != $data['add_question_right_answer_gapfill_gap']) {
2264
+			$question_right_answer = $data['add_question_right_answer_gapfill_pre'].'||'.$data['add_question_right_answer_gapfill_gap'].'||'.$data['add_question_right_answer_gapfill_post'];
2265 2265
 		} // End If Statement
2266 2266
 		// Handle Multi Line Fields
2267
-		if ( 'multi-line' == $question_type && isset( $data[ 'add_question_right_answer_multiline' ] ) && ( '' != $data[ 'add_question_right_answer_multiline' ] ) ) {
2268
-			$question_right_answer = $data[ 'add_question_right_answer_multiline' ];
2267
+		if ('multi-line' == $question_type && isset($data['add_question_right_answer_multiline']) && ('' != $data['add_question_right_answer_multiline'])) {
2268
+			$question_right_answer = $data['add_question_right_answer_multiline'];
2269 2269
 		} // End If Statement
2270 2270
 		// Handle Single Line Fields
2271
-		if ( 'single-line' == $question_type && isset( $data[ 'add_question_right_answer_singleline' ] ) && ( '' != $data[ 'add_question_right_answer_singleline' ] ) ) {
2272
-			$question_right_answer = $data[ 'add_question_right_answer_singleline' ];
2271
+		if ('single-line' == $question_type && isset($data['add_question_right_answer_singleline']) && ('' != $data['add_question_right_answer_singleline'])) {
2272
+			$question_right_answer = $data['add_question_right_answer_singleline'];
2273 2273
 		} // End If Statement
2274 2274
 		// Handle File Upload Fields
2275
-		if ( 'file-upload' == $question_type && isset( $data[ 'add_question_right_answer_fileupload' ] ) && ( '' != $data[ 'add_question_right_answer_fileupload' ] ) ) {
2276
-			$question_right_answer = $data[ 'add_question_right_answer_fileupload' ];
2275
+		if ('file-upload' == $question_type && isset($data['add_question_right_answer_fileupload']) && ('' != $data['add_question_right_answer_fileupload'])) {
2276
+			$question_right_answer = $data['add_question_right_answer_fileupload'];
2277 2277
 		} // End If Statement
2278
-		if ( 'file-upload' == $question_type && isset( $data[ 'add_question_wrong_answer_fileupload' ] ) && ( '' != $data[ 'add_question_wrong_answer_fileupload' ] ) ) {
2279
-			$question_wrong_answers = array( $data[ 'add_question_wrong_answer_fileupload' ] );
2278
+		if ('file-upload' == $question_type && isset($data['add_question_wrong_answer_fileupload']) && ('' != $data['add_question_wrong_answer_fileupload'])) {
2279
+			$question_wrong_answers = array($data['add_question_wrong_answer_fileupload']);
2280 2280
 		} // End If Statement
2281 2281
 
2282 2282
 		// Handle Question Grade
2283
-		if ( isset( $data[ 'question_grade' ] ) && ( '' != $data[ 'question_grade' ] ) ) {
2284
-			$question_grade = $data[ 'question_grade' ];
2283
+		if (isset($data['question_grade']) && ('' != $data['question_grade'])) {
2284
+			$question_grade = $data['question_grade'];
2285 2285
 		} // End If Statement
2286 2286
 
2287 2287
 		// Handle Answer Feedback
2288 2288
 		$answer_feedback = '';
2289
-		if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) {
2289
+		if (isset($data['answer_feedback_boolean']) && ! empty($data['answer_feedback_boolean'])) {
2290 2290
 
2291
-            $answer_feedback = $data[ 'answer_feedback_boolean' ];
2291
+            $answer_feedback = $data['answer_feedback_boolean'];
2292 2292
 
2293
-		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2293
+		}elseif (isset($data['answer_feedback_multiple_choice']) && ! empty($data['answer_feedback_multiple_choice'])) {
2294 2294
 
2295
-            $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2295
+            $answer_feedback = $data['answer_feedback_multiple_choice'];
2296 2296
 
2297
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2297
+        }elseif (isset($data['answer_feedback'])) {
2298 2298
 
2299
-            $answer_feedback = $data[ 'answer_feedback' ];
2299
+            $answer_feedback = $data['answer_feedback'];
2300 2300
 
2301 2301
         } // End If Statement
2302 2302
 
2303 2303
 		$post_title = $question_text;
2304
-		$post_author = $data[ 'post_author' ];
2304
+		$post_author = $data['post_author'];
2305 2305
 		$post_status = 'publish';
2306 2306
 		$post_type = 'question';
2307 2307
 		// Handle the extended question text
2308
-		if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) {
2309
-			$post_content = $data[ 'question_description' ];
2308
+		if (isset($data['question_description']) && ('' != $data['question_description'])) {
2309
+			$post_content = $data['question_description'];
2310 2310
 		}
2311 2311
 		else {
2312 2312
 			$post_content = '';
2313 2313
 		}
2314 2314
 		// Question Query Arguments
2315
-		$post_type_args = array(	'post_content' => $post_content,
2315
+		$post_type_args = array('post_content' => $post_content,
2316 2316
   		    						'post_status' => $post_status,
2317 2317
   		    						'post_title' => $post_title,
2318 2318
   		    						'post_type' => $post_type
2319 2319
   		    						);
2320 2320
 
2321 2321
   		// Remove empty values and reindex the array
2322
-  		if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) {
2323
-  			$question_right_answers_array = array_values( array_filter( $question_right_answers, 'strlen' ) );
2322
+  		if (is_array($question_right_answers) && 0 < count($question_right_answers)) {
2323
+  			$question_right_answers_array = array_values(array_filter($question_right_answers, 'strlen'));
2324 2324
   			$question_right_answers = array();
2325 2325
 
2326
-  			foreach( $question_right_answers_array as $answer ) {
2327
-  				if( ! in_array( $answer, $question_right_answers ) ) {
2326
+  			foreach ($question_right_answers_array as $answer) {
2327
+  				if ( ! in_array($answer, $question_right_answers)) {
2328 2328
   					$question_right_answers[] = $answer;
2329 2329
   				}
2330 2330
   			}
2331
-  			if ( 0 < count($question_right_answers) ) {
2331
+  			if (0 < count($question_right_answers)) {
2332 2332
   				$question_right_answer = $question_right_answers;
2333 2333
   			}
2334 2334
   		} // End If Statement
2335
-  		$right_answer_count = count( $question_right_answer );
2335
+  		$right_answer_count = count($question_right_answer);
2336 2336
 
2337 2337
 		// Remove empty values and reindex the array
2338
-  		if ( is_array( $question_wrong_answers ) ) {
2339
-  			$question_wrong_answers_array = array_values( array_filter( $question_wrong_answers, 'strlen' ) );
2338
+  		if (is_array($question_wrong_answers)) {
2339
+  			$question_wrong_answers_array = array_values(array_filter($question_wrong_answers, 'strlen'));
2340 2340
   			$question_wrong_answers = array();
2341 2341
   		} // End If Statement
2342 2342
 
2343
-  		foreach( $question_wrong_answers_array as $answer ) {
2344
-  			if( ! in_array( $answer, $question_wrong_answers ) ) {
2343
+  		foreach ($question_wrong_answers_array as $answer) {
2344
+  			if ( ! in_array($answer, $question_wrong_answers)) {
2345 2345
   				$question_wrong_answers[] = $answer;
2346 2346
   			}
2347 2347
   		}
2348 2348
 
2349
-  		$wrong_answer_count = count( $question_wrong_answers );
2349
+  		$wrong_answer_count = count($question_wrong_answers);
2350 2350
 
2351 2351
   		// Only save if there is a valid title
2352
-  		if ( $post_title != '' ) {
2352
+  		if ($post_title != '') {
2353 2353
 
2354 2354
   			// Get Quiz ID for the question
2355 2355
   		    $quiz_id = $data['quiz_id'];
@@ -2359,86 +2359,86 @@  discard block
 block discarded – undo
2359 2359
 
2360 2360
   		    // Get answer order
2361 2361
   		    $answer_order = '';
2362
-  		    if( isset( $data['answer_order'] ) ) {
2362
+  		    if (isset($data['answer_order'])) {
2363 2363
 				$answer_order = $data['answer_order'];
2364 2364
 			}
2365 2365
 
2366 2366
 			// Get random order selection
2367 2367
 			$random_order = 'no';
2368
-			if( isset( $data['random_order'] ) ) {
2368
+			if (isset($data['random_order'])) {
2369 2369
 				$random_order = $data['random_order'];
2370 2370
 			}
2371 2371
 
2372 2372
   		    // Insert or Update the question
2373
-  		    if ( 0 < $question_id ) {
2373
+  		    if (0 < $question_id) {
2374 2374
 
2375
-  		    	$post_type_args[ 'ID' ] = $question_id;
2376
-		    	$question_id = wp_update_post( $post_type_args );
2375
+  		    	$post_type_args['ID'] = $question_id;
2376
+		    	$question_id = wp_update_post($post_type_args);
2377 2377
 
2378 2378
 		    	// Update poast meta
2379
-		    	if( 'quiz' == $context ) {
2380
-		    		$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2381
-		    		if( ! in_array( $quiz_id, $quizzes ) ) {
2382
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2379
+		    	if ('quiz' == $context) {
2380
+		    		$quizzes = get_post_meta($question_id, '_quiz_id', false);
2381
+		    		if ( ! in_array($quiz_id, $quizzes)) {
2382
+			    		add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2383 2383
 			    	}
2384 2384
 		    	}
2385 2385
 
2386
-		    	update_post_meta( $question_id, '_question_grade', $question_grade );
2387
-		    	update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2388
-		    	update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2389
-		    	update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2390
-		    	update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2391
-		    	update_post_meta( $question_id, '_question_media', $question_media );
2392
-		    	update_post_meta( $question_id, '_answer_order', $answer_order );
2393
-		    	update_post_meta( $question_id, '_random_order', $random_order );
2394
-
2395
-		    	if( 'quiz' != $context ) {
2396
-		    		wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2386
+		    	update_post_meta($question_id, '_question_grade', $question_grade);
2387
+		    	update_post_meta($question_id, '_question_right_answer', $question_right_answer);
2388
+		    	update_post_meta($question_id, '_right_answer_count', $right_answer_count);
2389
+		    	update_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers);
2390
+		    	update_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count);
2391
+		    	update_post_meta($question_id, '_question_media', $question_media);
2392
+		    	update_post_meta($question_id, '_answer_order', $answer_order);
2393
+		    	update_post_meta($question_id, '_random_order', $random_order);
2394
+
2395
+		    	if ('quiz' != $context) {
2396
+		    		wp_set_post_terms($question_id, array($question_type), 'question-type', false);
2397 2397
 		    	}
2398 2398
 				// Don't store empty value, no point
2399
-				if ( !empty($answer_feedback) ) {
2400
-					update_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2399
+				if ( ! empty($answer_feedback)) {
2400
+					update_post_meta($question_id, '_answer_feedback', $answer_feedback);
2401 2401
 				}
2402 2402
 
2403 2403
 		    } else {
2404
-				$question_id = wp_insert_post( $post_type_args );
2405
-				$question_count = intval( $data['question_count'] );
2404
+				$question_id = wp_insert_post($post_type_args);
2405
+				$question_count = intval($data['question_count']);
2406 2406
 				++$question_count;
2407 2407
 
2408 2408
 				// Set post meta
2409
-				if( 'quiz' == $context ) {
2410
-					add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2411
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2412
-					update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2409
+				if ('quiz' == $context) {
2410
+					add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2411
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
2412
+					update_post_meta($lesson_id, '_quiz_has_questions', '1');
2413 2413
 				}
2414 2414
 
2415
-				if( isset( $question_grade ) ) {
2416
-		    		add_post_meta( $question_id, '_question_grade', $question_grade );
2415
+				if (isset($question_grade)) {
2416
+		    		add_post_meta($question_id, '_question_grade', $question_grade);
2417 2417
 		    	}
2418
-		    	add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2419
-		    	add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2420
-		    	add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2421
-		    	add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2422
-		    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2423
-		    	add_post_meta( $question_id, '_question_media', $question_media );
2424
-		    	add_post_meta( $question_id, '_answer_order', $answer_order );
2425
-		    	add_post_meta( $question_id, '_random_order', $random_order );
2418
+		    	add_post_meta($question_id, '_question_right_answer', $question_right_answer);
2419
+		    	add_post_meta($question_id, '_right_answer_count', $right_answer_count);
2420
+		    	add_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers);
2421
+		    	add_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count);
2422
+		    	add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count);
2423
+		    	add_post_meta($question_id, '_question_media', $question_media);
2424
+		    	add_post_meta($question_id, '_answer_order', $answer_order);
2425
+		    	add_post_meta($question_id, '_random_order', $random_order);
2426 2426
 				// Don't store empty value, no point
2427
-				if ( !empty($answer_feedback) ) {
2428
-					add_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2427
+				if ( ! empty($answer_feedback)) {
2428
+					add_post_meta($question_id, '_answer_feedback', $answer_feedback);
2429 2429
 				}
2430 2430
 
2431 2431
 		    	// Set the post terms for question-type
2432
-			    wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2432
+			    wp_set_post_terms($question_id, array($question_type), 'question-type');
2433 2433
 
2434
-			    if( $question_category ) {
2435
-	    			wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2434
+			    if ($question_category) {
2435
+	    			wp_set_post_terms($question_id, array($question_category), 'question-category');
2436 2436
 	    		}
2437 2437
 
2438 2438
 		    } // End If Statement
2439 2439
 		} // End If Statement
2440 2440
   		// Check that the insert or update saved by testing the post id
2441
-  		if ( 0 < $question_id ) {
2441
+  		if (0 < $question_id) {
2442 2442
   			$return = $question_id;
2443 2443
   		} // End If Statement
2444 2444
   		return $return;
@@ -2452,20 +2452,20 @@  discard block
 block discarded – undo
2452 2452
 	 * @param array $data (default: array())
2453 2453
 	 * @return boolean
2454 2454
 	 */
2455
-	private function lesson_delete_question( $data = array() ) {
2455
+	private function lesson_delete_question($data = array()) {
2456 2456
 
2457 2457
 		// Get which question to delete
2458 2458
 		$question_id = 0;
2459
-		if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) {
2460
-			$question_id = absint( $data[ 'question_id' ] );
2459
+		if (isset($data['question_id']) && (0 < absint($data['question_id']))) {
2460
+			$question_id = absint($data['question_id']);
2461 2461
 		} // End If Statement
2462 2462
 		// Delete the question
2463
-		if ( 0 < $question_id ) {
2464
-			$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2463
+		if (0 < $question_id) {
2464
+			$quizzes = get_post_meta($question_id, '_quiz_id', false);
2465 2465
 
2466
-			foreach( $quizzes as $quiz_id ) {
2467
-				if( $quiz_id == $data['quiz_id'] ) {
2468
-					delete_post_meta( $question_id, '_quiz_id', $quiz_id );
2466
+			foreach ($quizzes as $quiz_id) {
2467
+				if ($quiz_id == $data['quiz_id']) {
2468
+					delete_post_meta($question_id, '_quiz_id', $quiz_id);
2469 2469
 				}
2470 2470
 			}
2471 2471
 
@@ -2484,9 +2484,9 @@  discard block
 block discarded – undo
2484 2484
 	public function lesson_complexities() {
2485 2485
 
2486 2486
 		// V2 - make filter for this array
2487
-        $lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2488
-									'std' => __( 'Standard', 'woothemes-sensei' ),
2489
-									'hard' => __( 'Hard', 'woothemes-sensei' )
2487
+        $lesson_complexities = array('easy' => __('Easy', 'woothemes-sensei'),
2488
+									'std' => __('Standard', 'woothemes-sensei'),
2489
+									'hard' => __('Hard', 'woothemes-sensei')
2490 2490
 									);
2491 2491
 
2492 2492
 		return $lesson_complexities;
@@ -2501,9 +2501,9 @@  discard block
 block discarded – undo
2501 2501
 	 * @param string $post_status (default: 'publish')
2502 2502
 	 * @return int
2503 2503
 	 */
2504
-	public function lesson_count( $post_status = 'publish', $course_id = false ) {
2504
+	public function lesson_count($post_status = 'publish', $course_id = false) {
2505 2505
 
2506
-		$post_args = array(	'post_type'         => 'lesson',
2506
+		$post_args = array('post_type'         => 'lesson',
2507 2507
 							'posts_per_page'    => -1,
2508 2508
 //							'orderby'           => 'menu_order date',
2509 2509
 //							'order'             => 'ASC',
@@ -2511,7 +2511,7 @@  discard block
 block discarded – undo
2511 2511
 							'suppress_filters'  => 0,
2512 2512
 							'fields'            => 'ids',
2513 2513
 							);
2514
-		if( $course_id ) {
2514
+		if ($course_id) {
2515 2515
 			$post_args['meta_query'][] = array(
2516 2516
 				'key' => '_lesson_course',
2517 2517
 				'value' => $course_id,
@@ -2528,10 +2528,10 @@  discard block
 block discarded – undo
2528 2528
 
2529 2529
 		// Allow WP to generate the complex final query, just shortcut to only do an overall count
2530 2530
 //		add_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
2531
-		$lessons_query = new WP_Query( apply_filters( 'sensei_lesson_count', $post_args ) );
2531
+		$lessons_query = new WP_Query(apply_filters('sensei_lesson_count', $post_args));
2532 2532
 //		remove_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
2533 2533
 
2534
-		return count( $lessons_query->posts );
2534
+		return count($lessons_query->posts);
2535 2535
 	} // End lesson_count()
2536 2536
 
2537 2537
 
@@ -2544,11 +2544,11 @@  discard block
 block discarded – undo
2544 2544
 	 * @param string $fields (default: 'ids')
2545 2545
 	 * @return int $quiz_id
2546 2546
 	 */
2547
-	public function lesson_quizzes( $lesson_id = 0, $post_status = 'any', $fields = 'ids' ) {
2547
+	public function lesson_quizzes($lesson_id = 0, $post_status = 'any', $fields = 'ids') {
2548 2548
 
2549 2549
 		$posts_array = array();
2550 2550
 
2551
-		$post_args = array(	'post_type' 		=> 'quiz',
2551
+		$post_args = array('post_type' 		=> 'quiz',
2552 2552
 							'posts_per_page' 		=> 1,
2553 2553
 							'orderby'         	=> 'title',
2554 2554
     						'order'           	=> 'DESC',
@@ -2557,7 +2557,7 @@  discard block
 block discarded – undo
2557 2557
 							'suppress_filters' 	=> 0,
2558 2558
 							'fields'            => $fields
2559 2559
 							);
2560
-		$posts_array = get_posts( $post_args );
2560
+		$posts_array = get_posts($post_args);
2561 2561
         $quiz_id = array_shift($posts_array);
2562 2562
 
2563 2563
 		return $quiz_id;
@@ -2580,37 +2580,37 @@  discard block
 block discarded – undo
2580 2580
      *
2581 2581
 	 * @return array $questions { $question type WP_Post }
2582 2582
 	 */
2583
-	public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) {
2583
+	public function lesson_quiz_questions($quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC') {
2584 2584
 
2585 2585
 		$quiz_id = (string) $quiz_id;
2586
-        $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2586
+        $quiz_lesson_id = Sensei()->quiz->get_lesson_id($quiz_id);
2587 2587
 
2588 2588
         // setup the user id
2589
-        if( is_admin() ) {
2590
-            $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2589
+        if (is_admin()) {
2590
+            $user_id = isset($_GET['user']) ? $_GET['user'] : '';
2591 2591
         } else {
2592 2592
             $user_id = get_current_user_id();
2593 2593
         }
2594 2594
 
2595 2595
         // get the users current status on the lesson
2596
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2596
+        $user_lesson_status = Sensei_Utils::user_lesson_status($quiz_lesson_id, $user_id);
2597 2597
 
2598 2598
 		// Set the default question order if it has not already been set for this quiz
2599
-		$this->set_default_question_order( $quiz_id );
2599
+		$this->set_default_question_order($quiz_id);
2600 2600
 
2601 2601
 		// If viewing quiz on the frontend then show questions in random order if set
2602
-		if ( ! is_admin() ) {
2603
-			$random_order = get_post_meta( $quiz_id, '_random_question_order', true );
2604
-			if( $random_order && $random_order == 'yes' ) {
2602
+		if ( ! is_admin()) {
2603
+			$random_order = get_post_meta($quiz_id, '_random_question_order', true);
2604
+			if ($random_order && $random_order == 'yes') {
2605 2605
 				$orderby = 'rand';
2606 2606
 			}
2607 2607
 		}
2608 2608
 
2609 2609
 		// Get all questions and multiple questions
2610 2610
 		$question_query_args = array(
2611
-			'post_type' 		=> array( 'question', 'multiple_question' ),
2611
+			'post_type' 		=> array('question', 'multiple_question'),
2612 2612
 			'posts_per_page' 	=> -1,
2613
-			'meta_key'        	=> '_quiz_question_order' . $quiz_id,
2613
+			'meta_key'        	=> '_quiz_question_order'.$quiz_id,
2614 2614
 			'orderby'         	=> $orderby,
2615 2615
 			'order'           	=> $order,
2616 2616
 			'meta_query'		=> array(
@@ -2624,7 +2624,7 @@  discard block
 block discarded – undo
2624 2624
 		);
2625 2625
 
2626 2626
         //query the questions
2627
-		$questions_query = new WP_Query( $question_query_args );
2627
+		$questions_query = new WP_Query($question_query_args);
2628 2628
 
2629 2629
         // Set return array to initially include all items
2630 2630
         $questions = $questions_query->posts;
@@ -2634,20 +2634,20 @@  discard block
 block discarded – undo
2634 2634
 
2635 2635
 		// If viewing quiz on frontend or in grading then only single questions must be shown
2636 2636
 		$selected_questions = false;
2637
-		if( ! is_admin() || ( is_admin() && isset( $_GET['page'] ) && 'sensei_grading' == $_GET['page'] && isset( $_GET['user'] ) && isset( $_GET['quiz_id'] ) ) ) {
2637
+		if ( ! is_admin() || (is_admin() && isset($_GET['page']) && 'sensei_grading' == $_GET['page'] && isset($_GET['user']) && isset($_GET['quiz_id']))) {
2638 2638
 
2639 2639
 			// Fetch the questions that the user was asked in their quiz if they have already completed it
2640
-			$questions_asked_string = !empty( $user_lesson_status->comment_ID) ? get_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', true ) : false;
2641
-			if( !empty($questions_asked_string) ) {
2640
+			$questions_asked_string = ! empty($user_lesson_status->comment_ID) ? get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true) : false;
2641
+			if ( ! empty($questions_asked_string)) {
2642 2642
 
2643
-				$selected_questions = explode( ',', $questions_asked_string );
2643
+				$selected_questions = explode(',', $questions_asked_string);
2644 2644
 
2645 2645
 				// Fetch each question in the order in which they were asked
2646 2646
 				$questions = array();
2647
-				foreach( $selected_questions as $question_id ) {
2648
-					if( ! $question_id ) continue;
2649
-					$question = get_post( $question_id );
2650
-					if( ! isset( $question ) || ! isset( $question->ID ) ) continue;
2647
+				foreach ($selected_questions as $question_id) {
2648
+					if ( ! $question_id) continue;
2649
+					$question = get_post($question_id);
2650
+					if ( ! isset($question) || ! isset($question->ID)) continue;
2651 2651
 					$questions[] = $question;
2652 2652
 				}
2653 2653
 
@@ -2659,24 +2659,24 @@  discard block
 block discarded – undo
2659 2659
 				$existing_questions = array();
2660 2660
 
2661 2661
 				// Set array of questions that already exist so we can prevent duplicates from appearing
2662
-				foreach( $questions_array as $question ) {
2663
-					if( 'question' != $question->post_type ) continue;
2662
+				foreach ($questions_array as $question) {
2663
+					if ('question' != $question->post_type) continue;
2664 2664
 					$existing_questions[] = $question->ID;
2665 2665
 				}
2666 2666
 
2667 2667
 				// Include only single questions in the return array
2668 2668
 				$questions_loop = $questions_array;
2669 2669
 				$questions_array = array();
2670
-				foreach( $questions_loop as $k => $question ) {
2670
+				foreach ($questions_loop as $k => $question) {
2671 2671
 
2672 2672
 					// If this is a single question then include it
2673
-					if( 'question' == $question->post_type ) {
2673
+					if ('question' == $question->post_type) {
2674 2674
 						$questions_array[] = $question;
2675 2675
 					} else {
2676 2676
 
2677 2677
 						// If this is a multiple question then get the specified amount of questions from the specified category
2678
-						$question_cat = intval( get_post_meta( $question->ID, 'category', true ) );
2679
-						$question_number = intval( get_post_meta( $question->ID, 'number', true ) );
2678
+						$question_cat = intval(get_post_meta($question->ID, 'category', true));
2679
+						$question_number = intval(get_post_meta($question->ID, 'number', true));
2680 2680
 
2681 2681
 						$qargs = array(
2682 2682
 							'post_type' 		=> 'question',
@@ -2693,14 +2693,14 @@  discard block
 block discarded – undo
2693 2693
 							'suppress_filters' 	=> 0,
2694 2694
 							'post__not_in'		=> $existing_questions,
2695 2695
 						);
2696
-						$cat_questions = get_posts( $qargs );
2696
+						$cat_questions = get_posts($qargs);
2697 2697
 
2698 2698
 						// Merge results into return array
2699
-						$questions_array = array_merge( $questions_array, $cat_questions );
2699
+						$questions_array = array_merge($questions_array, $cat_questions);
2700 2700
 
2701 2701
 						// Add selected questions to existing questions array to prevent duplicates from being added
2702
-						foreach( $questions_array as $cat_question ) {
2703
-							if( in_array( $cat_question->ID, $existing_questions ) ) continue;
2702
+						foreach ($questions_array as $cat_question) {
2703
+							if (in_array($cat_question->ID, $existing_questions)) continue;
2704 2704
 							$existing_questions[] = $cat_question->ID;
2705 2705
 						}
2706 2706
 					}
@@ -2712,29 +2712,29 @@  discard block
 block discarded – undo
2712 2712
 		}
2713 2713
 
2714 2714
 		// 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
2715
-		if( ! $selected_questions ) {
2715
+		if ( ! $selected_questions) {
2716 2716
 
2717 2717
 			// Only limit questions like this on the frontend
2718
-			if( ! is_admin() ) {
2718
+			if ( ! is_admin()) {
2719 2719
 
2720 2720
 				// Get number of questions to show
2721
-				$show_questions = intval( get_post_meta( $quiz_id, '_show_questions', true ) );
2722
-				if( $show_questions ) {
2721
+				$show_questions = intval(get_post_meta($quiz_id, '_show_questions', true));
2722
+				if ($show_questions) {
2723 2723
 
2724 2724
 					// Get random set of array keys from selected questions array
2725
-					$selected_questions = array_rand( $questions_array, $show_questions );
2725
+					$selected_questions = array_rand($questions_array, $show_questions);
2726 2726
 
2727 2727
 					// Loop through all questions and pick the the ones to be shown based on the random key selection
2728 2728
 					$questions = array();
2729
-					foreach( $questions_array as $k => $question ) {
2729
+					foreach ($questions_array as $k => $question) {
2730 2730
 
2731 2731
 						// Random keys will always be an array, unless only one question is to be shown
2732
-						if( is_array( $selected_questions ) ) {
2733
-							if( in_array( $k, $selected_questions ) ) {
2732
+						if (is_array($selected_questions)) {
2733
+							if (in_array($k, $selected_questions)) {
2734 2734
 								$questions[] = $question;
2735 2735
 							}
2736
-						} elseif( 1 == $show_questions ) {
2737
-							if ( $selected_questions == $k ) {
2736
+						} elseif (1 == $show_questions) {
2737
+							if ($selected_questions == $k) {
2738 2738
 								$questions[] = $question;
2739 2739
 							}
2740 2740
 						}
@@ -2745,12 +2745,12 @@  discard block
 block discarded – undo
2745 2745
 
2746 2746
         // Save the questions that will be asked for the current user
2747 2747
         // this happens only once per user/quiz, unless the user resets the quiz
2748
-        if( ! is_admin() ){
2748
+        if ( ! is_admin()) {
2749 2749
 
2750
-            if( $user_lesson_status ) {
2750
+            if ($user_lesson_status) {
2751 2751
 
2752 2752
                 $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2753
-                if ( empty($questions_asked) && $user_lesson_status) {
2753
+                if (empty($questions_asked) && $user_lesson_status) {
2754 2754
 
2755 2755
                     $questions_asked = array();
2756 2756
                     foreach ($questions as $question) {
@@ -2773,7 +2773,7 @@  discard block
 block discarded – undo
2773 2773
          * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2774 2774
          * @since 1.8.0
2775 2775
          */
2776
-		return apply_filters( 'sensei_lesson_quiz_questions', $questions,  $quiz_id  );
2776
+		return apply_filters('sensei_lesson_quiz_questions', $questions, $quiz_id);
2777 2777
 
2778 2778
 	} // End lesson_quiz_questions()
2779 2779
 
@@ -2781,13 +2781,13 @@  discard block
 block discarded – undo
2781 2781
 	 * Set the default quiz order
2782 2782
 	 * @param integer $quiz_id ID of quiz
2783 2783
 	 */
2784
-	public function set_default_question_order( $quiz_id = 0 ) {
2784
+	public function set_default_question_order($quiz_id = 0) {
2785 2785
 
2786
-		if( $quiz_id ) {
2786
+		if ($quiz_id) {
2787 2787
 
2788
-			$question_order = get_post_meta( $quiz_id, '_question_order', true );
2788
+			$question_order = get_post_meta($quiz_id, '_question_order', true);
2789 2789
 
2790
-			if( ! $question_order ) {
2790
+			if ( ! $question_order) {
2791 2791
 
2792 2792
 				$args = array(
2793 2793
 					'post_type' 		=> 'question',
@@ -2803,11 +2803,11 @@  discard block
 block discarded – undo
2803 2803
 					'post_status'		=> 'any',
2804 2804
 					'suppress_filters' 	=> 0
2805 2805
 				);
2806
-				$questions = get_posts( $args );
2806
+				$questions = get_posts($args);
2807 2807
 
2808 2808
 				$o = 1;
2809
-				foreach( $questions as $question ) {
2810
-					add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $o, true );
2809
+				foreach ($questions as $question) {
2810
+					add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$o, true);
2811 2811
 					$o++;
2812 2812
 				}
2813 2813
 			}
@@ -2826,36 +2826,36 @@  discard block
 block discarded – undo
2826 2826
 	 * @param string $height (default: '100')
2827 2827
 	 * @return string
2828 2828
 	 */
2829
-	public function lesson_image( $lesson_id = 0, $width = '100', $height = '100', $widget = false ) {
2829
+	public function lesson_image($lesson_id = 0, $width = '100', $height = '100', $widget = false) {
2830 2830
 
2831 2831
 		$html = '';
2832 2832
 
2833 2833
 		// Get Width and Height settings
2834
-		if ( ( $width == '100' ) && ( $height == '100' ) ) {
2834
+		if (($width == '100') && ($height == '100')) {
2835 2835
 
2836
-			if ( is_singular( 'lesson' ) ) {
2836
+			if (is_singular('lesson')) {
2837 2837
 
2838
-				if ( ! $widget && ! Sensei()->settings->settings[ 'lesson_single_image_enable' ] ) {
2838
+				if ( ! $widget && ! Sensei()->settings->settings['lesson_single_image_enable']) {
2839 2839
 
2840 2840
 					return '';
2841 2841
 
2842 2842
 				} // End If Statement
2843 2843
 
2844 2844
 				$image_thumb_size = 'lesson_single_image';
2845
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
2845
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
2846 2846
 				$width = $dimensions['width'];
2847 2847
 				$height = $dimensions['height'];
2848 2848
 				$crop = $dimensions['crop'];
2849 2849
 
2850 2850
 			} else {
2851 2851
 
2852
-				if ( ! $widget && ! Sensei()->settings->settings[ 'course_lesson_image_enable' ] ) {
2852
+				if ( ! $widget && ! Sensei()->settings->settings['course_lesson_image_enable']) {
2853 2853
 
2854 2854
 					return '';
2855 2855
 				} // End If Statement
2856 2856
 
2857 2857
 				$image_thumb_size = 'lesson_archive_image';
2858
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
2858
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
2859 2859
 				$width = $dimensions['width'];
2860 2860
 				$height = $dimensions['height'];
2861 2861
 				$crop = $dimensions['crop'];
@@ -2866,23 +2866,23 @@  discard block
 block discarded – undo
2866 2866
 
2867 2867
 		$img_url = '';
2868 2868
 
2869
-		if ( has_post_thumbnail( $lesson_id ) ) {
2869
+		if (has_post_thumbnail($lesson_id)) {
2870 2870
 
2871 2871
    			// Get Featured Image
2872
-   			$img_url = get_the_post_thumbnail( $lesson_id, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') );
2872
+   			$img_url = get_the_post_thumbnail($lesson_id, array($width, $height), array('class' => 'woo-image thumbnail alignleft'));
2873 2873
 
2874 2874
  		} else {
2875 2875
 
2876 2876
  			// Display Image Placeholder if none
2877
-			if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) {
2877
+			if (Sensei()->settings->settings['placeholder_images_enable']) {
2878 2878
 
2879
-                $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2879
+                $img_url = apply_filters('sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/'.$width.'x'.$height.'" class="woo-image thumbnail alignleft" />');
2880 2880
 
2881 2881
 			} // End If Statement
2882 2882
 
2883 2883
 		} // End If Statement
2884 2884
 
2885
-		$html .= '<a href="' . get_permalink( $lesson_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $lesson_id ) ) . '">' . $img_url . '</a>';
2885
+		$html .= '<a href="'.get_permalink($lesson_id).'" title="'.esc_attr(get_post_field('post_title', $lesson_id)).'">'.$img_url.'</a>';
2886 2886
 
2887 2887
 		return $html;
2888 2888
 
@@ -2894,9 +2894,9 @@  discard block
 block discarded – undo
2894 2894
      * @since 1.9.0
2895 2895
      * @param integer $lesson_id
2896 2896
      */
2897
-    public static function the_lesson_image( $lesson_id = 0 ){
2897
+    public static function the_lesson_image($lesson_id = 0) {
2898 2898
 
2899
-        echo Sensei()->lesson->lesson_image( $lesson_id );
2899
+        echo Sensei()->lesson->lesson_image($lesson_id);
2900 2900
 
2901 2901
     }
2902 2902
 
@@ -2907,17 +2907,17 @@  discard block
 block discarded – undo
2907 2907
      * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2908 2908
 	 * @return string
2909 2909
 	 */
2910
-	public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) {
2910
+	public static function lesson_excerpt($lesson = null, $add_p_tags = true) {
2911 2911
 		$html = '';
2912
-		if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) {
2912
+		if (is_a($lesson, 'WP_Post') && 'lesson' == $lesson->post_type) {
2913 2913
 
2914
-            $excerpt =  $lesson->post_excerpt;
2914
+            $excerpt = $lesson->post_excerpt;
2915 2915
 
2916 2916
             // if $add_p_tags true wrap with <p> else return the excerpt as is
2917
-            $html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2917
+            $html = $add_p_tags ? wpautop($excerpt) : $excerpt;
2918 2918
 
2919 2919
 		}
2920
-		return apply_filters( 'sensei_lesson_excerpt', $html );
2920
+		return apply_filters('sensei_lesson_excerpt', $html);
2921 2921
 
2922 2922
 	} // End lesson_excerpt()
2923 2923
 
@@ -2930,20 +2930,20 @@  discard block
 block discarded – undo
2930 2930
      * @param int $lesson_id
2931 2931
      * @return int|bool $course_id or bool when nothing is found.
2932 2932
      */
2933
-     public function get_course_id( $lesson_id ){
2933
+     public function get_course_id($lesson_id) {
2934 2934
 
2935
-         if( ! isset( $lesson_id ) || empty( $lesson_id )
2936
-         ||  'lesson' != get_post_type( $lesson_id ) ){
2935
+         if ( ! isset($lesson_id) || empty($lesson_id)
2936
+         ||  'lesson' != get_post_type($lesson_id)) {
2937 2937
              return false;
2938 2938
          }
2939 2939
 
2940
-         $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2940
+         $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
2941 2941
 
2942 2942
          // make sure the course id is valid
2943
-         if( empty( $lesson_course_id )
2944
-             || is_array( $lesson_course_id )
2945
-             || intval( $lesson_course_id ) < 1
2946
-             || 'course' != get_post_type( $lesson_course_id ) ){
2943
+         if (empty($lesson_course_id)
2944
+             || is_array($lesson_course_id)
2945
+             || intval($lesson_course_id) < 1
2946
+             || 'course' != get_post_type($lesson_course_id)) {
2947 2947
 
2948 2948
              return false;
2949 2949
 
@@ -2970,11 +2970,11 @@  discard block
 block discarded – undo
2970 2970
      * @param string $post_type
2971 2971
      * @return void
2972 2972
      */
2973
-    public function all_lessons_edit_fields( $column_name, $post_type ) {
2973
+    public function all_lessons_edit_fields($column_name, $post_type) {
2974 2974
 
2975 2975
         // only show these options ont he lesson post type edit screen
2976
-        if( 'lesson' != $post_type || 'lesson-course' != $column_name
2977
-            || ! current_user_can( 'edit_lessons' ) ) {
2976
+        if ('lesson' != $post_type || 'lesson-course' != $column_name
2977
+            || ! current_user_can('edit_lessons')) {
2978 2978
             return;
2979 2979
         }
2980 2980
 
@@ -2982,41 +2982,41 @@  discard block
 block discarded – undo
2982 2982
         <fieldset class="sensei-edit-field-set inline-edit-lesson">
2983 2983
             <div class="sensei-inline-edit-col column-<?php echo $column_name ?>">
2984 2984
                     <?php
2985
-                    echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2985
+                    echo '<h4>'.__('Lesson Information', 'woothemes-sensei').'</h4>';
2986 2986
                     // create a nonce field to be  used as a security measure when saving the data
2987
-                    wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2988
-                    wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2987
+                    wp_nonce_field('bulk-edit-lessons', '_edit_lessons_nonce');
2988
+                    wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce');
2989 2989
 
2990 2990
                     // unchanged option - we need this in because
2991 2991
                     // the default option in bulk edit should not be empty. If it is
2992 2992
                     // the user will erase data they didn't want to touch.
2993
-                    $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2993
+                    $no_change_text = '-- '.__('No Change', 'woothemes-sensei').' --';
2994 2994
 
2995 2995
                     //
2996 2996
                     //course selection
2997 2997
                     //
2998
-                    $courses =  WooThemes_Sensei_Course::get_all_courses();
2998
+                    $courses = WooThemes_Sensei_Course::get_all_courses();
2999 2999
                     $course_options = array();
3000
-                    if ( count( $courses ) > 0 ) {
3001
-                        foreach ($courses as $course ){
3002
-                            $course_options[ $course->ID ] = get_the_title( $course->ID );
3000
+                    if (count($courses) > 0) {
3001
+                        foreach ($courses as $course) {
3002
+                            $course_options[$course->ID] = get_the_title($course->ID);
3003 3003
                         }
3004 3004
                     }
3005 3005
                     //pre-append the no change option
3006
-                    $course_options['-1']=  $no_change_text;
3007
-                    $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
3008
-                    $course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
3009
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
3006
+                    $course_options['-1'] = $no_change_text;
3007
+                    $course_attributes = array('name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course', 'class'=>' ');
3008
+                    $course_field = Sensei_Utils::generate_drop_down('-1', $course_options, $course_attributes);
3009
+                    echo $this->generate_all_lessons_edit_field(__('Lesson Course', 'woothemes-sensei'), $course_field);
3010 3010
 
3011 3011
                     //
3012 3012
                     // lesson complexity selection
3013 3013
                     //
3014
-                    $lesson_complexities =  $this->lesson_complexities();
3014
+                    $lesson_complexities = $this->lesson_complexities();
3015 3015
                     //pre-append the no change option
3016
-                    $lesson_complexities['-1']=  $no_change_text;
3017
-                    $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
3018
-                    $complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
3019
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
3016
+                    $lesson_complexities['-1'] = $no_change_text;
3017
+                    $complexity_dropdown_attributes = array('name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity', 'class'=>' ');
3018
+                    $complexity_filed = Sensei_Utils::generate_drop_down('-1', $lesson_complexities, $complexity_dropdown_attributes);
3019
+                    echo $this->generate_all_lessons_edit_field(__('Lesson Complexity', 'woothemes-sensei'), $complexity_filed);
3020 3020
 
3021 3021
                     ?>
3022 3022
 
@@ -3029,34 +3029,34 @@  discard block
 block discarded – undo
3029 3029
                     //
3030 3030
                     $pass_required_options = array(
3031 3031
                         '-1' => $no_change_text,
3032
-                         '0' => __('No','woothemes'),
3033
-                         '1' => __('Yes','woothemes'),
3032
+                         '0' => __('No', 'woothemes'),
3033
+                         '1' => __('Yes', 'woothemes'),
3034 3034
                     );
3035 3035
 
3036
-                    $pass_required_select_attributes = array( 'name'=> 'pass_required',
3036
+                    $pass_required_select_attributes = array('name'=> 'pass_required',
3037 3037
                                                                 'id'=> 'sensei-edit-lesson-pass-required',
3038
-                                                                'class'=>' '   );
3039
-                    $require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3040
-                    echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3038
+                                                                'class'=>' ');
3039
+                    $require_pass_field = Sensei_Utils::generate_drop_down('-1', $pass_required_options, $pass_required_select_attributes, false);
3040
+                    echo $this->generate_all_lessons_edit_field(__('Pass required', 'woothemes-sensei'), $require_pass_field);
3041 3041
 
3042 3042
                     //
3043 3043
                     // Quiz pass percentage
3044 3044
                     //
3045 3045
                     $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3046
-                    echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3046
+                    echo $this->generate_all_lessons_edit_field(__('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field);
3047 3047
 
3048 3048
                     //
3049 3049
                     // Enable quiz reset button
3050 3050
                     //
3051 3051
                     $quiz_reset_select__options = array(
3052 3052
                         '-1' => $no_change_text,
3053
-                        '0' => __('No','woothemes'),
3054
-                        '1' => __('Yes','woothemes'),
3053
+                        '0' => __('No', 'woothemes'),
3054
+                        '1' => __('Yes', 'woothemes'),
3055 3055
                     );
3056 3056
                     $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3057
-                    $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3058
-                    $quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3059
-                    echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3057
+                    $quiz_reset_select_attributes = array('name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ');
3058
+                    $quiz_reset_field = Sensei_Utils::generate_drop_down('-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false);
3059
+                    echo $this->generate_all_lessons_edit_field(__('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field);
3060 3060
 
3061 3061
                     ?>
3062 3062
             </div>
@@ -3075,17 +3075,17 @@  discard block
 block discarded – undo
3075 3075
      * @param string $field type markup for the field that must be wrapped.
3076 3076
      * @return string $field_html
3077 3077
      */
3078
-    public function generate_all_lessons_edit_field( $title  ,$field ){
3078
+    public function generate_all_lessons_edit_field($title, $field) {
3079 3079
 
3080 3080
         $html = '';
3081 3081
         $html = '<div class="inline-edit-group" >';
3082
-        $html .=  '<span class="title">'. $title .'</span> ';
3082
+        $html .= '<span class="title">'.$title.'</span> ';
3083 3083
         $html .= '<span class="input-text-wrap">';
3084 3084
         $html .= $field;
3085 3085
         $html .= '</span>';
3086 3086
         $html .= '</label></div>';
3087 3087
 
3088
-        return $html ;
3088
+        return $html;
3089 3089
 
3090 3090
     }//end generate_all_lessons_edit_field
3091 3091
 
@@ -3099,48 +3099,48 @@  discard block
 block discarded – undo
3099 3099
     function save_all_lessons_edit_fields() {
3100 3100
 
3101 3101
         // verify all the data before attempting to save
3102
-        if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3103
-            ||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3102
+        if ( ! isset($_POST['security']) || ! check_ajax_referer('bulk-edit-lessons', 'security')
3103
+            ||  empty($_POST['post_ids']) || ! is_array($_POST['post_ids'])) {
3104 3104
             die();
3105 3105
         }
3106 3106
 
3107 3107
         // get our variables
3108
-        $new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3109
-        $new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3110
-        $new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3111
-        $new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3112
-        $new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3108
+        $new_course = sanitize_text_field($_POST['sensei_edit_lesson_course']);
3109
+        $new_complexity = sanitize_text_field($_POST['sensei_edit_complexity']);
3110
+        $new_pass_required = sanitize_text_field($_POST['sensei_edit_pass_required']);
3111
+        $new_pass_percentage = sanitize_text_field($_POST['sensei_edit_pass_percentage']);
3112
+        $new_enable_quiz_reset = sanitize_text_field($_POST['sensei_edit_enable_quiz_reset']);
3113 3113
         // store the values for all selected posts
3114
-        foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3114
+        foreach ($_POST['post_ids'] as $lesson_id) {
3115 3115
 
3116 3116
             // get the quiz id needed for the quiz meta
3117
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3117
+            $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
3118 3118
 
3119 3119
             // do not save the items if the value is -1 as this
3120 3120
             // means it was not changed
3121 3121
 
3122 3122
             // update lesson course
3123
-            if( -1 != $new_course ){
3124
-                update_post_meta( $lesson_id, '_lesson_course', $new_course );
3123
+            if ( -1 != $new_course ) {
3124
+                update_post_meta($lesson_id, '_lesson_course', $new_course);
3125 3125
             }
3126 3126
             // update lesson complexity
3127
-            if( -1 != $new_complexity ){
3128
-                update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3127
+            if ( -1 != $new_complexity ) {
3128
+                update_post_meta($lesson_id, '_lesson_complexity', $new_complexity);
3129 3129
             }
3130 3130
 
3131 3131
             // Quiz Related settings
3132
-            if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3132
+            if (isset($quiz_id) && 0 < intval($quiz_id)) {
3133 3133
 
3134 3134
                 // update pass required
3135 3135
                 if (-1 != $new_pass_required) {
3136 3136
 
3137
-                    $checked = $new_pass_required  ? 'on' : '';
3137
+                    $checked = $new_pass_required ? 'on' : '';
3138 3138
                     update_post_meta($quiz_id, '_pass_required', $checked);
3139
-                    unset( $checked );
3139
+                    unset($checked);
3140 3140
                 }
3141 3141
 
3142 3142
                 // update pass percentage
3143
-                if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3143
+                if ( ! empty($new_pass_percentage) && is_numeric($new_pass_percentage)) {
3144 3144
 
3145 3145
                         update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3146 3146
 
@@ -3151,9 +3151,9 @@  discard block
 block discarded – undo
3151 3151
                 //
3152 3152
                 if (-1 != $new_enable_quiz_reset ) {
3153 3153
 
3154
-                    $checked = $new_enable_quiz_reset ? 'on' : ''  ;
3154
+                    $checked = $new_enable_quiz_reset ? 'on' : '';
3155 3155
                     update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3156
-                    unset( $checked );
3156
+                    unset($checked);
3157 3157
 
3158 3158
                 }
3159 3159
 
@@ -3177,31 +3177,31 @@  discard block
 block discarded – undo
3177 3177
      * @since 1.8.0
3178 3178
      * @return void
3179 3179
      */
3180
-    public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3180
+    public function set_quick_edit_admin_defaults($column_name, $post_id) {
3181 3181
 
3182
-        if( 'lesson-course' != $column_name ){
3182
+        if ('lesson-course' != $column_name) {
3183 3183
             return;
3184 3184
         }
3185 3185
         // load the script
3186
-        $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3187
-        wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3186
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3187
+        wp_enqueue_script('sensei-lesson-quick-edit', Sensei()->plugin_url.'assets/js/admin/lesson-quick-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true);
3188 3188
 
3189 3189
         // setup the values for all meta fields
3190 3190
         $data = array();
3191
-        foreach( $this->meta_fields as $field ){
3191
+        foreach ($this->meta_fields as $field) {
3192 3192
 
3193
-            $data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3193
+            $data[$field] = get_post_meta($post_id, '_'.$field, true);
3194 3194
 
3195 3195
         }
3196 3196
         // add quiz meta fields
3197
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3198
-        foreach( Sensei()->quiz->meta_fields as $field ){
3197
+        $quiz_id = Sensei()->lesson->lesson_quizzes($post_id);
3198
+        foreach (Sensei()->quiz->meta_fields as $field) {
3199 3199
 
3200
-            $data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3200
+            $data[$field] = get_post_meta($quiz_id, '_'.$field, true);
3201 3201
 
3202 3202
         }
3203 3203
 
3204
-        wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3204
+        wp_localize_script('sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data);
3205 3205
 
3206 3206
     }// end quick edit admin defaults
3207 3207
 
@@ -3214,19 +3214,19 @@  discard block
 block discarded – undo
3214 3214
      * @param array $classes
3215 3215
      * @return array $classes
3216 3216
      */
3217
-    public static function single_course_lessons_classes( $classes ){
3217
+    public static function single_course_lessons_classes($classes) {
3218 3218
 
3219
-        if(  is_singular('course') ){
3219
+        if (is_singular('course')) {
3220 3220
 
3221 3221
             global $post;
3222 3222
             $course_id = $post->ID;
3223 3223
 
3224
-            $lesson_classes = array( 'course', 'post' );
3225
-            if ( is_user_logged_in() ) {
3224
+            $lesson_classes = array('course', 'post');
3225
+            if (is_user_logged_in()) {
3226 3226
 
3227 3227
                 // Check if Lesson is complete
3228
-                $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3229
-                if ( $single_lesson_complete ) {
3228
+                $single_lesson_complete = Sensei_Utils::user_completed_lesson(get_the_ID(), get_current_user_id());
3229
+                if ($single_lesson_complete) {
3230 3230
 
3231 3231
                     $lesson_classes[] = 'lesson-completed';
3232 3232
 
@@ -3234,14 +3234,14 @@  discard block
 block discarded – undo
3234 3234
 
3235 3235
             } // End If Statement
3236 3236
 
3237
-            $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3238
-            if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3237
+            $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
3238
+            if (Sensei_Utils::is_preview_lesson(get_the_ID()) && ! $is_user_taking_course) {
3239 3239
 
3240 3240
                 $lesson_classes[] = 'lesson-preview';
3241 3241
 
3242 3242
             }
3243 3243
 
3244
-            $classes = array_merge( $classes, $lesson_classes  );
3244
+            $classes = array_merge($classes, $lesson_classes);
3245 3245
 
3246 3246
         }
3247 3247
 
@@ -3255,56 +3255,56 @@  discard block
 block discarded – undo
3255 3255
      * @since 1.9.0
3256 3256
      * @param $lesson_id
3257 3257
      */
3258
-    public static function the_lesson_meta( $lesson_id ){
3258
+    public static function the_lesson_meta($lesson_id) {
3259 3259
 
3260 3260
         global $wp_query;
3261 3261
         $loop_lesson_number = $wp_query->current_post + 1;
3262 3262
 
3263
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
3263
+        $course_id = Sensei()->lesson->get_course_id($lesson_id);
3264 3264
         $single_lesson_complete = false;
3265
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3265
+        $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
3266 3266
 
3267 3267
         // Get Lesson data
3268 3268
         $complexity_array = Sensei()->lesson->lesson_complexities();
3269 3269
 
3270
-        $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3271
-        if ( '' != $lesson_complexity ) {
3270
+        $lesson_complexity = get_post_meta($lesson_id, '_lesson_complexity', true);
3271
+        if ('' != $lesson_complexity) {
3272 3272
 
3273 3273
             $lesson_complexity = $complexity_array[$lesson_complexity];
3274 3274
 
3275 3275
         }
3276
-        $user_info = get_userdata( absint( get_post()->post_author ) );
3277
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3276
+        $user_info = get_userdata(absint(get_post()->post_author));
3277
+        $is_preview = Sensei_Utils::is_preview_lesson($lesson_id);
3278 3278
         $preview_label = '';
3279
-        if ( $is_preview && !$is_user_taking_course ) {
3279
+        if ($is_preview && ! $is_user_taking_course) {
3280 3280
 
3281
-            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3282
-            $preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3281
+            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text($lesson_id);
3282
+            $preview_label = '<span class="preview-heading">'.$preview_label.'</span>';
3283 3283
 
3284 3284
         }
3285 3285
 
3286 3286
 
3287
-        $count_markup= '';
3287
+        $count_markup = '';
3288 3288
         /**
3289 3289
          * Filter for if you want the $lesson_count to show next to the lesson.
3290 3290
          *
3291 3291
          * @since 1.0
3292 3292
          * @param bool default false.
3293 3293
          */
3294
-        if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3294
+        if (apply_filters('sensei_show_lesson_numbers', false)) {
3295 3295
 
3296
-            $count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3296
+            $count_markup = '<span class="lesson-number">'.$loop_lesson_number.'</span>';
3297 3297
 
3298 3298
         }
3299 3299
 
3300
-        $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3300
+        $heading_link_title = sprintf(__('Start %s', 'woothemes-sensei'), get_the_title($lesson_id));
3301 3301
 
3302 3302
         ?>
3303 3303
         <header>
3304 3304
             <h2>
3305
-                <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>"
3306
-                   title="<?php esc_attr_e( $heading_link_title ) ?>" >
3307
-                    <?php echo $count_markup. get_the_title( $lesson_id ) . $preview_label; ?>
3305
+                <a href="<?php echo esc_url_raw(get_permalink($lesson_id)) ?>"
3306
+                   title="<?php esc_attr_e($heading_link_title) ?>" >
3307
+                    <?php echo $count_markup.get_the_title($lesson_id).$preview_label; ?>
3308 3308
                 </a>
3309 3309
             </h2>
3310 3310
 
@@ -3313,33 +3313,33 @@  discard block
 block discarded – undo
3313 3313
                 <?php
3314 3314
 
3315 3315
                 $meta_html = '';
3316
-                $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3316
+                $user_lesson_status = Sensei_Utils::user_lesson_status(get_the_ID(), get_current_user_id());
3317 3317
 
3318
-                $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3319
-                if ( '' != $lesson_length ) {
3318
+                $lesson_length = get_post_meta($lesson_id, '_lesson_length', true);
3319
+                if ('' != $lesson_length) {
3320 3320
 
3321
-                    $meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3321
+                    $meta_html .= '<span class="lesson-length">'.__('Length: ', 'woothemes-sensei').$lesson_length.__(' minutes', 'woothemes-sensei').'</span>';
3322 3322
 
3323 3323
                 }
3324 3324
 
3325
-                if ( Sensei()->settings->get( 'lesson_author' ) ) {
3325
+                if (Sensei()->settings->get('lesson_author')) {
3326 3326
 
3327
-                    $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>';
3327
+                    $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>';
3328 3328
 
3329 3329
                 } // End If Statement
3330
-                if ( '' != $lesson_complexity ) {
3330
+                if ('' != $lesson_complexity) {
3331 3331
 
3332
-                    $meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3332
+                    $meta_html .= '<span class="lesson-complexity">'.__('Complexity: ', 'woothemes-sensei').$lesson_complexity.'</span>';
3333 3333
 
3334 3334
                 }
3335 3335
 
3336
-                if ( $single_lesson_complete ) {
3336
+                if ($single_lesson_complete) {
3337 3337
 
3338
-                    $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3338
+                    $meta_html .= '<span class="lesson-status complete">'.__('Complete', 'woothemes-sensei').'</span>';
3339 3339
 
3340
-                } elseif ( $user_lesson_status ) {
3340
+                } elseif ($user_lesson_status) {
3341 3341
 
3342
-                    $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3342
+                    $meta_html .= '<span class="lesson-status in-progress">'.__('In Progress', 'woothemes-sensei').'</span>';
3343 3343
 
3344 3344
                 } // End If Statement
3345 3345
 
@@ -3362,19 +3362,19 @@  discard block
 block discarded – undo
3362 3362
      *
3363 3363
      * @param $lesson_id
3364 3364
      */
3365
-    public static function the_lesson_thumbnail( $lesson_id ){
3365
+    public static function the_lesson_thumbnail($lesson_id) {
3366 3366
 
3367
-        if( empty( $lesson_id ) ){
3367
+        if (empty($lesson_id)) {
3368 3368
 
3369 3369
             $lesson_id = get_the_ID();
3370 3370
 
3371 3371
         }
3372 3372
 
3373
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3373
+        if ('lesson' != get_post_type($lesson_id)) {
3374 3374
             return;
3375 3375
         }
3376 3376
 
3377
-        echo Sensei()->lesson->lesson_image( $lesson_id );
3377
+        echo Sensei()->lesson->lesson_image($lesson_id);
3378 3378
     }
3379 3379
 
3380 3380
 
@@ -3385,14 +3385,14 @@  discard block
 block discarded – undo
3385 3385
      * @param string $excerpt
3386 3386
      * @return string $excerpt
3387 3387
      */
3388
-    public static function alter_the_lesson_excerpt( $excerpt ) {
3388
+    public static function alter_the_lesson_excerpt($excerpt) {
3389 3389
 
3390
-        if ('lesson' == get_post_type(get_the_ID())){
3390
+        if ('lesson' == get_post_type(get_the_ID())) {
3391 3391
 
3392 3392
             // remove this hooks to avoid an infinite loop.
3393
-            remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3393
+            remove_filter('get_the_excerpt', array('WooThemes_Sensei_Lesson', 'alter_the_lesson_excerpt'));
3394 3394
 
3395
-            return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3395
+            return WooThemes_Sensei_Lesson::lesson_excerpt(get_post(get_the_ID()));
3396 3396
         }
3397 3397
 
3398 3398
         return $excerpt;
@@ -3407,20 +3407,20 @@  discard block
 block discarded – undo
3407 3407
      * @param $current_lesson_id
3408 3408
      * @return mixed | bool | int $prerequisite_lesson_id or false
3409 3409
      */
3410
-    public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3410
+    public static function get_lesson_prerequisite_id($current_lesson_id) {
3411 3411
 
3412
-        $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3412
+        $prerequisite_lesson_id = get_post_meta($current_lesson_id, '_lesson_prerequisite', true);
3413 3413
 
3414 3414
         // set ti to false if not a valid prerequisite lesson id
3415
-        if(  empty( $prerequisite_lesson_id )
3416
-            || 'lesson' != get_post_type( $prerequisite_lesson_id )
3417
-            || $prerequisite_lesson_id == $current_lesson_id  ) {
3415
+        if (empty($prerequisite_lesson_id)
3416
+            || 'lesson' != get_post_type($prerequisite_lesson_id)
3417
+            || $prerequisite_lesson_id == $current_lesson_id) {
3418 3418
 
3419 3419
             $prerequisite_lesson_id = false;
3420 3420
 
3421 3421
         }
3422 3422
 
3423
-        return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3423
+        return apply_filters('sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id);
3424 3424
 
3425 3425
     }
3426 3426
 
@@ -3435,27 +3435,27 @@  discard block
 block discarded – undo
3435 3435
      * @param $user_id
3436 3436
      * @return bool
3437 3437
      */
3438
-    public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3438
+    public  static function is_prerequisite_complete($lesson_id, $user_id) {
3439 3439
 
3440
-        if( empty( $lesson_id ) || empty( $user_id )
3441
-        || 'lesson' != get_post_type( $lesson_id )
3442
-        ||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3440
+        if (empty($lesson_id) || empty($user_id)
3441
+        || 'lesson' != get_post_type($lesson_id)
3442
+        ||  ! is_a(get_user_by('id', $user_id), 'WP_User')) {
3443 3443
 
3444 3444
             return false;
3445 3445
 
3446 3446
         }
3447 3447
 
3448
-        $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3448
+        $pre_requisite_id = (string) self::get_lesson_prerequisite_id($lesson_id);
3449 3449
 
3450 3450
         // not a valid pre-requisite so pre-requisite is completed
3451
-        if( 'lesson' != get_post_type( $pre_requisite_id )
3452
-            || ! is_numeric( $pre_requisite_id ) ){
3451
+        if ('lesson' != get_post_type($pre_requisite_id)
3452
+            || ! is_numeric($pre_requisite_id)) {
3453 3453
 
3454 3454
             return true;
3455 3455
 
3456 3456
         }
3457 3457
 
3458
-        return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3458
+        return  Sensei_Utils::user_completed_lesson($pre_requisite_id, $user_id);
3459 3459
 
3460 3460
     }// end is_prerequisite_complete
3461 3461
 
@@ -3464,20 +3464,20 @@  discard block
 block discarded – undo
3464 3464
      *
3465 3465
      * @since 1.9.0
3466 3466
      */
3467
-    public  static function user_not_taking_course_message(){
3467
+    public  static function user_not_taking_course_message() {
3468 3468
 
3469 3469
         $lesson_id = get_the_ID();
3470 3470
 
3471
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3471
+        if ('lesson' != get_post_type($lesson_id)) {
3472 3472
             return;
3473 3473
         }
3474 3474
 
3475
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3476
-        $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3477
-        $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3478
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3475
+        $is_preview = Sensei_Utils::is_preview_lesson($lesson_id);
3476
+        $pre_requisite_complete = self::is_prerequisite_complete($lesson_id, get_current_user_id());
3477
+        $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
3478
+        $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id());
3479 3479
 
3480
-        if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3480
+        if ($pre_requisite_complete && $is_preview && ! $user_taking_course) {
3481 3481
 
3482 3482
 
3483 3483
         }// end if
@@ -3491,11 +3491,11 @@  discard block
 block discarded – undo
3491 3491
      *
3492 3492
      * @since 1.9.0
3493 3493
      */
3494
-    public static function course_signup_link( ){
3494
+    public static function course_signup_link( ) {
3495 3495
 
3496
-        $course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3496
+        $course_id = Sensei()->lesson->get_course_id(get_the_ID());
3497 3497
 
3498
-        if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3498
+        if (empty($course_id) || 'course' != get_post_type($course_id) || sensei_all_access()) {
3499 3499
 
3500 3500
             return;
3501 3501
 
@@ -3508,69 +3508,69 @@  discard block
 block discarded – undo
3508 3508
             <?php
3509 3509
 
3510 3510
             global $current_user;
3511
-            $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3511
+            $wc_post_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true);
3512 3512
 
3513
-            if ( Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable( $course_id ) ) {
3513
+            if (Sensei_WC::is_woocommerce_active() && Sensei_WC::is_course_purchasable($course_id)) {
3514 3514
 
3515
-                if( is_user_logged_in() && ! Sensei_Utils::user_started_course( $course_id, $current_user->ID )  ) {
3515
+                if (is_user_logged_in() && ! Sensei_Utils::user_started_course($course_id, $current_user->ID)) {
3516 3516
 
3517
-	                    $a_element = '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Sign Up', 'woothemes-sensei' )  . '">';
3518
-	                    $a_element .= __( 'course', 'woothemes-sensei' );
3517
+	                    $a_element = '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Sign Up', 'woothemes-sensei').'">';
3518
+	                    $a_element .= __('course', 'woothemes-sensei');
3519 3519
 	                    $a_element .= '</a>';
3520 3520
 
3521
-	                    if( Sensei_Utils::is_preview_lesson( get_the_ID()  ) ){
3521
+	                    if (Sensei_Utils::is_preview_lesson(get_the_ID())) {
3522 3522
 
3523
-		                    $message = sprintf( __( 'This is a preview lesson. Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3523
+		                    $message = sprintf(__('This is a preview lesson. Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), $a_element);
3524 3524
 
3525
-	                    }else{
3525
+	                    } else {
3526 3526
 
3527
-		                    $message = sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3527
+		                    $message = sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), $a_element);
3528 3528
 
3529 3529
 	                    }
3530 3530
 
3531
-	                    Sensei()->notices->add_notice( $message, 'info' );
3531
+	                    Sensei()->notices->add_notice($message, 'info');
3532 3532
 
3533 3533
                 }
3534 3534
 
3535
-	            if( ! is_user_logged_in() ) {
3535
+	            if ( ! is_user_logged_in()) {
3536 3536
 
3537
-	                $a_element = '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Sign Up', 'woothemes-sensei' )  . '">';
3538
-	                $a_element .= __( 'course', 'woothemes-sensei' );
3537
+	                $a_element = '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Sign Up', 'woothemes-sensei').'">';
3538
+	                $a_element .= __('course', 'woothemes-sensei');
3539 3539
 	                $a_element .= '</a>';
3540 3540
 
3541
-	                if( Sensei_Utils::is_preview_lesson( get_the_ID()  ) ){
3541
+	                if (Sensei_Utils::is_preview_lesson(get_the_ID())) {
3542 3542
 
3543
-						$message = sprintf( __( 'This is a preview lesson. Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3543
+						$message = sprintf(__('This is a preview lesson. Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), $a_element);
3544 3544
 
3545
-					}else{
3545
+					} else {
3546 3546
 
3547
-						$message = sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element );
3547
+						$message = sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), $a_element);
3548 3548
 
3549 3549
 					}
3550 3550
 
3551
-					Sensei()->notices->add_notice( $message, 'alert' );
3551
+					Sensei()->notices->add_notice($message, 'alert');
3552 3552
 
3553 3553
 	            }
3554 3554
 
3555 3555
             } else { ?>
3556 3556
 
3557
-	            <?php if( ! Sensei_Utils::user_started_course( $course_id, get_current_user_id() ) &&  sensei_is_login_required() )  : ?>
3557
+	            <?php if ( ! Sensei_Utils::user_started_course($course_id, get_current_user_id()) && sensei_is_login_required())  : ?>
3558 3558
 
3559 3559
 	                <div class="sensei-message alert">
3560 3560
 	                    <?php
3561
-	                    $course_link =  '<a href="'
3562
-	                                        . esc_url( get_permalink( $course_id ) )
3563
-	                                        . '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3564
-	                                        . '">' . __( 'course', 'woothemes-sensei' )
3561
+	                    $course_link = '<a href="'
3562
+	                                        . esc_url(get_permalink($course_id))
3563
+	                                        . '" title="'.__('Sign Up', 'woothemes-sensei')
3564
+	                                        . '">'.__('course', 'woothemes-sensei')
3565 3565
 	                                    . '</a>';
3566 3566
 
3567
-						if ( Sensei_Utils::is_preview_lesson( get_the_ID( ) ) ) {
3567
+						if (Sensei_Utils::is_preview_lesson(get_the_ID( ))) {
3568 3568
 
3569
-							echo sprintf( __( 'This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ),  $course_link );
3569
+							echo sprintf(__('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei'), $course_link);
3570 3570
 
3571 3571
 						} else {
3572 3572
 
3573
-							echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3573
+							echo sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
3574 3574
 
3575 3575
 						}
3576 3576
 
@@ -3591,14 +3591,14 @@  discard block
 block discarded – undo
3591 3591
      *
3592 3592
      * @since 1.9.0
3593 3593
      */
3594
-    public  static function prerequisite_complete_message(){
3594
+    public  static function prerequisite_complete_message() {
3595 3595
 
3596
-        $lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3596
+        $lesson_prerequisite = WooThemes_Sensei_Lesson::get_lesson_prerequisite_id(get_the_ID());
3597 3597
         $lesson_has_pre_requisite = $lesson_prerequisite > 0;
3598
-        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3598
+        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(get_the_ID(), get_current_user_id()) && $lesson_has_pre_requisite) {
3599 3599
 
3600
-            $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>';
3601
-            echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3600
+            $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>';
3601
+            echo sprintf(__('You must first complete %1$s before viewing this Lesson', 'woothemes-sensei'), $prerequisite_lesson_link);
3602 3602
 
3603 3603
         }
3604 3604
 
@@ -3610,7 +3610,7 @@  discard block
 block discarded – undo
3610 3610
      *
3611 3611
      * @deprecated since 1.9.0
3612 3612
      */
3613
-    public static function deprecate_sensei_lesson_archive_header_hook(){
3613
+    public static function deprecate_sensei_lesson_archive_header_hook() {
3614 3614
 
3615 3615
         sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3616 3616
 
@@ -3626,9 +3626,9 @@  discard block
 block discarded – undo
3626 3626
 
3627 3627
         $before_html = '<header class="archive-header"><h1>';
3628 3628
         $after_html = '</h1></header>';
3629
-        $html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3629
+        $html = $before_html.__('Lessons Archive', 'woothemes-sensei').$after_html;
3630 3630
 
3631
-        echo apply_filters( 'sensei_lesson_archive_title', $html );
3631
+        echo apply_filters('sensei_lesson_archive_title', $html);
3632 3632
 
3633 3633
     } // sensei_course_archive_header()
3634 3634
 
@@ -3638,7 +3638,7 @@  discard block
 block discarded – undo
3638 3638
      * @global $post
3639 3639
      * @since 1.9.0
3640 3640
      */
3641
-    public static function the_title(){
3641
+    public static function the_title() {
3642 3642
 
3643 3643
         global $post;
3644 3644
 
@@ -3651,7 +3651,7 @@  discard block
 block discarded – undo
3651 3651
                 /**
3652 3652
                  * Filter documented in class-sensei-messages.php the_title
3653 3653
                  */
3654
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3654
+                echo apply_filters('sensei_single_title', get_the_title($post), $post->post_type);
3655 3655
                 ?>
3656 3656
 
3657 3657
             </h1>
@@ -3669,16 +3669,16 @@  discard block
 block discarded – undo
3669 3669
      *
3670 3670
      * @param $post_id
3671 3671
      */
3672
-    public static function flush_rewrite_rules( $post_id ){
3672
+    public static function flush_rewrite_rules($post_id) {
3673 3673
 
3674
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3674
+        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3675 3675
 
3676 3676
             return;
3677 3677
 
3678 3678
         }
3679 3679
 
3680 3680
 
3681
-        if( 'lesson' == get_post_type( $post_id )  ){
3681
+        if ('lesson' == get_post_type($post_id)) {
3682 3682
 
3683 3683
             Sensei()->initiate_rewrite_rules_flush();
3684 3684
 
@@ -3695,27 +3695,27 @@  discard block
 block discarded – undo
3695 3695
      * @param int $lesson_id
3696 3696
      * @param int $user_id
3697 3697
      */
3698
-    public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3698
+    public static function footer_quiz_call_to_action($lesson_id = 0, $user_id = 0) {
3699 3699
 
3700 3700
 
3701
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3702
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3701
+        $lesson_id                 = empty($lesson_id) ? get_the_ID() : $lesson_id;
3702
+        $user_id                   = empty($lesson_id) ? get_current_user_id() : $user_id;
3703 3703
 
3704 3704
 
3705
-	    if ( ! sensei_can_user_view_lesson( $lesson_id, $user_id ) ) {
3705
+	    if ( ! sensei_can_user_view_lesson($lesson_id, $user_id)) {
3706 3706
 		    return;
3707 3707
 	    }
3708 3708
 
3709
-        $lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3710
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3711
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3712
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3709
+        $lesson_prerequisite       = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
3710
+        $lesson_course_id          = (int) get_post_meta($lesson_id, '_lesson_course', true);
3711
+        $quiz_id                   = Sensei()->lesson->lesson_quizzes($lesson_id);
3712
+        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id);
3713 3713
         $show_actions              = is_user_logged_in() ? true : false;
3714 3714
 
3715
-        if( intval( $lesson_prerequisite ) > 0 ) {
3715
+        if (intval($lesson_prerequisite) > 0) {
3716 3716
 
3717 3717
             // If the user hasn't completed the prereq then hide the current actions
3718
-            $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3718
+            $show_actions = Sensei_Utils::user_completed_lesson($lesson_prerequisite, $user_id);
3719 3719
 
3720 3720
         }
3721 3721
 
@@ -3724,19 +3724,19 @@  discard block
 block discarded – undo
3724 3724
         <footer>
3725 3725
 
3726 3726
             <?php
3727
-            if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3727
+            if ($show_actions && $quiz_id && Sensei()->access_settings()) {
3728 3728
 
3729
-                $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3730
-                if( $has_quiz_questions ) {
3729
+                $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
3730
+                if ($has_quiz_questions) {
3731 3731
                     ?>
3732 3732
 
3733 3733
                     <p>
3734 3734
 
3735 3735
                         <a class="button"
3736
-                           href="<?php echo esc_url_raw( get_permalink( $quiz_id ) ); ?>"
3737
-                           title="<?php _e( 'View the Lesson Quiz', 'woothemes-sensei'  ); ?>">
3736
+                           href="<?php echo esc_url_raw(get_permalink($quiz_id)); ?>"
3737
+                           title="<?php _e('View the Lesson Quiz', 'woothemes-sensei'); ?>">
3738 3738
 
3739
-                            <?php  _e( 'View the Lesson Quiz', 'woothemes-sensei' ); ?>
3739
+                            <?php  _e('View the Lesson Quiz', 'woothemes-sensei'); ?>
3740 3740
 
3741 3741
                         </a>
3742 3742
 
@@ -3747,11 +3747,11 @@  discard block
 block discarded – undo
3747 3747
 
3748 3748
             } // End If Statement
3749 3749
 
3750
-            if ( $show_actions && ! $has_user_completed_lesson ) {
3750
+            if ($show_actions && ! $has_user_completed_lesson) {
3751 3751
 
3752 3752
                 sensei_complete_lesson_button();
3753 3753
 
3754
-            } elseif( $show_actions ) {
3754
+            } elseif ($show_actions) {
3755 3755
 
3756 3756
                 sensei_reset_lesson_button();
3757 3757
 
@@ -3768,20 +3768,20 @@  discard block
 block discarded – undo
3768 3768
      *
3769 3769
      * @since 1.9.0
3770 3770
      */
3771
-    public static function output_comments(){
3771
+    public static function output_comments() {
3772 3772
 
3773
-        if( ! is_user_logged_in() ){
3773
+        if ( ! is_user_logged_in()) {
3774 3774
             return;
3775 3775
         }
3776 3776
 
3777
-        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3778
-        $course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3779
-        $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3780
-        $user_taking_course = Sensei_Utils::user_started_course($course_id );
3777
+        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete(get_the_ID(), get_current_user_id());
3778
+        $course_id = Sensei()->lesson->get_course_id(get_the_ID());
3779
+        $allow_comments = Sensei()->settings->settings['lesson_comments'];
3780
+        $user_taking_course = Sensei_Utils::user_started_course($course_id);
3781 3781
 
3782
-        $lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3782
+        $lesson_allow_comments = $allow_comments && $pre_requisite_complete && $user_taking_course;
3783 3783
 
3784
-        if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3784
+        if ($lesson_allow_comments || is_singular('sensei_message')) {
3785 3785
 
3786 3786
             comments_template();
3787 3787
 
@@ -3797,26 +3797,26 @@  discard block
 block discarded – undo
3797 3797
      *
3798 3798
      * @since 1.9.0
3799 3799
      */
3800
-    public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3800
+    public static function user_lesson_quiz_status_message($lesson_id = 0, $user_id = 0) {
3801 3801
 
3802
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3803
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3804
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3805
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3806
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3802
+        $lesson_id                 = empty($lesson_id) ? get_the_ID() : $lesson_id;
3803
+        $user_id                   = empty($lesson_id) ? get_current_user_id() : $user_id;
3804
+        $lesson_course_id          = (int) get_post_meta($lesson_id, '_lesson_course', true);
3805
+        $quiz_id                   = Sensei()->lesson->lesson_quizzes($lesson_id);
3806
+        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id);
3807 3807
 
3808 3808
 
3809
-        if ( $quiz_id && is_user_logged_in()
3810
-            && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3809
+        if ($quiz_id && is_user_logged_in()
3810
+            && Sensei_Utils::user_started_course($lesson_course_id, $user_id)) {
3811 3811
 
3812 3812
             $no_quiz_count = 0;
3813
-            $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3813
+            $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
3814 3814
 
3815 3815
             // Display lesson quiz status message
3816
-            if ( $has_user_completed_lesson || $has_quiz_questions ) {
3817
-                $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3818
-                echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3819
-                if( $has_quiz_questions ) {
3816
+            if ($has_user_completed_lesson || $has_quiz_questions) {
3817
+                $status = Sensei_Utils::sensei_user_quiz_status_message($lesson_id, $user_id, true);
3818
+                echo '<div class="sensei-message '.$status['box_class'].'">'.$status['message'].'</div>';
3819
+                if ($has_quiz_questions) {
3820 3820
                    // echo $status['extra'];
3821 3821
                 } // End If Statement
3822 3822
             } // End If Statement
@@ -3832,11 +3832,11 @@  discard block
 block discarded – undo
3832 3832
      * @param $content
3833 3833
      * @return string
3834 3834
      */
3835
-    public static function limit_archive_content ( $content ){
3835
+    public static function limit_archive_content($content) {
3836 3836
 
3837
-        if( is_archive('lesson') && Sensei()->settings->get('access_permission') ){
3837
+        if (is_archive('lesson') && Sensei()->settings->get('access_permission')) {
3838 3838
 
3839
-            return wp_trim_words( $content, $num_words = 30, $more = '…' );
3839
+            return wp_trim_words($content, $num_words = 30, $more = '…');
3840 3840
         }
3841 3841
 
3842 3842
         return $content;
@@ -3849,9 +3849,9 @@  discard block
 block discarded – undo
3849 3849
      * @since 1.9.0
3850 3850
      * @return array
3851 3851
      */
3852
-    public static function get_all_lesson_ids(){
3852
+    public static function get_all_lesson_ids() {
3853 3853
 
3854
-        return get_posts( array(
3854
+        return get_posts(array(
3855 3855
             'post_type'=>'lesson',
3856 3856
             'fields'=>'ids',
3857 3857
             'post_status' => 'publish',
@@ -3868,4 +3868,4 @@  discard block
 block discarded – undo
3868 3868
  * @ignore only for backward compatibility
3869 3869
  * @since 1.9.0
3870 3870
  */
3871
-class WooThemes_Sensei_Lesson extends Sensei_Lesson{}
3871
+class WooThemes_Sensei_Lesson extends Sensei_Lesson {}
Please login to merge, or discard this patch.
includes/hooks/woocommerce.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,20 +7,20 @@  discard block
 block discarded – undo
7 7
  * show the WooCommerce course filter links above the courses
8 8
  * @since 1.9.0
9 9
  */
10
-add_filter( 'sensei_archive_course_filter_by_options', array( 'Sensei_WC', 'add_course_archive_wc_filter_links' ) );
10
+add_filter('sensei_archive_course_filter_by_options', array('Sensei_WC', 'add_course_archive_wc_filter_links'));
11 11
 
12 12
 /**
13 13
  * filter the queries for paid and free course based on the users selection.
14 14
  * @since 1.9.0
15 15
  */
16
-add_filter('pre_get_posts', array( 'Sensei_WC', 'course_archive_wc_filter_free'));
17
-add_filter('pre_get_posts', array( 'Sensei_WC', 'course_archive_wc_filter_paid'));
16
+add_filter('pre_get_posts', array('Sensei_WC', 'course_archive_wc_filter_free'));
17
+add_filter('pre_get_posts', array('Sensei_WC', 'course_archive_wc_filter_paid'));
18 18
 
19 19
 /**
20 20
  * Add woocommerce action above single course the action
21 21
  * @since 1.9.0
22 22
  */
23
-add_action('sensei_before_main_content', array('Sensei_WC', 'do_single_course_wc_single_product_action') ,50) ;
23
+add_action('sensei_before_main_content', array('Sensei_WC', 'do_single_course_wc_single_product_action'), 50);
24 24
 
25 25
 
26 26
 /******************************
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
  * Single Lesson Hooks
29 29
  *
30 30
  ******************************/
31
-add_filter( 'sensei_can_user_view_lesson', array( 'Sensei_WC','alter_can_user_view_lesson' ), 20, 3 );
31
+add_filter('sensei_can_user_view_lesson', array('Sensei_WC', 'alter_can_user_view_lesson'), 20, 3);
32 32
 
33 33
 /******************************
34 34
  *
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
  *
37 37
  ******************************/
38 38
 // add a notice on the checkout page to tell users about the course they've purchase
39
-add_action( 'template_redirect', array( 'Sensei_WC','course_link_from_order' ) );
39
+add_action('template_redirect', array('Sensei_WC', 'course_link_from_order'));
40 40
 
41 41
 /******************************
42 42
  *
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
  ******************************/
46 46
 //@since 1.9.0
47 47
 //show a notice if the user has already added the current course to their cart
48
-add_action( 'sensei_single_course_content_inside_before', array( 'Sensei_WC', 'course_in_cart_message' ), 20 );
48
+add_action('sensei_single_course_content_inside_before', array('Sensei_WC', 'course_in_cart_message'), 20);
49 49
 
50 50
 /******************************
51 51
  *
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
  ******************************/
55 55
 //@since 1.9.0
56 56
 // alter the no permissions message to show the woocommerce message instead
57
-add_filter( 'sensei_the_no_permissions_message', array( 'Sensei_WC', 'alter_no_permissions_message' ), 20, 2 );
57
+add_filter('sensei_the_no_permissions_message', array('Sensei_WC', 'alter_no_permissions_message'), 20, 2);
58 58
 
59 59
 // @since 1.9.0
60 60
 // add  woocommerce class to the the no permission body class to ensure WooCommerce elements are styled
61
-add_filter( 'body_class', array( 'Sensei_WC', 'add_woocommerce_body_class' ), 20, 1);
61
+add_filter('body_class', array('Sensei_WC', 'add_woocommerce_body_class'), 20, 1);
62 62
 
63 63
 
64 64
 /************************************
@@ -67,28 +67,28 @@  discard block
 block discarded – undo
67 67
  *
68 68
  ************************************/
69 69
 // Add Email link to course orders
70
-add_action( 'woocommerce_email_after_order_table', array( 'Sensei_WC', 'email_course_details' ), 10, 1 );
70
+add_action('woocommerce_email_after_order_table', array('Sensei_WC', 'email_course_details'), 10, 1);
71 71
 
72 72
 /************************************
73 73
  *
74 74
  * Checkout
75 75
  *
76 76
  ************************************/
77
-add_action( 'woocommerce_delete_shop_order_transients',           array( 'Sensei_WC', 'complete_order' ) );
78
-add_action( 'woocommerce_delete_shop_order_transients',            array( 'Sensei_WC', 'cancel_order' ) );
77
+add_action('woocommerce_delete_shop_order_transients', array('Sensei_WC', 'complete_order'));
78
+add_action('woocommerce_delete_shop_order_transients', array('Sensei_WC', 'cancel_order'));
79 79
 // Disable guest checkout if a course is in the cart as we need a valid user to store data for
80
-add_filter( 'pre_option_woocommerce_enable_guest_checkout', array( 'Sensei_WC', 'disable_guest_checkout' ) );
80
+add_filter('pre_option_woocommerce_enable_guest_checkout', array('Sensei_WC', 'disable_guest_checkout'));
81 81
 // Mark orders with virtual products as complete rather then stay processing
82
-add_filter( 'woocommerce_payment_complete_order_status',    array( 'Sensei_WC', 'virtual_order_payment_complete' ), 10, 2 );
82
+add_filter('woocommerce_payment_complete_order_status', array('Sensei_WC', 'virtual_order_payment_complete'), 10, 2);
83 83
 
84 84
 /************************************
85 85
  *
86 86
  * WooCommerce Subscriptions
87 87
  *
88 88
  ************************************/
89
-add_action( 'woocommerce_subscription_status_pending_to_active', array( 'Sensei_WC', 'activate_subscription' ), 50, 3 );
89
+add_action('woocommerce_subscription_status_pending_to_active', array('Sensei_WC', 'activate_subscription'), 50, 3);
90 90
 // filter the user permission of the subscription is not valid
91
-add_filter( 'sensei_access_permissions',               array( 'Sensei_WC', 'get_subscription_permission' ), 10, 2 );
91
+add_filter('sensei_access_permissions', array('Sensei_WC', 'get_subscription_permission'), 10, 2);
92 92
 
93 93
 //block user from accessing course when subscription
94
-add_filter( 'sensei_user_started_course',     array( 'Sensei_WC', 'get_subscription_user_started_course' ), 10, 3 );
94
+add_filter('sensei_user_started_course', array('Sensei_WC', 'get_subscription_user_started_course'), 10, 3);
Please login to merge, or discard this patch.