Completed
Pull Request — master (#1233)
by Dan
07:34
created
includes/lib/woo-functions.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
 		if ( WooThemes_Sensei_Utils::sensei_is_woocommerce_activated() ) {
87 87
 			global $woocommerce;
88 88
 			if( version_compare( $woocommerce->version, $version, ">=" ) ) {
89
-			    return true;
89
+				return true;
90 90
 			}
91 91
 		}
92 92
 		return false;
Please login to merge, or discard this patch.
Braces   +9 added lines, -4 removed lines patch added patch discarded remove patch
@@ -7,8 +7,9 @@  discard block
 block discarded – undo
7 7
 	function woothemes_queue_update( $file, $file_id, $product_id ) {
8 8
 		global $woothemes_queued_updates;
9 9
 
10
-		if ( ! isset( $woothemes_queued_updates ) )
11
-			$woothemes_queued_updates = array();
10
+		if ( ! isset( $woothemes_queued_updates ) ) {
11
+					$woothemes_queued_updates = array();
12
+		}
12 13
 
13 14
 		$plugin             = new stdClass();
14 15
 		$plugin->file       = $file;
@@ -31,7 +32,9 @@  discard block
 block discarded – undo
31 32
 			false !== $api ||
32 33
 			! isset( $args->slug ) ||
33 34
 			'woothemes-updater' != $args->slug
34
-		) return $api;
35
+		) {
36
+			return $api;
37
+		}
35 38
 
36 39
 		$api = new stdClass();
37 40
 		$api->name = 'WooThemes Updater';
@@ -54,7 +57,9 @@  discard block
 block discarded – undo
54 57
 	 */
55 58
 	function woothemes_updater_notice() {
56 59
 		$active_plugins = apply_filters( 'active_plugins', get_option('active_plugins' ) );
57
-		if ( in_array( 'woothemes-updater/woothemes-updater.php', $active_plugins ) ) return;
60
+		if ( in_array( 'woothemes-updater/woothemes-updater.php', $active_plugins ) ) {
61
+			return;
62
+		}
58 63
 
59 64
 		$slug = 'woothemes-updater';
60 65
 		$install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug );
Please login to merge, or discard this patch.
Spacing   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
 /**
4 4
  * Queue updates for the WooUpdater
5 5
  */
6
-if ( ! function_exists( 'woothemes_queue_update' ) ) {
7
-	function woothemes_queue_update( $file, $file_id, $product_id ) {
6
+if ( ! function_exists('woothemes_queue_update')) {
7
+	function woothemes_queue_update($file, $file_id, $product_id) {
8 8
 		global $woothemes_queued_updates;
9 9
 
10
-		if ( ! isset( $woothemes_queued_updates ) )
10
+		if ( ! isset($woothemes_queued_updates))
11 11
 			$woothemes_queued_updates = array();
12 12
 
13 13
 		$plugin             = new stdClass();
@@ -23,56 +23,56 @@  discard block
 block discarded – undo
23 23
  * Load installer for the WooThemes Updater.
24 24
  * @return $api Object
25 25
  */
26
-if ( ! class_exists( 'WooThemes_Updater' ) && ! function_exists( 'woothemes_updater_install' ) ) {
27
-	function woothemes_updater_install( $api, $action, $args ) {
26
+if ( ! class_exists('WooThemes_Updater') && ! function_exists('woothemes_updater_install')) {
27
+	function woothemes_updater_install($api, $action, $args) {
28 28
 		$download_url = 'http://woodojo.s3.amazonaws.com/downloads/woothemes-updater/woothemes-updater.zip';
29 29
 
30
-		if ( 'plugin_information' != $action ||
30
+		if ('plugin_information' != $action ||
31 31
 			false !== $api ||
32
-			! isset( $args->slug ) ||
32
+			! isset($args->slug) ||
33 33
 			'woothemes-updater' != $args->slug
34 34
 		) return $api;
35 35
 
36 36
 		$api = new stdClass();
37 37
 		$api->name = 'WooThemes Updater';
38 38
 		$api->version = '';
39
-		$api->download_link = esc_url( $download_url );
39
+		$api->download_link = esc_url($download_url);
40 40
 		return $api;
41 41
 	}
42 42
 
43
-	add_filter( 'plugins_api', 'woothemes_updater_install', 10, 3 );
43
+	add_filter('plugins_api', 'woothemes_updater_install', 10, 3);
44 44
 }
45 45
 
46 46
 /**
47 47
  * WooUpdater Installation Prompts
48 48
  */
49
-if ( ! class_exists( 'WooThemes_Updater' ) && ! function_exists( 'woothemes_updater_notice' ) ) {
49
+if ( ! class_exists('WooThemes_Updater') && ! function_exists('woothemes_updater_notice')) {
50 50
 
51 51
 	/**
52 52
 	 * Display a notice if the "WooThemes Updater" plugin hasn't been installed.
53 53
 	 * @return void
54 54
 	 */
55 55
 	function woothemes_updater_notice() {
56
-		$active_plugins = apply_filters( 'active_plugins', get_option('active_plugins' ) );
57
-		if ( in_array( 'woothemes-updater/woothemes-updater.php', $active_plugins ) ) return;
56
+		$active_plugins = apply_filters('active_plugins', get_option('active_plugins'));
57
+		if (in_array('woothemes-updater/woothemes-updater.php', $active_plugins)) return;
58 58
 
59 59
 		$slug = 'woothemes-updater';
60
-		$install_url = wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $slug ), 'install-plugin_' . $slug );
61
-		$activate_url = 'plugins.php?action=activate&plugin=' . urlencode( 'woothemes-updater/woothemes-updater.php' ) . '&plugin_status=all&paged=1&s&_wpnonce=' . urlencode( wp_create_nonce( 'activate-plugin_woothemes-updater/woothemes-updater.php' ) );
60
+		$install_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin='.$slug), 'install-plugin_'.$slug);
61
+		$activate_url = 'plugins.php?action=activate&plugin='.urlencode('woothemes-updater/woothemes-updater.php').'&plugin_status=all&paged=1&s&_wpnonce='.urlencode(wp_create_nonce('activate-plugin_woothemes-updater/woothemes-updater.php'));
62 62
 
63
-		$message = '<a href="' . esc_url( $install_url ) . '">Install the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
63
+		$message = '<a href="'.esc_url($install_url).'">Install the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
64 64
 		$is_downloaded = false;
65
-		$plugins = array_keys( get_plugins() );
66
-		foreach ( $plugins as $plugin ) {
67
-			if ( strpos( $plugin, 'woothemes-updater.php' ) !== false ) {
65
+		$plugins = array_keys(get_plugins());
66
+		foreach ($plugins as $plugin) {
67
+			if (strpos($plugin, 'woothemes-updater.php') !== false) {
68 68
 				$is_downloaded = true;
69
-				$message = '<a href="' . esc_url( admin_url( $activate_url ) ) . '">Activate the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
69
+				$message = '<a href="'.esc_url(admin_url($activate_url)).'">Activate the WooThemes Updater plugin</a> to get updates for your WooThemes plugins.';
70 70
 			}
71 71
 		}
72
-		echo '<div class="updated fade"><p>' . $message . '</p></div>' . "\n";
72
+		echo '<div class="updated fade"><p>'.$message.'</p></div>'."\n";
73 73
 	}
74 74
 
75
-	add_action( 'admin_notices', 'woothemes_updater_notice' );
75
+	add_action('admin_notices', 'woothemes_updater_notice');
76 76
 }
77 77
 
78 78
 /**
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
  * @param  $version Version to check against
82 82
  * @return @boolean
83 83
  */
84
-if( ! function_exists( 'sensei_check_woocommerce_version' ) ) {
85
-	function sensei_check_woocommerce_version( $version = '2.1' ) {
86
-		if ( Sensei_WC::is_woocommerce_active() ) {
84
+if ( ! function_exists('sensei_check_woocommerce_version')) {
85
+	function sensei_check_woocommerce_version($version = '2.1') {
86
+		if (Sensei_WC::is_woocommerce_active()) {
87 87
 			global $woocommerce;
88
-			if( version_compare( $woocommerce->version, $version, ">=" ) ) {
88
+			if (version_compare($woocommerce->version, $version, ">=")) {
89 89
 			    return true;
90 90
 			}
91 91
 		}
Please login to merge, or discard this patch.
includes/class-sensei-analysis-lesson-list-table.php 3 patches
Braces   +9 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis Lesson List Table Class
@@ -204,31 +207,26 @@  discard block
 block discarded – undo
204 207
 			$status_class = 'graded';
205 208
 
206 209
 			$grade =  __( 'No Grade', 'woothemes-sensei' );
207
-		}
208
-		elseif( 'graded' == $item->comment_approved ) {
210
+		} elseif( 'graded' == $item->comment_approved ) {
209 211
 			$status = __( 'Graded', 'woothemes-sensei' ) ;
210 212
 			$status_class = 'graded';
211 213
 
212 214
 			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
213
-		}
214
-		elseif( 'passed' == $item->comment_approved ) {
215
+		} elseif( 'passed' == $item->comment_approved ) {
215 216
 			$status =  __( 'Passed', 'woothemes-sensei' );
216 217
 			$status_class = 'graded';
217 218
 
218 219
 			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
219
-		}
220
-		elseif( 'failed' == $item->comment_approved ) {
220
+		} elseif( 'failed' == $item->comment_approved ) {
221 221
 			$status = __( 'Failed', 'woothemes-sensei' );
222 222
 			$status_class = 'failed';
223 223
 
224 224
 			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
225
-		}
226
-		elseif( 'ungraded' == $item->comment_approved ) {
225
+		} elseif( 'ungraded' == $item->comment_approved ) {
227 226
 			$status =  __( 'Ungraded', 'woothemes-sensei' );
228 227
 			$status_class = 'ungraded';
229 228
 
230
-		}
231
-		else {
229
+		} else {
232 230
 			$status =  __( 'In Progress', 'woothemes-sensei' );
233 231
 			$user_end_date = '';
234 232
 		}
Please login to merge, or discard this patch.
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
 		}
231 231
 
232 232
 		// Output users data
233
-        $user_name = Sensei_Learner::get_full_name( $item->user_id );
233
+		$user_name = Sensei_Learner::get_full_name( $item->user_id );
234 234
 
235
-        if ( !$this->csv_output ) {
235
+		if ( !$this->csv_output ) {
236 236
 			$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) );
237 237
 
238 238
 			$user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>';
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 	 */
340 340
 	public function search_button( $text = '' ) {
341 341
 
342
-        $text =  __( 'Search Learners', 'woothemes-sensei' );
342
+		$text =  __( 'Search Learners', 'woothemes-sensei' );
343 343
 
344
-        return $text;
344
+		return $text;
345 345
 
346 346
 	}
347 347
 } // End Class
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Admin Analysis Lesson Data Table in Sensei.
@@ -18,18 +18,18 @@  discard block
 block discarded – undo
18 18
 	 * Constructor
19 19
 	 * @since  1.2.0
20 20
 	 */
21
-	public function __construct ( $lesson_id = 0 ) {
22
-		$this->lesson_id = intval( $lesson_id );
23
-		$this->course_id = intval( get_post_meta( $this->lesson_id, '_lesson_course', true ) );
21
+	public function __construct($lesson_id = 0) {
22
+		$this->lesson_id = intval($lesson_id);
23
+		$this->course_id = intval(get_post_meta($this->lesson_id, '_lesson_course', true));
24 24
 
25 25
 		// Load Parent token into constructor
26
-		parent::__construct( 'analysis_lesson' );
26
+		parent::__construct('analysis_lesson');
27 27
 
28 28
 		// Actions
29
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
30
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
29
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
30
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
31 31
 
32
-		add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) );
32
+		add_filter('sensei_list_table_search_button_text', array($this, 'search_button'));
33 33
 	} // End __construct()
34 34
 
35 35
 	/**
@@ -39,13 +39,13 @@  discard block
 block discarded – undo
39 39
 	 */
40 40
 	function get_columns() {
41 41
 		$columns = array(
42
-			'title' => __( 'Learner', 'woothemes-sensei' ),
43
-			'started' => __( 'Date Started', 'woothemes-sensei' ),
44
-			'completed' => __( 'Date Completed', 'woothemes-sensei' ),
45
-			'status' => __( 'Status', 'woothemes-sensei' ),
46
-			'grade' => __( 'Grade', 'woothemes-sensei' ),
42
+			'title' => __('Learner', 'woothemes-sensei'),
43
+			'started' => __('Date Started', 'woothemes-sensei'),
44
+			'completed' => __('Date Completed', 'woothemes-sensei'),
45
+			'status' => __('Status', 'woothemes-sensei'),
46
+			'grade' => __('Grade', 'woothemes-sensei'),
47 47
 		);
48
-		$columns = apply_filters( 'sensei_analysis_lesson_columns', $columns, $this );
48
+		$columns = apply_filters('sensei_analysis_lesson_columns', $columns, $this);
49 49
 		return $columns;
50 50
 	}
51 51
 
@@ -56,13 +56,13 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	function get_sortable_columns() {
58 58
 		$columns = array(
59
-			'title' => array( 'title', false ),
60
-			'started' => array( 'started', false ),
61
-			'completed' => array( 'completed', false ),
62
-			'status' => array( 'status', false ),
63
-			'grade' => array( 'grade', false ),
59
+			'title' => array('title', false),
60
+			'started' => array('started', false),
61
+			'completed' => array('completed', false),
62
+			'status' => array('status', false),
63
+			'grade' => array('grade', false),
64 64
 		);
65
-		$columns = apply_filters( 'sensei_analysis_lesson_columns_sortable', $columns, $this );
65
+		$columns = apply_filters('sensei_analysis_lesson_columns_sortable', $columns, $this);
66 66
 		return $columns;
67 67
 	}
68 68
 
@@ -76,32 +76,32 @@  discard block
 block discarded – undo
76 76
 
77 77
 		// Handle orderby (needs work)
78 78
 		$orderby = '';
79
-		if ( !empty( $_GET['orderby'] ) ) {
80
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
81
-				$orderby = esc_html( $_GET['orderby'] );
79
+		if ( ! empty($_GET['orderby'])) {
80
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
81
+				$orderby = esc_html($_GET['orderby']);
82 82
 			} // End If Statement
83 83
 		}
84 84
 
85 85
 		// Handle order
86 86
 		$order = 'ASC';
87
-		if ( !empty( $_GET['order'] ) ) {
88
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
87
+		if ( ! empty($_GET['order'])) {
88
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
89 89
 		}
90 90
 
91 91
 		// Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids
92 92
 		$search = false;
93
-		if ( !empty( $_GET['s'] ) ) {
94
-			$search = esc_html( $_GET['s'] );
93
+		if ( ! empty($_GET['s'])) {
94
+			$search = esc_html($_GET['s']);
95 95
 		} // End If Statement
96 96
 		$this->search = $search;
97 97
 
98
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
99
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
98
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
99
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
100 100
 
101 101
 		$paged = $this->get_pagenum();
102 102
 		$offset = 0;
103
-		if ( !empty($paged) ) {
104
-			$offset = $per_page * ( $paged - 1 );
103
+		if ( ! empty($paged)) {
104
+			$offset = $per_page * ($paged - 1);
105 105
 		} // End If Statement
106 106
 
107 107
 		$args = array(
@@ -110,19 +110,19 @@  discard block
 block discarded – undo
110 110
 			'orderby' => $orderby,
111 111
 			'order' => $order,
112 112
 		);
113
-		if ( $this->search ) {
113
+		if ($this->search) {
114 114
 			$args['search'] = $this->search;
115 115
 		} // End If Statement
116 116
 
117
-		$this->items = $this->get_lesson_statuses( $args );
117
+		$this->items = $this->get_lesson_statuses($args);
118 118
 
119 119
 		$total_items = $this->total_items;
120
-		$total_pages = ceil( $total_items / $per_page );
121
-		$this->set_pagination_args( array(
120
+		$total_pages = ceil($total_items / $per_page);
121
+		$this->set_pagination_args(array(
122 122
 			'total_items' => $total_items,
123 123
 			'total_pages' => $total_pages,
124 124
 			'per_page' => $per_page
125
-		) );
125
+		));
126 126
 	}
127 127
 
128 128
 	/**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
 	 * @since  1.7.0
131 131
 	 * @return data
132 132
 	 */
133
-	public function generate_report( $report ) {
133
+	public function generate_report($report) {
134 134
 
135 135
 		$data = array();
136 136
 
@@ -138,22 +138,22 @@  discard block
 block discarded – undo
138 138
 
139 139
 		// Handle orderby
140 140
 		$orderby = '';
141
-		if ( !empty( $_GET['orderby'] ) ) {
142
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
143
-				$orderby = esc_html( $_GET['orderby'] );
141
+		if ( ! empty($_GET['orderby'])) {
142
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
143
+				$orderby = esc_html($_GET['orderby']);
144 144
 			} // End If Statement
145 145
 		}
146 146
 
147 147
 		// Handle order
148 148
 		$order = 'ASC';
149
-		if ( !empty( $_GET['order'] ) ) {
150
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
149
+		if ( ! empty($_GET['order'])) {
150
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
151 151
 		}
152 152
 
153 153
 		// Handle search
154 154
 		$search = false;
155
-		if ( !empty( $_GET['s'] ) ) {
156
-			$search = esc_html( $_GET['s'] );
155
+		if ( ! empty($_GET['s'])) {
156
+			$search = esc_html($_GET['s']);
157 157
 		} // End If Statement
158 158
 		$this->search = $search;
159 159
 
@@ -161,23 +161,23 @@  discard block
 block discarded – undo
161 161
 			'orderby' => $orderby,
162 162
 			'order' => $order,
163 163
 		);
164
-		if ( $this->search ) {
164
+		if ($this->search) {
165 165
 			$args['search'] = $this->search;
166 166
 		} // End If Statement
167 167
 
168 168
 		// Start the csv with the column headings
169 169
 		$column_headers = array();
170 170
 		$columns = $this->get_columns();
171
-		foreach( $columns AS $key => $title ) {
171
+		foreach ($columns AS $key => $title) {
172 172
 			$column_headers[] = $title;
173 173
 		}
174 174
 		$data[] = $column_headers;
175 175
 
176
-		$this->items = $this->get_lesson_statuses( $args );
176
+		$this->items = $this->get_lesson_statuses($args);
177 177
 
178 178
 		// Process each row
179
-		foreach( $this->items AS $item) {
180
-			$data[] = $this->get_row_data( $item );
179
+		foreach ($this->items AS $item) {
180
+			$data[] = $this->get_row_data($item);
181 181
 		}
182 182
 
183 183
 		return $data;
@@ -189,64 +189,64 @@  discard block
 block discarded – undo
189 189
 	 * @since  1.7.0
190 190
 	 * @param object $item The current item
191 191
 	 */
192
-	protected function get_row_data( $item ) {
192
+	protected function get_row_data($item) {
193 193
 
194
-		$user_start_date = get_comment_meta( $item->comment_ID, 'start', true );
194
+		$user_start_date = get_comment_meta($item->comment_ID, 'start', true);
195 195
 		$user_end_date = $item->comment_date;
196 196
 		$status_class = $grade = '';
197 197
 
198
-		if( 'complete' == $item->comment_approved ) {
199
-			$status =  __( 'Completed', 'woothemes-sensei' );
198
+		if ('complete' == $item->comment_approved) {
199
+			$status = __('Completed', 'woothemes-sensei');
200 200
 			$status_class = 'graded';
201 201
 
202
-			$grade =  __( 'No Grade', 'woothemes-sensei' );
202
+			$grade = __('No Grade', 'woothemes-sensei');
203 203
 		}
204
-		elseif( 'graded' == $item->comment_approved ) {
205
-			$status = __( 'Graded', 'woothemes-sensei' ) ;
204
+		elseif ('graded' == $item->comment_approved) {
205
+			$status = __('Graded', 'woothemes-sensei');
206 206
 			$status_class = 'graded';
207 207
 
208
-			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
208
+			$grade = get_comment_meta($item->comment_ID, 'grade', true);
209 209
 		}
210
-		elseif( 'passed' == $item->comment_approved ) {
211
-			$status =  __( 'Passed', 'woothemes-sensei' );
210
+		elseif ('passed' == $item->comment_approved) {
211
+			$status = __('Passed', 'woothemes-sensei');
212 212
 			$status_class = 'graded';
213 213
 
214
-			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
214
+			$grade = get_comment_meta($item->comment_ID, 'grade', true);
215 215
 		}
216
-		elseif( 'failed' == $item->comment_approved ) {
217
-			$status = __( 'Failed', 'woothemes-sensei' );
216
+		elseif ('failed' == $item->comment_approved) {
217
+			$status = __('Failed', 'woothemes-sensei');
218 218
 			$status_class = 'failed';
219 219
 
220
-			$grade = get_comment_meta( $item->comment_ID, 'grade', true);
220
+			$grade = get_comment_meta($item->comment_ID, 'grade', true);
221 221
 		}
222
-		elseif( 'ungraded' == $item->comment_approved ) {
223
-			$status =  __( 'Ungraded', 'woothemes-sensei' );
222
+		elseif ('ungraded' == $item->comment_approved) {
223
+			$status = __('Ungraded', 'woothemes-sensei');
224 224
 			$status_class = 'ungraded';
225 225
 
226 226
 		}
227 227
 		else {
228
-			$status =  __( 'In Progress', 'woothemes-sensei' );
228
+			$status = __('In Progress', 'woothemes-sensei');
229 229
 			$user_end_date = '';
230 230
 		}
231 231
 
232 232
 		// Output users data
233
-        $user_name = Sensei_Learner::get_full_name( $item->user_id );
233
+        $user_name = Sensei_Learner::get_full_name($item->user_id);
234 234
 
235
-        if ( !$this->csv_output ) {
236
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) );
235
+        if ( ! $this->csv_output) {
236
+			$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id), admin_url('admin.php'));
237 237
 
238
-			$user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>';
239
-			$status = sprintf( '<span class="%s">%s</span>', $item->comment_approved, $status );
240
-			if ( is_numeric($grade) ) {
238
+			$user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$user_name.'</a></strong>';
239
+			$status = sprintf('<span class="%s">%s</span>', $item->comment_approved, $status);
240
+			if (is_numeric($grade)) {
241 241
 				$grade .= '%';
242 242
 			}
243 243
 		} // End If Statement
244
-		$column_data = apply_filters( 'sensei_analysis_lesson_column_data', array( 'title' => $user_name,
244
+		$column_data = apply_filters('sensei_analysis_lesson_column_data', array('title' => $user_name,
245 245
 										'started' => $user_start_date,
246 246
 										'completed' => $user_end_date,
247 247
 										'status' => $status,
248 248
 										'grade' => $grade,
249
-									), $item, $this );
249
+									), $item, $this);
250 250
 
251 251
 		return $column_data;
252 252
 	}
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 	 * @since  1.7.0
257 257
 	 * @return array statuses
258 258
 	 */
259
-	private function get_lesson_statuses( $args ) {
259
+	private function get_lesson_statuses($args) {
260 260
 
261 261
 		$activity_args = array( 
262 262
 				'post_id' => $this->lesson_id,
@@ -269,34 +269,34 @@  discard block
 block discarded – undo
269 269
 			);
270 270
 
271 271
 		// Searching users on statuses requires sub-selecting the statuses by user_ids
272
-		if ( $this->search ) {
272
+		if ($this->search) {
273 273
 			$user_args = array(
274
-				'search' => '*' . $this->search . '*',
274
+				'search' => '*'.$this->search.'*',
275 275
 				'fields' => 'ID',
276 276
 			);
277 277
 			// Filter for extending
278
-			$user_args = apply_filters( 'sensei_analysis_lesson_search_users', $user_args );
279
-			if ( !empty( $user_args ) ) {
280
-				$learners_search = new WP_User_Query( $user_args );
278
+			$user_args = apply_filters('sensei_analysis_lesson_search_users', $user_args);
279
+			if ( ! empty($user_args)) {
280
+				$learners_search = new WP_User_Query($user_args);
281 281
 				// Store for reuse on counts
282 282
 				$activity_args['user_id'] = (array) $learners_search->get_results();
283 283
 			}
284 284
 		} // End If Statement
285 285
 
286
-		$activity_args = apply_filters( 'sensei_analysis_lesson_filter_statuses', $activity_args );
286
+		$activity_args = apply_filters('sensei_analysis_lesson_filter_statuses', $activity_args);
287 287
 
288 288
 		// WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice
289
-		$this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
289
+		$this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0)));
290 290
 
291 291
 		// Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views?
292
-		if ( $this->total_items < $activity_args['offset'] ) {
293
-			$new_paged = floor( $total_statuses / $activity_args['number'] );
292
+		if ($this->total_items < $activity_args['offset']) {
293
+			$new_paged = floor($total_statuses / $activity_args['number']);
294 294
 			$activity_args['offset'] = $new_paged * $activity_args['number'];
295 295
 		}
296
-		$statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true );
296
+		$statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true);
297 297
 		// Need to always return an array, even with only 1 item
298
-		if ( !is_array($statuses) ) {
299
-			$statuses = array( $statuses );
298
+		if ( ! is_array($statuses)) {
299
+			$statuses = array($statuses);
300 300
 		}
301 301
 		return $statuses;
302 302
 	} // End get_lesson_statuses()
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 * @return void
309 309
 	 */
310 310
 	public function no_items() {
311
-		 _e( 'No learners found.', 'woothemes-sensei' );
311
+		 _e('No learners found.', 'woothemes-sensei');
312 312
 	} // End no_items()
313 313
 
314 314
 	/**
@@ -317,7 +317,7 @@  discard block
 block discarded – undo
317 317
 	 * @return void
318 318
 	 */
319 319
 	public function data_table_header() {
320
-		echo '<strong>' . __( 'Learners taking this Lesson', 'woothemes-sensei' ) . '</strong>';
320
+		echo '<strong>'.__('Learners taking this Lesson', 'woothemes-sensei').'</strong>';
321 321
 	} // End data_table_header()
322 322
 
323 323
 	/**
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
 	 * @return void
327 327
 	 */
328 328
 	public function data_table_footer() {
329
-		$lesson = get_post( $this->lesson_id );
330
-		$report = sanitize_title( $lesson->post_title ) . '-learners-overview';
331
-		$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $this->lesson_id, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) );
332
-		echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>';
329
+		$lesson = get_post($this->lesson_id);
330
+		$report = sanitize_title($lesson->post_title).'-learners-overview';
331
+		$url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $this->lesson_id, 'sensei_report_download' => $report), admin_url('admin.php'));
332
+		echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>';
333 333
 	} // End data_table_footer()
334 334
 
335 335
 	/**
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
 	 * @since  1.7.0
338 338
 	 * @return string $text
339 339
 	 */
340
-	public function search_button( $text = '' ) {
340
+	public function search_button($text = '') {
341 341
 
342
-        $text =  __( 'Search Learners', 'woothemes-sensei' );
342
+        $text = __('Search Learners', 'woothemes-sensei');
343 343
 
344 344
         return $text;
345 345
 
Please login to merge, or discard this patch.
includes/class-sensei-course.php 4 patches
Braces   +12 added lines, -10 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 Class
@@ -614,7 +617,7 @@  discard block
 block discarded – undo
614 617
 
615 618
 			return $results_array;
616 619
 
617
-		}else{
620
+		} else{
618 621
 
619 622
 			//reset the pagination as this widgets do not need it
620 623
 			$post_args['paged'] = 1;
@@ -835,7 +838,7 @@  discard block
 block discarded – undo
835 838
 
836 839
             return $html;
837 840
 
838
-        }else{
841
+        } else{
839 842
 
840 843
             echo $html;
841 844
 
@@ -982,8 +985,7 @@  discard block
 block discarded – undo
982 985
 				$has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
983 986
 				if ( $has_questions && $boolean_check ) {
984 987
 					return true;
985
-				}
986
-				elseif ( $has_questions ) {
988
+				} elseif ( $has_questions ) {
987 989
 					$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
988 990
 //					$questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
989 991
 //					if( count( $questions ) > 0 ) {
@@ -1805,11 +1807,11 @@  discard block
 block discarded – undo
1805 1807
 
1806 1808
             $course_id = $email['course_id'];
1807 1809
 
1808
-        }elseif( isset( $email['lesson_id'] ) ){
1810
+        } elseif( isset( $email['lesson_id'] ) ){
1809 1811
 
1810 1812
             $course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] );
1811 1813
 
1812
-        }elseif( isset( $email['quiz_id'] ) ){
1814
+        } elseif( isset( $email['quiz_id'] ) ){
1813 1815
 
1814 1816
             $lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] );
1815 1817
             $course_id = Sensei()->lesson->get_course_id( $lesson_id );
@@ -1870,7 +1872,7 @@  discard block
 block discarded – undo
1870 1872
 
1871 1873
         if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification']  ) {
1872 1874
             $new_val = true;
1873
-        }else{
1875
+        } else{
1874 1876
             $new_val = false;
1875 1877
         }
1876 1878
 
@@ -2009,7 +2011,7 @@  discard block
 block discarded – undo
2009 2011
 
2010 2012
                 $classes[] = 'user-status-completed';
2011 2013
 
2012
-            }else{
2014
+            } else{
2013 2015
 
2014 2016
                 $classes[] = 'user-status-active';
2015 2017
 
@@ -2826,7 +2828,7 @@  discard block
 block discarded – undo
2826 2828
 
2827 2829
             $title = $term->name;
2828 2830
 
2829
-        }else{
2831
+        } else{
2830 2832
 
2831 2833
             $title = 'Course Category';
2832 2834
 
Please login to merge, or discard this patch.
Doc Comments   -2 removed lines patch added patch discarded remove patch
@@ -848,7 +848,6 @@  discard block
 block discarded – undo
848 848
 	 * course_count function.
849 849
 	 *
850 850
 	 * @access public
851
-	 * @param array $exclude (default: array())
852 851
 	 * @param string $post_status (default: 'publish')
853 852
 	 * @return int
854 853
 	 */
@@ -1159,7 +1158,6 @@  discard block
 block discarded – undo
1159 1158
      *
1160 1159
 	 * @since  1.4.0
1161 1160
 	 * @param  object  $user   Queried user object
1162
-	 * @param  boolean $manage Whether the user has permission to manage the courses
1163 1161
 	 * @return string          HTML displayng course data
1164 1162
 	 */
1165 1163
 	public function load_user_courses_content( $user = false ) {
Please login to merge, or discard this patch.
Indentation   +1417 added lines, -1417 removed lines patch added patch discarded remove patch
@@ -13,21 +13,21 @@  discard block
 block discarded – undo
13 13
  * @since 1.0.0
14 14
  */
15 15
 class Sensei_Course {
16
-    /**
17
-     * @var $token
18
-     */
16
+	/**
17
+	 * @var $token
18
+	 */
19 19
 	public $token;
20 20
 
21
-    /**
22
-     * @var array $meta_fields
23
-     */
21
+	/**
22
+	 * @var array $meta_fields
23
+	 */
24 24
 	public $meta_fields;
25 25
 
26
-    /**
27
-     * @var string|bool $my_courses_page reference to the sites
28
-     * my courses page, false if none was set
29
-     */
30
-    public  $my_courses_page;
26
+	/**
27
+	 * @var string|bool $my_courses_page reference to the sites
28
+	 * my courses page, false if none was set
29
+	 */
30
+	public  $my_courses_page;
31 31
 
32 32
 	/**
33 33
 	 * Constructor.
@@ -35,14 +35,14 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public function __construct () {
37 37
 
38
-        $this->token = 'course';
38
+		$this->token = 'course';
39 39
 
40 40
 		// Setup meta fields for this post type
41 41
 		$this->meta_fields = array( 'course_prerequisite', 'course_featured', 'course_video_embed', 'course_woocommerce_product' );
42 42
 		// Admin actions
43 43
 		if ( is_admin() ) {
44 44
 			// Metabox functions
45
-            add_action( 'add_meta_boxes', array( $this, 'meta_box_setup' ), 20 );
45
+			add_action( 'add_meta_boxes', array( $this, 'meta_box_setup' ), 20 );
46 46
 			add_action( 'save_post', array( $this, 'meta_box_save' ) );
47 47
 			// Custom Write Panel Columns
48 48
 			add_filter( 'manage_edit-course_columns', array( $this, 'add_column_headings' ), 10, 1 );
@@ -58,47 +58,47 @@  discard block
 block discarded – undo
58 58
 		// Update course completion upon grading of a quiz
59 59
 		add_action( 'sensei_user_quiz_grade', array( $this, 'update_status_after_quiz_submission' ), 10, 2 );
60 60
 
61
-        // show the progress bar ont he single course page
62
-        add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_statement' ), 15 );
63
-        add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_meter' ), 16 );
61
+		// show the progress bar ont he single course page
62
+		add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_statement' ), 15 );
63
+		add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_meter' ), 16 );
64 64
 
65
-        // provide an option to block all emails related to a selected course
66
-        add_filter( 'sensei_send_emails', array( $this, 'block_notification_emails' ) );
67
-        add_action( 'save_post', array( $this, 'save_course_notification_meta_box' ) );
65
+		// provide an option to block all emails related to a selected course
66
+		add_filter( 'sensei_send_emails', array( $this, 'block_notification_emails' ) );
67
+		add_action( 'save_post', array( $this, 'save_course_notification_meta_box' ) );
68 68
 
69
-        // preview lessons on the course content
70
-        add_action( 'sensei_course_content_inside_after',array( $this, 'the_course_free_lesson_preview' ) );
69
+		// preview lessons on the course content
70
+		add_action( 'sensei_course_content_inside_after',array( $this, 'the_course_free_lesson_preview' ) );
71 71
 
72
-        // the course meta
73
-        add_action('sensei_course_content_inside_before', array( $this, 'the_course_meta' ) );
72
+		// the course meta
73
+		add_action('sensei_course_content_inside_before', array( $this, 'the_course_meta' ) );
74 74
 
75
-        // backwards compatible template hooks
76
-        add_action('sensei_course_content_inside_before', array( $this, 'content_before_backwards_compatibility_hooks' ));
77
-        add_action('sensei_loop_course_before', array( $this,'loop_before_backwards_compatibility_hooks' ) );
75
+		// backwards compatible template hooks
76
+		add_action('sensei_course_content_inside_before', array( $this, 'content_before_backwards_compatibility_hooks' ));
77
+		add_action('sensei_loop_course_before', array( $this,'loop_before_backwards_compatibility_hooks' ) );
78 78
 
79
-        // add the user status on the course to the markup as a class
80
-        add_filter('post_class', array( __CLASS__ , 'add_course_user_status_class' ), 20, 3 );
79
+		// add the user status on the course to the markup as a class
80
+		add_filter('post_class', array( __CLASS__ , 'add_course_user_status_class' ), 20, 3 );
81 81
 
82
-        //filter the course query in Sensei specific instances
83
-        add_filter( 'pre_get_posts', array( __CLASS__, 'course_query_filter' ) );
82
+		//filter the course query in Sensei specific instances
83
+		add_filter( 'pre_get_posts', array( __CLASS__, 'course_query_filter' ) );
84 84
 
85
-        //attache the sorting to the course archive
86
-        add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_sorting' ) );
85
+		//attache the sorting to the course archive
86
+		add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_sorting' ) );
87 87
 
88
-        //attach the filter links to the course archive
89
-        add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_filters' ) );
88
+		//attach the filter links to the course archive
89
+		add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_filters' ) );
90 90
 
91
-        //filter the course query when featured filter is applied
92
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'course_archive_featured_filter'));
91
+		//filter the course query when featured filter is applied
92
+		add_filter( 'pre_get_posts',  array( __CLASS__, 'course_archive_featured_filter'));
93 93
 
94
-        // handle the order by title post submission
95
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'course_archive_order_by_title'));
94
+		// handle the order by title post submission
95
+		add_filter( 'pre_get_posts',  array( __CLASS__, 'course_archive_order_by_title'));
96 96
 
97
-        // ensure the course category page respects the manual order set for courses
98
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'alter_course_category_order'));
97
+		// ensure the course category page respects the manual order set for courses
98
+		add_filter( 'pre_get_posts',  array( __CLASS__, 'alter_course_category_order'));
99 99
 
100
-        // flush rewrite rules when saving a course
101
-        add_action('save_post', array( 'Sensei_Course', 'flush_rewrite_rules' ) );
100
+		// flush rewrite rules when saving a course
101
+		add_action('save_post', array( 'Sensei_Course', 'flush_rewrite_rules' ) );
102 102
 
103 103
 	} // End __construct()
104 104
 
@@ -151,13 +151,13 @@  discard block
 block discarded – undo
151 151
 		add_meta_box( 'course-video', __( 'Course Video', 'woothemes-sensei' ), array( $this, 'course_video_meta_box_content' ), $this->token, 'normal', 'default' );
152 152
 		// Add Meta Box for Course Lessons
153 153
 		add_meta_box( 'course-lessons', __( 'Course Lessons', 'woothemes-sensei' ), array( $this, 'course_lessons_meta_box_content' ), $this->token, 'normal', 'default' );
154
-        // Add Meta Box to link to Manage Learners
155
-        add_meta_box( 'course-manage', __( 'Course Management', 'woothemes-sensei' ), array( $this, 'course_manage_meta_box_content' ), $this->token, 'side', 'default' );
156
-        // Remove "Custom Settings" meta box.
154
+		// Add Meta Box to link to Manage Learners
155
+		add_meta_box( 'course-manage', __( 'Course Management', 'woothemes-sensei' ), array( $this, 'course_manage_meta_box_content' ), $this->token, 'side', 'default' );
156
+		// Remove "Custom Settings" meta box.
157 157
 		remove_meta_box( 'woothemes-settings', $this->token, 'normal' );
158 158
 
159
-        // add Disable email notification box
160
-        add_meta_box( 'course-notifications', __( 'Course Notifications', 'woothemes-sensei' ), array( $this, 'course_notification_meta_box_content' ), 'course', 'normal', 'default' );
159
+		// add Disable email notification box
160
+		add_meta_box( 'course-notifications', __( 'Course Notifications', 'woothemes-sensei' ), array( $this, 'course_notification_meta_box_content' ), 'course', 'normal', 'default' );
161 161
 
162 162
 	} // End meta_box_setup()
163 163
 
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 		$post_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
176 176
 							'posts_per_page' 		=> -1,
177 177
 							'orderby'         	=> 'title',
178
-    						'order'           	=> 'DESC',
179
-    						'exclude' 			=> $post->ID,
180
-    						'post_status'		=> array( 'publish', 'private', 'draft' ),
181
-    						'tax_query'			=> array(
178
+							'order'           	=> 'DESC',
179
+							'exclude' 			=> $post->ID,
180
+							'post_status'		=> array( 'publish', 'private', 'draft' ),
181
+							'tax_query'			=> array(
182 182
 								array(
183 183
 									'taxonomy'	=> 'product_type',
184 184
 									'field'		=> 'slug',
@@ -206,21 +206,21 @@  discard block
 block discarded – undo
206 206
 						$product_object = get_product( $post_item->ID );
207 207
 						$parent_id = wp_get_post_parent_id( $post_item->ID );
208 208
 
209
-                        if( sensei_check_woocommerce_version( '2.1' ) ) {
209
+						if( sensei_check_woocommerce_version( '2.1' ) ) {
210 210
 							$formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true );
211 211
 
212 212
 						} else {
213
-                            // fall back to pre wc 2.1
213
+							// fall back to pre wc 2.1
214 214
 							$formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true );
215 215
 
216 216
 						}
217 217
 
218
-                        $product_name = ucwords( $formatted_variation );
219
-                        if( empty( $product_name ) ){
218
+						$product_name = ucwords( $formatted_variation );
219
+						if( empty( $product_name ) ){
220 220
 
221
-                            $product_name = __( 'Variation #', 'woothemes-sensei' ) . $product_object->variation_id;
221
+							$product_name = __( 'Variation #', 'woothemes-sensei' ) . $product_object->variation_id;
222 222
 
223
-                        }
223
+						}
224 224
 
225 225
 					} else {
226 226
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 
271 271
 			} else {
272 272
 
273
-                $html .= '<p>' . "\n";
273
+				$html .= '<p>' . "\n";
274 274
 					$html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . "\n";
275 275
 				$html .= '</p>'."\n";
276 276
 
@@ -296,8 +296,8 @@  discard block
 block discarded – undo
296 296
 		$post_args = array(	'post_type' 		=> 'course',
297 297
 							'posts_per_page' 		=> -1,
298 298
 							'orderby'         	=> 'title',
299
-    						'order'           	=> 'DESC',
300
-    						'exclude' 			=> $post->ID,
299
+							'order'           	=> 'DESC',
300
+							'exclude' 			=> $post->ID,
301 301
 							'suppress_filters' 	=> 0
302 302
 							);
303 303
 		$posts_array = get_posts( $post_args );
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
 
339 339
 		$checked = '';
340 340
 		if ( isset( $course_featured ) && ( '' != $course_featured ) ) {
341
-	 	    $checked = checked( 'featured', $course_featured, false );
341
+	 		$checked = checked( 'featured', $course_featured, false );
342 342
 	 	} // End If Statement
343 343
 
344 344
 	 	$html .= '<input type="checkbox" name="course_featured" value="featured" ' . $checked . '>&nbsp;' . __( 'Feature this course', 'woothemes-sensei' ) . '<br>';
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
434 434
 		} // End If Statement
435 435
 
436
-        // update field with the new value
437
-        return update_post_meta( $post_id, $meta_key, $new_meta_value );
436
+		// update field with the new value
437
+		return update_post_meta( $post_id, $meta_key, $new_meta_value );
438 438
 
439 439
 	} // End save_post_meta()
440 440
 
@@ -458,8 +458,8 @@  discard block
 block discarded – undo
458 458
 
459 459
 		$html = '';
460 460
 		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="'
461
-                 . esc_attr( 'woo_' . $this->token . '_noonce' )
462
-                 . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
461
+				 . esc_attr( 'woo_' . $this->token . '_noonce' )
462
+				 . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
463 463
 
464 464
 		if ( count( $posts_array ) > 0 ) {
465 465
 
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 			$html .= '<p>' . esc_html( __( 'No lessons exist yet for this course.', 'woothemes-sensei' ) ) . "\n";
481 481
 
482 482
 				$html .= '<a href="' . admin_url( 'post-new.php?post_type=lesson' . $course_id )
483
-                         . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '">'
484
-                         . __( 'Please add some.', 'woothemes-sensei' ) . '</a>' . "\n";
483
+						 . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '">'
484
+						 . __( 'Please add some.', 'woothemes-sensei' ) . '</a>' . "\n";
485 485
 
486 486
 			$html .= '</p>'."\n";
487 487
 		} // End If Statement
@@ -490,29 +490,29 @@  discard block
 block discarded – undo
490 490
 
491 491
 	} // End course_lessons_meta_box_content()
492 492
 
493
-    /**
494
-     * course_manage_meta_box_content function.
495
-     *
496
-     * @since 1.9.0
497
-     * @access public
498
-     * @return void
499
-     */
493
+	/**
494
+	 * course_manage_meta_box_content function.
495
+	 *
496
+	 * @since 1.9.0
497
+	 * @access public
498
+	 * @return void
499
+	 */
500 500
 
501
-    public function course_manage_meta_box_content () {
502
-        global $post;
501
+	public function course_manage_meta_box_content () {
502
+		global $post;
503 503
         
504
-        $manage_url = esc_url( add_query_arg( array( 'page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) );
504
+		$manage_url = esc_url( add_query_arg( array( 'page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) );
505 505
 
506
-        $grading_url = esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) );
506
+		$grading_url = esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) );
507 507
 
508 508
 
509
-        echo "<ul><li><a href='$manage_url'>".__("Manage Learners", 'woothemes-sensei')."</a></li>";
509
+		echo "<ul><li><a href='$manage_url'>".__("Manage Learners", 'woothemes-sensei')."</a></li>";
510 510
 
511
-        echo "<li><a href='$grading_url'>".__("Manage Grading", 'woothemes-sensei')."</a></li></ul>";
511
+		echo "<li><a href='$grading_url'>".__("Manage Grading", 'woothemes-sensei')."</a></li></ul>";
512 512
 
513 513
 
514 514
 
515
-    } // End course_manage_meta_box_content()
515
+	} // End course_manage_meta_box_content()
516 516
 
517 517
 	/**
518 518
 	 * Add column headings to the "lesson" post list screen.
@@ -653,92 +653,92 @@  discard block
 block discarded – undo
653 653
 			} // End If Statement
654 654
 		} // End If Statement
655 655
 
656
-        $stored_order = get_option( 'sensei_course_order', '' );
657
-        $order = 'ASC';
658
-        $orderby = 'menu_order';
659
-        if( empty( $stored_order ) ){
656
+		$stored_order = get_option( 'sensei_course_order', '' );
657
+		$order = 'ASC';
658
+		$orderby = 'menu_order';
659
+		if( empty( $stored_order ) ){
660 660
 
661
-            $order = 'DESC';
662
-            $orderby = 'date';
661
+			$order = 'DESC';
662
+			$orderby = 'date';
663 663
 
664
-        }
664
+		}
665 665
 
666 666
 		switch ($type) {
667 667
 
668 668
 			case 'usercourses':
669 669
 				$post_args = array(	'post_type' 		=> 'course',
670 670
 									'orderby'         	=> $orderby,
671
-    								'order'           	=> $order,
672
-    								'post_status'      	=> 'publish',
673
-    								'include'			=> $includes,
674
-    								'exclude'			=> $excludes,
675
-    								'suppress_filters' 	=> 0
671
+									'order'           	=> $order,
672
+									'post_status'      	=> 'publish',
673
+									'include'			=> $includes,
674
+									'exclude'			=> $excludes,
675
+									'suppress_filters' 	=> 0
676 676
 									);
677 677
 				break;
678 678
 			case 'freecourses':
679 679
 
680
-                $post_args = array(
681
-                    'post_type' 		=> 'course',
682
-                    'orderby'         	=> $orderby,
683
-                    'order'           	=> $order,
684
-                    'post_status'      	=> 'publish',
685
-                    'exclude'			=> $excludes,
686
-                    'suppress_filters' 	=> 0
687
-                );
688
-                // Sub Query to get all WooCommerce Products that have Zero price
689
-                $post_args['meta_query'] = Sensei_WC::get_free_courses_meta_query_args();
680
+				$post_args = array(
681
+					'post_type' 		=> 'course',
682
+					'orderby'         	=> $orderby,
683
+					'order'           	=> $order,
684
+					'post_status'      	=> 'publish',
685
+					'exclude'			=> $excludes,
686
+					'suppress_filters' 	=> 0
687
+				);
688
+				// Sub Query to get all WooCommerce Products that have Zero price
689
+				$post_args['meta_query'] = Sensei_WC::get_free_courses_meta_query_args();
690 690
 
691
-                break;
691
+				break;
692 692
 
693 693
 			case 'paidcourses':
694 694
 
695
-                $post_args = array(
696
-                    'post_type' 		=> 'course',
697
-                    'orderby'         	=> $orderby,
698
-                    'order'           	=> $order,
699
-                    'post_status'      	=> 'publish',
700
-                    'exclude'			=> $excludes,
701
-                    'suppress_filters' 	=> 0
702
-                );
695
+				$post_args = array(
696
+					'post_type' 		=> 'course',
697
+					'orderby'         	=> $orderby,
698
+					'order'           	=> $order,
699
+					'post_status'      	=> 'publish',
700
+					'exclude'			=> $excludes,
701
+					'suppress_filters' 	=> 0
702
+				);
703 703
 
704
-                // Sub Query to get all WooCommerce Products that have price greater than zero
705
-                $post_args['meta_query'] = Sensei_WC::get_paid_courses_meta_query_args();
704
+				// Sub Query to get all WooCommerce Products that have price greater than zero
705
+				$post_args['meta_query'] = Sensei_WC::get_paid_courses_meta_query_args();
706 706
 
707 707
 				break;
708 708
 
709 709
 			case 'featuredcourses':
710
-                $post_args = array(	'post_type' 		=> 'course',
711
-                                    'orderby'         	=> $orderby,
712
-                                    'order'           	=> $order,
713
-    								'post_status'      	=> 'publish',
714
-    								'meta_value' 		=> 'featured',
715
-    								'meta_key' 			=> '_course_featured',
716
-    								'meta_compare' 		=> '=',
717
-    								'exclude'			=> $excludes,
718
-    								'suppress_filters' 	=> 0
710
+				$post_args = array(	'post_type' 		=> 'course',
711
+									'orderby'         	=> $orderby,
712
+									'order'           	=> $order,
713
+									'post_status'      	=> 'publish',
714
+									'meta_value' 		=> 'featured',
715
+									'meta_key' 			=> '_course_featured',
716
+									'meta_compare' 		=> '=',
717
+									'exclude'			=> $excludes,
718
+									'suppress_filters' 	=> 0
719 719
 									);
720 720
 				break;
721 721
 			default:
722 722
 				$post_args = array(	'post_type' 		=> 'course',
723
-                                    'orderby'         	=> $orderby,
724
-                                    'order'           	=> $order,
725
-    								'post_status'      	=> 'publish',
726
-    								'exclude'			=> $excludes,
727
-    								'suppress_filters' 	=> 0
723
+									'orderby'         	=> $orderby,
724
+									'order'           	=> $order,
725
+									'post_status'      	=> 'publish',
726
+									'exclude'			=> $excludes,
727
+									'suppress_filters' 	=> 0
728 728
 									);
729 729
 				break;
730 730
 
731 731
 		}
732 732
 
733
-        $post_args['posts_per_page'] = $amount;
734
-        $paged = $wp_query->get( 'paged' );
735
-        $post_args['paged'] = empty( $paged) ? 1 : $paged;
733
+		$post_args['posts_per_page'] = $amount;
734
+		$paged = $wp_query->get( 'paged' );
735
+		$post_args['paged'] = empty( $paged) ? 1 : $paged;
736 736
 
737
-        if( 'newcourses' == $type ){
737
+		if( 'newcourses' == $type ){
738 738
 
739
-            $post_args[ 'orderby' ] = 'date';
740
-            $post_args[ 'order' ] = 'DESC';
741
-        }
739
+			$post_args[ 'orderby' ] = 'date';
740
+			$post_args[ 'order' ] = 'DESC';
741
+		}
742 742
 
743 743
 		return $post_args;
744 744
 	}
@@ -748,22 +748,22 @@  discard block
 block discarded – undo
748 748
 	 * course_image function.
749 749
 	 *
750 750
 	 * Outputs the courses image, or first image from a lesson within a course
751
-     *
752
-     * Will echo the image unless return true is specified.
751
+	 *
752
+	 * Will echo the image unless return true is specified.
753 753
 	 *
754 754
 	 * @access public
755 755
 	 * @param int | WP_Post $course_id (default: 0)
756 756
 	 * @param string $width (default: '100')
757 757
 	 * @param string $height (default: '100')
758
-     * @param bool $return default false
759
-     *
758
+	 * @param bool $return default false
759
+	 *
760 760
 	 * @return string | void
761 761
 	 */
762 762
 	public function course_image( $course_id = 0, $width = '100', $height = '100', $return = false ) {
763 763
 
764
-        if( is_a( $course_id, 'WP_Post' ) ){
765
-            $course_id = $course_id->ID;
766
-        }
764
+		if( is_a( $course_id, 'WP_Post' ) ){
765
+			$course_id = $course_id->ID;
766
+		}
767 767
 
768 768
 		$html = '';
769 769
 
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
  				// Display Image Placeholder if none
821 821
 				if ( Sensei()->settings->get( 'placeholder_images_enable' ) ) {
822 822
 
823
-                    $img_url = apply_filters( 'sensei_course_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
823
+					$img_url = apply_filters( 'sensei_course_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
824 824
 
825 825
 				} // End If Statement
826 826
 
@@ -834,15 +834,15 @@  discard block
 block discarded – undo
834 834
 
835 835
 		} // End If Statement
836 836
 
837
-        if( $return ){
837
+		if( $return ){
838 838
 
839
-            return $html;
839
+			return $html;
840 840
 
841
-        }else{
841
+		}else{
842 842
 
843
-            echo $html;
843
+			echo $html;
844 844
 
845
-        }
845
+		}
846 846
 
847 847
 	} // End course_image()
848 848
 
@@ -886,9 +886,9 @@  discard block
 block discarded – undo
886 886
 	 */
887 887
 	public function course_lessons( $course_id = 0, $post_status = 'publish', $fields = 'all' ) {
888 888
 
889
-        if( is_a( $course_id, 'WP_Post' ) ){
890
-            $course_id = $course_id->ID;
891
-        }
889
+		if( is_a( $course_id, 'WP_Post' ) ){
890
+			$course_id = $course_id->ID;
891
+		}
892 892
 
893 893
 		$post_args = array(	'post_type'         => 'lesson',
894 894
 							'posts_per_page'       => -1,
@@ -904,67 +904,67 @@  discard block
 block discarded – undo
904 904
 							'suppress_filters'  => 0,
905 905
 							);
906 906
 		$query_results = new WP_Query( $post_args );
907
-        $lessons = $query_results->posts;
908
-
909
-        // re order the lessons. This could not be done via the OR meta query as there may be lessons
910
-        // with the course order for a different course and this should not be included. It could also not
911
-        // be done via the AND meta query as it excludes lesson that does not have the _order_$course_id but
912
-        // that have been added to the course.
913
-        if( count( $lessons) > 1  ){
914
-
915
-            foreach( $lessons as $lesson ){
916
-
917
-                $order = intval( get_post_meta( $lesson->ID, '_order_'. $course_id, true ) );
918
-                // for lessons with no order set it to be 10000 so that it show up at the end
919
-                $lesson->course_order = $order ? $order : 100000;
920
-            }
921
-
922
-            uasort( $lessons, array( $this, '_short_course_lessons_callback' )   );
923
-        }
924
-
925
-        /**
926
-         * Filter runs inside Sensei_Course::course_lessons function
927
-         *
928
-         * Returns all lessons for a given course
929
-         *
930
-         * @param array $lessons
931
-         * @param int $course_id
932
-         */
933
-        $lessons = apply_filters( 'sensei_course_get_lessons', $lessons, $course_id  );
934
-
935
-        //return the requested fields
936
-        // runs after the sensei_course_get_lessons filter so the filter always give an array of lesson
937
-        // objects
938
-        if( 'ids' == $fields ) {
939
-            $lesson_objects = $lessons;
940
-            $lessons = array();
941
-
942
-            foreach ($lesson_objects as $lesson) {
943
-                $lessons[] = $lesson->ID;
944
-            }
945
-        }
946
-
947
-        return $lessons;
907
+		$lessons = $query_results->posts;
908
+
909
+		// re order the lessons. This could not be done via the OR meta query as there may be lessons
910
+		// with the course order for a different course and this should not be included. It could also not
911
+		// be done via the AND meta query as it excludes lesson that does not have the _order_$course_id but
912
+		// that have been added to the course.
913
+		if( count( $lessons) > 1  ){
914
+
915
+			foreach( $lessons as $lesson ){
916
+
917
+				$order = intval( get_post_meta( $lesson->ID, '_order_'. $course_id, true ) );
918
+				// for lessons with no order set it to be 10000 so that it show up at the end
919
+				$lesson->course_order = $order ? $order : 100000;
920
+			}
921
+
922
+			uasort( $lessons, array( $this, '_short_course_lessons_callback' )   );
923
+		}
924
+
925
+		/**
926
+		 * Filter runs inside Sensei_Course::course_lessons function
927
+		 *
928
+		 * Returns all lessons for a given course
929
+		 *
930
+		 * @param array $lessons
931
+		 * @param int $course_id
932
+		 */
933
+		$lessons = apply_filters( 'sensei_course_get_lessons', $lessons, $course_id  );
934
+
935
+		//return the requested fields
936
+		// runs after the sensei_course_get_lessons filter so the filter always give an array of lesson
937
+		// objects
938
+		if( 'ids' == $fields ) {
939
+			$lesson_objects = $lessons;
940
+			$lessons = array();
941
+
942
+			foreach ($lesson_objects as $lesson) {
943
+				$lessons[] = $lesson->ID;
944
+			}
945
+		}
946
+
947
+		return $lessons;
948 948
 
949 949
 	} // End course_lessons()
950 950
 
951
-    /**
952
-     * Used for the uasort in $this->course_lessons()
953
-     * @since 1.8.0
954
-     * @access protected
955
-     *
956
-     * @param array $lesson_1
957
-     * @param array $lesson_2
958
-     * @return int
959
-     */
960
-    protected function _short_course_lessons_callback( $lesson_1, $lesson_2 ){
951
+	/**
952
+	 * Used for the uasort in $this->course_lessons()
953
+	 * @since 1.8.0
954
+	 * @access protected
955
+	 *
956
+	 * @param array $lesson_1
957
+	 * @param array $lesson_2
958
+	 * @return int
959
+	 */
960
+	protected function _short_course_lessons_callback( $lesson_1, $lesson_2 ){
961 961
 
962
-        if ( $lesson_1->course_order == $lesson_2->course_order ) {
963
-            return 0;
964
-        }
962
+		if ( $lesson_1->course_order == $lesson_2->course_order ) {
963
+			return 0;
964
+		}
965 965
 
966
-        return ($lesson_1->course_order < $lesson_2->course_order) ? -1 : 1;
967
-    }
966
+		return ($lesson_1->course_order < $lesson_2->course_order) ? -1 : 1;
967
+	}
968 968
 
969 969
 	/**
970 970
 	 * Fetch all quiz ids in a course
@@ -1027,15 +1027,15 @@  discard block
 block discarded – undo
1027 1027
 	 */
1028 1028
 	public function course_author_lesson_count( $author_id = 0, $course_id = 0 ) {
1029 1029
 
1030
-        $lesson_args = array(	'post_type' 		=> 'lesson',
1030
+		$lesson_args = array(	'post_type' 		=> 'lesson',
1031 1031
 								'posts_per_page' 		=> -1,
1032
-		    					'author'         	=> $author_id,
1033
-		    					'meta_key'        	=> '_lesson_course',
1034
-    							'meta_value'      	=> $course_id,
1035
-    	    					'post_status'      	=> 'publish',
1036
-    	    					'suppress_filters' 	=> 0,
1032
+								'author'         	=> $author_id,
1033
+								'meta_key'        	=> '_lesson_course',
1034
+								'meta_value'      	=> $course_id,
1035
+								'post_status'      	=> 'publish',
1036
+								'suppress_filters' 	=> 0,
1037 1037
 								'fields'            => 'ids', // less data to retrieve
1038
-		    				);
1038
+							);
1039 1039
 		$lessons_array = get_posts( $lesson_args );
1040 1040
 		$count = count( $lessons_array );
1041 1041
 		return $count;
@@ -1053,17 +1053,17 @@  discard block
 block discarded – undo
1053 1053
 
1054 1054
 		$lesson_args = array(	'post_type' 		=> 'lesson',
1055 1055
 								'posts_per_page' 		=> -1,
1056
-		    					'meta_key'        	=> '_lesson_course',
1057
-    							'meta_value'      	=> $course_id,
1058
-    	    					'post_status'      	=> 'publish',
1059
-    	    					'suppress_filters' 	=> 0,
1056
+								'meta_key'        	=> '_lesson_course',
1057
+								'meta_value'      	=> $course_id,
1058
+								'post_status'      	=> 'publish',
1059
+								'suppress_filters' 	=> 0,
1060 1060
 								'fields'            => 'ids', // less data to retrieve
1061
-		    				);
1061
+							);
1062 1062
 		$lessons_array = get_posts( $lesson_args );
1063 1063
 
1064
-        $count = count( $lessons_array );
1064
+		$count = count( $lessons_array );
1065 1065
 
1066
-        return $count;
1066
+		return $count;
1067 1067
 
1068 1068
 	} // End course_lesson_count()
1069 1069
 
@@ -1078,9 +1078,9 @@  discard block
 block discarded – undo
1078 1078
 
1079 1079
 		$lesson_args = array(	'post_type' 		=> 'lesson',
1080 1080
 								'posts_per_page' 		=> -1,
1081
-    	    					'post_status'      	=> 'publish',
1082
-    	    					'suppress_filters' 	=> 0,
1083
-    	    					'meta_query' => array(
1081
+								'post_status'      	=> 'publish',
1082
+								'suppress_filters' 	=> 0,
1083
+								'meta_query' => array(
1084 1084
 									array(
1085 1085
 										'key' => '_lesson_course',
1086 1086
 										'value' => $course_id
@@ -1091,12 +1091,12 @@  discard block
 block discarded – undo
1091 1091
 									)
1092 1092
 								),
1093 1093
 								'fields'            => 'ids', // less data to retrieve
1094
-		    				);
1094
+							);
1095 1095
 		$lessons_array = get_posts( $lesson_args );
1096 1096
 
1097 1097
 		$count = count( $lessons_array );
1098 1098
 
1099
-        return $count;
1099
+		return $count;
1100 1100
 
1101 1101
 	} // End course_lesson_count()
1102 1102
 
@@ -1115,8 +1115,8 @@  discard block
 block discarded – undo
1115 1115
 			$post_args = array(	'post_type' 		=> 'course',
1116 1116
 								'posts_per_page' 		=> -1,
1117 1117
 								'meta_key'        	=> '_course_woocommerce_product',
1118
-	    						'meta_value'      	=> $product_id,
1119
-	    						'post_status'       => 'publish',
1118
+								'meta_value'      	=> $product_id,
1119
+								'post_status'       => 'publish',
1120 1120
 								'suppress_filters' 	=> 0,
1121 1121
 								'orderby' 			=> 'menu_order date',
1122 1122
 								'order' 			=> 'ASC',
@@ -1157,9 +1157,9 @@  discard block
 block discarded – undo
1157 1157
 
1158 1158
 	/**
1159 1159
 	 * load_user_courses_content generates HTML for user's active & completed courses
1160
-     *
1161
-     * This function also ouputs the html so no need to echo the content.
1162
-     *
1160
+	 *
1161
+	 * This function also ouputs the html so no need to echo the content.
1162
+	 *
1163 1163
 	 * @since  1.4.0
1164 1164
 	 * @param  object  $user   Queried user object
1165 1165
 	 * @param  boolean $manage Whether the user has permission to manage the courses
@@ -1168,17 +1168,17 @@  discard block
 block discarded – undo
1168 1168
 	public function load_user_courses_content( $user = false ) {
1169 1169
 		global $course, $my_courses_page, $my_courses_section;
1170 1170
 
1171
-        if( ! isset( Sensei()->settings->settings[ 'learner_profile_show_courses' ] )
1172
-            || ! Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) {
1171
+		if( ! isset( Sensei()->settings->settings[ 'learner_profile_show_courses' ] )
1172
+			|| ! Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) {
1173 1173
 
1174
-            // do not show the content if the settings doesn't allow for it
1175
-            return;
1174
+			// do not show the content if the settings doesn't allow for it
1175
+			return;
1176 1176
 
1177
-        }
1177
+		}
1178 1178
 
1179
-        $manage = ( $user->ID == get_current_user_id() ) ? true : false;
1179
+		$manage = ( $user->ID == get_current_user_id() ) ? true : false;
1180 1180
 
1181
-        do_action( 'sensei_before_learner_course_content', $user );
1181
+		do_action( 'sensei_before_learner_course_content', $user );
1182 1182
 
1183 1183
 		// Build Output HTML
1184 1184
 		$complete_html = $active_html = '';
@@ -1193,7 +1193,7 @@  discard block
 block discarded – undo
1193 1193
 			// Logic for Active and Completed Courses
1194 1194
 			$per_page = 20;
1195 1195
 			if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] )
1196
-                && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) {
1196
+				&& ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) {
1197 1197
 
1198 1198
 				$per_page = absint( Sensei()->settings->settings[ 'my_course_amount' ] );
1199 1199
 
@@ -1239,111 +1239,111 @@  discard block
 block discarded – undo
1239 1239
 					}
1240 1240
 				}
1241 1241
 
1242
-			    // Get Course Categories
1243
-			    $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );
1242
+				// Get Course Categories
1243
+				$category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );
1244 1244
 
1245
-                $active_html .= '<article class="' . esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) ) . '">';
1245
+				$active_html .= '<article class="' . esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) ) . '">';
1246 1246
 
1247
-                // Image
1248
-                $active_html .= Sensei()->course->course_image( absint( $course_item->ID ), '100','100', true );
1247
+				// Image
1248
+				$active_html .= Sensei()->course->course_image( absint( $course_item->ID ), '100','100', true );
1249 1249
 
1250
-                // Title
1251
-                $active_html .= '<header>';
1250
+				// Title
1251
+				$active_html .= '<header>';
1252 1252
 
1253
-                $active_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>';
1253
+				$active_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>';
1254 1254
 
1255
-                $active_html .= '</header>';
1255
+				$active_html .= '</header>';
1256 1256
 
1257
-                $active_html .= '<section class="entry">';
1257
+				$active_html .= '<section class="entry">';
1258 1258
 
1259
-                $active_html .= '<p class="sensei-course-meta">';
1259
+				$active_html .= '<p class="sensei-course-meta">';
1260 1260
 
1261
-                // Author
1262
-                $user_info = get_userdata( absint( $course_item->post_author ) );
1263
-                if ( isset( Sensei()->settings->settings[ 'course_author' ] )
1264
-                    && ( Sensei()->settings->settings[ 'course_author' ] ) ) {
1261
+				// Author
1262
+				$user_info = get_userdata( absint( $course_item->post_author ) );
1263
+				if ( isset( Sensei()->settings->settings[ 'course_author' ] )
1264
+					&& ( Sensei()->settings->settings[ 'course_author' ] ) ) {
1265 1265
 
1266
-                    $active_html .= '<span class="course-author">'
1267
-                        . __( 'by ', 'woothemes-sensei' )
1268
-                        . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) )
1269
-                        . '" title="' . esc_attr( $user_info->display_name ) . '">'
1270
-                        . esc_html( $user_info->display_name )
1271
-                        . '</a></span>';
1266
+					$active_html .= '<span class="course-author">'
1267
+						. __( 'by ', 'woothemes-sensei' )
1268
+						. '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) )
1269
+						. '" title="' . esc_attr( $user_info->display_name ) . '">'
1270
+						. esc_html( $user_info->display_name )
1271
+						. '</a></span>';
1272 1272
 
1273
-                } // End If Statement
1273
+				} // End If Statement
1274 1274
 
1275
-                // Lesson count for this author
1276
-                $lesson_count = Sensei()->course->course_lesson_count( absint( $course_item->ID ) );
1277
-                // Handle Division by Zero
1278
-                if ( 0 == $lesson_count ) {
1275
+				// Lesson count for this author
1276
+				$lesson_count = Sensei()->course->course_lesson_count( absint( $course_item->ID ) );
1277
+				// Handle Division by Zero
1278
+				if ( 0 == $lesson_count ) {
1279 1279
 
1280
-                    $lesson_count = 1;
1280
+					$lesson_count = 1;
1281 1281
 
1282
-                } // End If Statement
1283
-                $active_html .= '<span class="course-lesson-count">' . $lesson_count . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ) . '</span>';
1284
-                // Course Categories
1285
-                if ( '' != $category_output ) {
1282
+				} // End If Statement
1283
+				$active_html .= '<span class="course-lesson-count">' . $lesson_count . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ) . '</span>';
1284
+				// Course Categories
1285
+				if ( '' != $category_output ) {
1286 1286
 
1287
-                    $active_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>';
1287
+					$active_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>';
1288 1288
 
1289
-                } // End If Statement
1290
-                $active_html .= '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $lessons_completed, $lesson_count  ) . '</span>';
1289
+				} // End If Statement
1290
+				$active_html .= '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $lessons_completed, $lesson_count  ) . '</span>';
1291 1291
 
1292
-                $active_html .= '</p>';
1292
+				$active_html .= '</p>';
1293 1293
 
1294
-                $active_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>';
1294
+				$active_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>';
1295 1295
 
1296 1296
 
1297 1297
 
1298
-                $progress_percentage = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $lesson_count ), 0 ) );
1298
+				$progress_percentage = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $lesson_count ), 0 ) );
1299 1299
 
1300
-                $active_html .= $this->get_progress_meter( $progress_percentage );
1300
+				$active_html .= $this->get_progress_meter( $progress_percentage );
1301 1301
 
1302
-                $active_html .= '</section>';
1302
+				$active_html .= '</section>';
1303 1303
 
1304
-                if( is_user_logged_in() ) {
1304
+				if( is_user_logged_in() ) {
1305 1305
 
1306
-                    $active_html .= '<section class="entry-actions">';
1306
+					$active_html .= '<section class="entry-actions">';
1307 1307
 
1308
-                    $active_html .= '<form method="POST" action="' . esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ) . '">';
1308
+					$active_html .= '<form method="POST" action="' . esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ) . '">';
1309 1309
 
1310
-                    $active_html .= '<input type="hidden" name="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" id="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" value="' . esc_attr( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ) . '" />';
1310
+					$active_html .= '<input type="hidden" name="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" id="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" value="' . esc_attr( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ) . '" />';
1311 1311
 
1312
-                    $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="' . esc_attr( absint( $course_item->ID ) ) . '" />';
1312
+					$active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="' . esc_attr( absint( $course_item->ID ) ) . '" />';
1313 1313
 
1314
-                    if ( 0 < absint( count( $course_lessons ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) {
1314
+					if ( 0 < absint( count( $course_lessons ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) {
1315 1315
 
1316
-                        $active_html .= '<span><input name="course_complete" type="submit" class="course-complete" value="'
1317
-                            .  __( 'Mark as Complete', 'woothemes-sensei' ) . '"/> </span>';
1316
+						$active_html .= '<span><input name="course_complete" type="submit" class="course-complete" value="'
1317
+							.  __( 'Mark as Complete', 'woothemes-sensei' ) . '"/> </span>';
1318 1318
 
1319
-                    } // End If Statement
1319
+					} // End If Statement
1320 1320
 
1321
-                    $course_purchased = false;
1322
-                    if ( Sensei_WC::is_woocommerce_active() ) {
1321
+					$course_purchased = false;
1322
+					if ( Sensei_WC::is_woocommerce_active() ) {
1323 1323
 
1324
-                        // Get the product ID
1325
-                        $wc_post_id = get_post_meta( absint( $course_item->ID ), '_course_woocommerce_product', true );
1326
-                        if ( 0 < $wc_post_id ) {
1324
+						// Get the product ID
1325
+						$wc_post_id = get_post_meta( absint( $course_item->ID ), '_course_woocommerce_product', true );
1326
+						if ( 0 < $wc_post_id ) {
1327 1327
 
1328
-                            $course_purchased = Sensei_WC::has_customer_bought_product(  $user->ID, $wc_post_id );
1328
+							$course_purchased = Sensei_WC::has_customer_bought_product(  $user->ID, $wc_post_id );
1329 1329
 
1330
-                        } // End If Statement
1330
+						} // End If Statement
1331 1331
 
1332
-                    } // End If Statement
1332
+					} // End If Statement
1333 1333
 
1334
-                    if ( false == $course_purchased ) {
1334
+					if ( false == $course_purchased ) {
1335 1335
 
1336
-                        $active_html .= '<span><input name="course_complete" type="submit" class="course-delete" value="'
1337
-                            .  __( 'Delete Course', 'woothemes-sensei' ) . '"/></span>';
1336
+						$active_html .= '<span><input name="course_complete" type="submit" class="course-delete" value="'
1337
+							.  __( 'Delete Course', 'woothemes-sensei' ) . '"/></span>';
1338 1338
 
1339
-                    } // End If Statement
1339
+					} // End If Statement
1340 1340
 
1341
-                    $active_html .= '</form>';
1341
+					$active_html .= '</form>';
1342 1342
 
1343
-                    $active_html .= '</section>';
1344
-                }
1343
+					$active_html .= '</section>';
1344
+				}
1345 1345
 
1346
-                $active_html .= '</article>';
1346
+				$active_html .= '</article>';
1347 1347
 			}
1348 1348
 
1349 1349
 			// Active pagination
@@ -1383,49 +1383,49 @@  discard block
 block discarded – undo
1383 1383
 			foreach ( $completed_courses as $course_item ) {
1384 1384
 				$course = $course_item;
1385 1385
 
1386
-			    // Get Course Categories
1387
-			    $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );
1386
+				// Get Course Categories
1387
+				$category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );
1388 1388
 
1389
-		    	$complete_html .= '<article class="' . join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) . '">';
1389
+				$complete_html .= '<article class="' . join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) . '">';
1390 1390
 
1391
-		    	    // Image
1392
-		    		$complete_html .= Sensei()->course->course_image( absint( $course_item->ID ),100, 100, true );
1391
+					// Image
1392
+					$complete_html .= Sensei()->course->course_image( absint( $course_item->ID ),100, 100, true );
1393 1393
 
1394
-		    		// Title
1395
-		    		$complete_html .= '<header>';
1394
+					// Title
1395
+					$complete_html .= '<header>';
1396 1396
 
1397
-		    		    $complete_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>';
1397
+						$complete_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>';
1398 1398
 
1399
-		    		$complete_html .= '</header>';
1399
+					$complete_html .= '</header>';
1400 1400
 
1401
-		    		$complete_html .= '<section class="entry">';
1401
+					$complete_html .= '<section class="entry">';
1402 1402
 
1403
-		    			$complete_html .= '<p class="sensei-course-meta">';
1403
+						$complete_html .= '<p class="sensei-course-meta">';
1404 1404
 
1405
-		    		    	// Author
1406
-		    		    	$user_info = get_userdata( absint( $course_item->post_author ) );
1407
-		    		    	if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {
1408
-		    		    		$complete_html .= '<span class="course-author">' . __( 'by ', 'woothemes-sensei' ) . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
1409
-		    		    	} // End If Statement
1405
+							// Author
1406
+							$user_info = get_userdata( absint( $course_item->post_author ) );
1407
+							if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {
1408
+								$complete_html .= '<span class="course-author">' . __( 'by ', 'woothemes-sensei' ) . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
1409
+							} // End If Statement
1410 1410
 
1411
-		    		    	// Lesson count for this author
1412
-		    		    	$complete_html .= '<span class="course-lesson-count">'
1413
-                                . Sensei()->course->course_lesson_count( absint( $course_item->ID ) )
1414
-                                . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' )
1415
-                                . '</span>';
1411
+							// Lesson count for this author
1412
+							$complete_html .= '<span class="course-lesson-count">'
1413
+								. Sensei()->course->course_lesson_count( absint( $course_item->ID ) )
1414
+								. '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' )
1415
+								. '</span>';
1416 1416
 
1417
-		    		    	// Course Categories
1418
-		    		    	if ( '' != $category_output ) {
1417
+							// Course Categories
1418
+							if ( '' != $category_output ) {
1419 1419
 
1420
-		    		    		$complete_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>';
1420
+								$complete_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>';
1421 1421
 
1422
-		    		    	} // End If Statement
1422
+							} // End If Statement
1423 1423
 
1424 1424
 						$complete_html .= '</p>';
1425 1425
 
1426 1426
 						$complete_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>';
1427 1427
 
1428
-                        $complete_html .= $this->get_progress_meter( 100 );
1428
+						$complete_html .= $this->get_progress_meter( 100 );
1429 1429
 
1430 1430
 						if( $manage ) {
1431 1431
 							$has_quizzes = Sensei()->course->course_quizzes( $course_item->ID, true );
@@ -1438,9 +1438,9 @@  discard block
 block discarded – undo
1438 1438
 								if( $has_quizzes ) {
1439 1439
 
1440 1440
 									$results_link = '<a class="button view-results" href="'
1441
-                                        . Sensei()->course_results->get_permalink( $course_item->ID )
1442
-                                        . '">' . __( 'View results', 'woothemes-sensei' )
1443
-                                        . '</a>';
1441
+										. Sensei()->course_results->get_permalink( $course_item->ID )
1442
+										. '">' . __( 'View results', 'woothemes-sensei' )
1443
+										. '</a>';
1444 1444
 								}
1445 1445
 								$complete_html .= apply_filters( 'sensei_results_links', $results_link );
1446 1446
 								$complete_html .= '</p>';
@@ -1448,9 +1448,9 @@  discard block
 block discarded – undo
1448 1448
 							}
1449 1449
 						}
1450 1450
 
1451
-		    		$complete_html .= '</section>';
1451
+					$complete_html .= '</section>';
1452 1452
 
1453
-		    	$complete_html .= '</article>';
1453
+				$complete_html .= '</article>';
1454 1454
 			}
1455 1455
 
1456 1456
 			// Active pagination
@@ -1525,16 +1525,16 @@  discard block
 block discarded – undo
1525 1525
 		    <?php do_action( 'sensei_before_active_user_courses' ); ?>
1526 1526
 
1527 1527
 		    <?php
1528
-            $course_page_url = Sensei_Course::get_courses_page_url();
1529
-            ?>
1528
+			$course_page_url = Sensei_Course::get_courses_page_url();
1529
+			?>
1530 1530
 
1531 1531
 		    <div id="active-courses">
1532 1532
 
1533 1533
 		    	<?php if ( '' != $active_html ) {
1534 1534
 
1535
-		    		echo $active_html;
1535
+					echo $active_html;
1536 1536
 
1537
-		    	} else { ?>
1537
+				} else { ?>
1538 1538
 
1539 1539
 		    		<div class="sensei-message info">
1540 1540
 
@@ -1560,9 +1560,9 @@  discard block
 block discarded – undo
1560 1560
 
1561 1561
 		    	<?php if ( '' != $complete_html ) {
1562 1562
 
1563
-		    		echo $complete_html;
1563
+					echo $complete_html;
1564 1564
 
1565
-		    	} else { ?>
1565
+				} else { ?>
1566 1566
 
1567 1567
 		    		<div class="sensei-message info">
1568 1568
 
@@ -1581,356 +1581,356 @@  discard block
 block discarded – undo
1581 1581
 		<?php do_action( 'sensei_after_user_courses' ); ?>
1582 1582
 
1583 1583
 		<?php
1584
-        echo ob_get_clean();
1584
+		echo ob_get_clean();
1585 1585
 
1586
-        do_action( 'sensei_after_learner_course_content', $user );
1586
+		do_action( 'sensei_after_learner_course_content', $user );
1587 1587
 
1588 1588
 	} // end load_user_courses_content
1589 1589
 
1590
-    /**
1591
-     * Returns a list of all courses
1592
-     *
1593
-     * @since 1.8.0
1594
-     * @return array $courses{
1595
-     *  @type $course WP_Post
1596
-     * }
1597
-     */
1598
-    public static function get_all_courses(){
1599
-
1600
-        $args = array(
1601
-               'post_type' => 'course',
1602
-                'posts_per_page' 		=> -1,
1603
-                'orderby'         	=> 'title',
1604
-                'order'           	=> 'ASC',
1605
-                'post_status'      	=> 'any',
1606
-                'suppress_filters' 	=> 0,
1607
-        );
1608
-
1609
-        $wp_query_obj =  new WP_Query( $args );
1610
-
1611
-        /**
1612
-         * sensei_get_all_courses filter
1613
-         *
1614
-         * This filter runs inside Sensei_Course::get_all_courses.
1615
-         *
1616
-         * @param array $courses{
1617
-         *  @type WP_Post
1618
-         * }
1619
-         * @param array $attributes
1620
-         */
1621
-        return apply_filters( 'sensei_get_all_courses' , $wp_query_obj->posts );
1622
-
1623
-    }// end get_all_courses
1624
-
1625
-    /**
1626
-     * Generate the course meter component
1627
-     *
1628
-     * @since 1.8.0
1629
-     * @param int $progress_percentage 0 - 100
1630
-     * @return string $progress_bar_html
1631
-     */
1632
-    public function get_progress_meter( $progress_percentage ){
1633
-
1634
-        if ( 50 < $progress_percentage ) {
1635
-            $class = ' green';
1636
-        } elseif ( 25 <= $progress_percentage && 50 >= $progress_percentage ) {
1637
-            $class = ' orange';
1638
-        } else {
1639
-            $class = ' red';
1640
-        }
1641
-        $progress_bar_html = '<div class="meter' . esc_attr( $class ) . '"><span style="width: ' . $progress_percentage . '%">' . round( $progress_percentage ) . '%</span></div>';
1642
-
1643
-        return $progress_bar_html;
1644
-
1645
-    }// end get_progress_meter
1646
-
1647
-    /**
1648
-     * Generate a statement that tells users
1649
-     * how far they are in the course.
1650
-     *
1651
-     * @param int $course_id
1652
-     * @param int $user_id
1653
-     *
1654
-     * @return string $statement_html
1655
-     */
1656
-    public function get_progress_statement( $course_id, $user_id ){
1657
-
1658
-        if( empty( $course_id ) || empty( $user_id )
1659
-        || ! Sensei_Utils::user_started_course( $course_id, $user_id ) ){
1660
-            return '';
1661
-        }
1662
-
1663
-        $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) );
1664
-        $total_lessons = count( $this->course_lessons( $course_id ) );
1665
-
1666
-        $statement = sprintf( _n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons );
1667
-
1668
-        /**
1669
-         * Filter the course completion statement.
1670
-         * Default Currently completed $var lesson($plural) of $var in total
1671
-         *
1672
-         * @param string $statement
1673
-         */
1674
-        return apply_filters( 'sensei_course_completion_statement', $statement );
1675
-
1676
-    }// end generate_progress_statement
1677
-
1678
-    /**
1679
-     * Output the course progress statement
1680
-     *
1681
-     * @param $course_id
1682
-     * @return void
1683
-     */
1684
-    public function the_progress_statement( $course_id = 0, $user_id = 0 ){
1685
-        if( empty( $course_id ) ){
1686
-            global $post;
1687
-            $course_id = $post->ID;
1688
-        }
1689
-
1690
-        if( empty( $user_id ) ){
1691
-            $user_id = get_current_user_id();
1692
-        }
1693
-
1694
-        echo '<span class="progress statement  course-completion-rate">' . $this->get_progress_statement( $course_id, $user_id  ) . '</span>';
1695
-    }
1696
-
1697
-    /**
1698
-     * Output the course progress bar
1699
-     *
1700
-     * @param $course_id
1701
-     * @return void
1702
-     */
1703
-    public function the_progress_meter( $course_id = 0, $user_id = 0 ){
1704
-
1705
-        if( empty( $course_id ) ){
1706
-            global $post;
1707
-            $course_id = $post->ID;
1708
-        }
1709
-
1710
-        if( empty( $user_id ) ){
1711
-            $user_id = get_current_user_id();
1712
-        }
1713
-
1714
-        if( 'course' != get_post_type( $course_id ) || ! get_userdata( $user_id )
1715
-            || ! Sensei_Utils::user_started_course( $course_id ,$user_id ) ){
1716
-            return;
1717
-        }
1718
-        $percentage_completed = $this->get_completion_percentage( $course_id, $user_id );
1719
-
1720
-        echo $this->get_progress_meter( $percentage_completed );
1721
-
1722
-    }// end the_progress_meter
1723
-
1724
-    /**
1725
-     * Checks how many lessons are completed
1726
-     *
1727
-     * @since 1.8.0
1728
-     *
1729
-     * @param int $course_id
1730
-     * @param int $user_id
1731
-     * @return array $completed_lesson_ids
1732
-     */
1733
-    public function get_completed_lesson_ids( $course_id, $user_id = 0 ){
1734
-
1735
-        if( !( intval( $user_id ) ) > 0 ){
1736
-            $user_id = get_current_user_id();
1737
-        }
1590
+	/**
1591
+	 * Returns a list of all courses
1592
+	 *
1593
+	 * @since 1.8.0
1594
+	 * @return array $courses{
1595
+	 *  @type $course WP_Post
1596
+	 * }
1597
+	 */
1598
+	public static function get_all_courses(){
1599
+
1600
+		$args = array(
1601
+			   'post_type' => 'course',
1602
+				'posts_per_page' 		=> -1,
1603
+				'orderby'         	=> 'title',
1604
+				'order'           	=> 'ASC',
1605
+				'post_status'      	=> 'any',
1606
+				'suppress_filters' 	=> 0,
1607
+		);
1608
+
1609
+		$wp_query_obj =  new WP_Query( $args );
1610
+
1611
+		/**
1612
+		 * sensei_get_all_courses filter
1613
+		 *
1614
+		 * This filter runs inside Sensei_Course::get_all_courses.
1615
+		 *
1616
+		 * @param array $courses{
1617
+		 *  @type WP_Post
1618
+		 * }
1619
+		 * @param array $attributes
1620
+		 */
1621
+		return apply_filters( 'sensei_get_all_courses' , $wp_query_obj->posts );
1622
+
1623
+	}// end get_all_courses
1624
+
1625
+	/**
1626
+	 * Generate the course meter component
1627
+	 *
1628
+	 * @since 1.8.0
1629
+	 * @param int $progress_percentage 0 - 100
1630
+	 * @return string $progress_bar_html
1631
+	 */
1632
+	public function get_progress_meter( $progress_percentage ){
1633
+
1634
+		if ( 50 < $progress_percentage ) {
1635
+			$class = ' green';
1636
+		} elseif ( 25 <= $progress_percentage && 50 >= $progress_percentage ) {
1637
+			$class = ' orange';
1638
+		} else {
1639
+			$class = ' red';
1640
+		}
1641
+		$progress_bar_html = '<div class="meter' . esc_attr( $class ) . '"><span style="width: ' . $progress_percentage . '%">' . round( $progress_percentage ) . '%</span></div>';
1642
+
1643
+		return $progress_bar_html;
1644
+
1645
+	}// end get_progress_meter
1646
+
1647
+	/**
1648
+	 * Generate a statement that tells users
1649
+	 * how far they are in the course.
1650
+	 *
1651
+	 * @param int $course_id
1652
+	 * @param int $user_id
1653
+	 *
1654
+	 * @return string $statement_html
1655
+	 */
1656
+	public function get_progress_statement( $course_id, $user_id ){
1657
+
1658
+		if( empty( $course_id ) || empty( $user_id )
1659
+		|| ! Sensei_Utils::user_started_course( $course_id, $user_id ) ){
1660
+			return '';
1661
+		}
1662
+
1663
+		$completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) );
1664
+		$total_lessons = count( $this->course_lessons( $course_id ) );
1665
+
1666
+		$statement = sprintf( _n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons );
1667
+
1668
+		/**
1669
+		 * Filter the course completion statement.
1670
+		 * Default Currently completed $var lesson($plural) of $var in total
1671
+		 *
1672
+		 * @param string $statement
1673
+		 */
1674
+		return apply_filters( 'sensei_course_completion_statement', $statement );
1675
+
1676
+	}// end generate_progress_statement
1677
+
1678
+	/**
1679
+	 * Output the course progress statement
1680
+	 *
1681
+	 * @param $course_id
1682
+	 * @return void
1683
+	 */
1684
+	public function the_progress_statement( $course_id = 0, $user_id = 0 ){
1685
+		if( empty( $course_id ) ){
1686
+			global $post;
1687
+			$course_id = $post->ID;
1688
+		}
1689
+
1690
+		if( empty( $user_id ) ){
1691
+			$user_id = get_current_user_id();
1692
+		}
1693
+
1694
+		echo '<span class="progress statement  course-completion-rate">' . $this->get_progress_statement( $course_id, $user_id  ) . '</span>';
1695
+	}
1696
+
1697
+	/**
1698
+	 * Output the course progress bar
1699
+	 *
1700
+	 * @param $course_id
1701
+	 * @return void
1702
+	 */
1703
+	public function the_progress_meter( $course_id = 0, $user_id = 0 ){
1704
+
1705
+		if( empty( $course_id ) ){
1706
+			global $post;
1707
+			$course_id = $post->ID;
1708
+		}
1709
+
1710
+		if( empty( $user_id ) ){
1711
+			$user_id = get_current_user_id();
1712
+		}
1713
+
1714
+		if( 'course' != get_post_type( $course_id ) || ! get_userdata( $user_id )
1715
+			|| ! Sensei_Utils::user_started_course( $course_id ,$user_id ) ){
1716
+			return;
1717
+		}
1718
+		$percentage_completed = $this->get_completion_percentage( $course_id, $user_id );
1719
+
1720
+		echo $this->get_progress_meter( $percentage_completed );
1738 1721
 
1739
-        $completed_lesson_ids = array();
1722
+	}// end the_progress_meter
1740 1723
 
1741
-        $course_lessons = $this->course_lessons( $course_id );
1724
+	/**
1725
+	 * Checks how many lessons are completed
1726
+	 *
1727
+	 * @since 1.8.0
1728
+	 *
1729
+	 * @param int $course_id
1730
+	 * @param int $user_id
1731
+	 * @return array $completed_lesson_ids
1732
+	 */
1733
+	public function get_completed_lesson_ids( $course_id, $user_id = 0 ){
1734
+
1735
+		if( !( intval( $user_id ) ) > 0 ){
1736
+			$user_id = get_current_user_id();
1737
+		}
1738
+
1739
+		$completed_lesson_ids = array();
1740
+
1741
+		$course_lessons = $this->course_lessons( $course_id );
1742
+
1743
+		foreach( $course_lessons as $lesson ){
1744
+
1745
+			$is_lesson_completed = Sensei_Utils::user_completed_lesson( $lesson->ID, $user_id );
1746
+			if( $is_lesson_completed ){
1747
+				$completed_lesson_ids[] = $lesson->ID;
1748
+			}
1749
+
1750
+		}
1751
+
1752
+		return $completed_lesson_ids;
1753
+
1754
+	}// end get_completed_lesson_ids
1755
+
1756
+	/**
1757
+	 * Calculate the perceantage completed in the course
1758
+	 *
1759
+	 * @since 1.8.0
1760
+	 *
1761
+	 * @param int $course_id
1762
+	 * @param int $user_id
1763
+	 * @return int $percentage
1764
+	 */
1765
+	public function get_completion_percentage( $course_id, $user_id = 0 ){
1766
+
1767
+		if( !( intval( $user_id ) ) > 0 ){
1768
+			$user_id = get_current_user_id();
1769
+		}
1770
+
1771
+		$completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) );
1772
+
1773
+		if( ! (  $completed  > 0 ) ){
1774
+			return 0;
1775
+		}
1776
+
1777
+		$total_lessons = count( $this->course_lessons( $course_id ) );
1778
+		$percentage = $completed / $total_lessons * 100;
1779
+
1780
+		/**
1781
+		 *
1782
+		 * Filter the percentage returned for a users course.
1783
+		 *
1784
+		 * @param $percentage
1785
+		 * @param $course_id
1786
+		 * @param $user_id
1787
+		 * @since 1.8.0
1788
+		 */
1789
+		return apply_filters( 'sensei_course_completion_percentage', $percentage, $course_id, $user_id );
1790
+
1791
+	}// end get_completed_lesson_ids
1792
+
1793
+	/**
1794
+	 * Block email notifications for the specific courses
1795
+	 * that the user disabled the notifications.
1796
+	 *
1797
+	 * @since 1.8.0
1798
+	 * @param $should_send
1799
+	 * @return bool
1800
+	 */
1801
+	public function block_notification_emails( $should_send ){
1802
+		global $sensei_email_data;
1803
+		$email = $sensei_email_data;
1804
+
1805
+		$course_id = '';
1806
+
1807
+		if( isset( $email['course_id'] ) ){
1808
+
1809
+			$course_id = $email['course_id'];
1810
+
1811
+		}elseif( isset( $email['lesson_id'] ) ){
1812
+
1813
+			$course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] );
1814
+
1815
+		}elseif( isset( $email['quiz_id'] ) ){
1816
+
1817
+			$lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] );
1818
+			$course_id = Sensei()->lesson->get_course_id( $lesson_id );
1819
+
1820
+		}
1821
+
1822
+		if( !empty( $course_id ) && 'course'== get_post_type( $course_id ) ) {
1823
+
1824
+			$course_emails_disabled = get_post_meta($course_id, 'disable_notification', true);
1825
+
1826
+			if ($course_emails_disabled) {
1827
+
1828
+				return false;
1829
+
1830
+			}
1831
+
1832
+		}// end if
1833
+
1834
+		return $should_send;
1835
+	}// end block_notification_emails
1836
+
1837
+	/**
1838
+	 * Render the course notification setting meta box
1839
+	 *
1840
+	 * @since 1.8.0
1841
+	 * @param $course
1842
+	 */
1843
+	public function course_notification_meta_box_content( $course ){
1742 1844
 
1743
-        foreach( $course_lessons as $lesson ){
1845
+		$checked = get_post_meta( $course->ID , 'disable_notification', true );
1744 1846
 
1745
-            $is_lesson_completed = Sensei_Utils::user_completed_lesson( $lesson->ID, $user_id );
1746
-            if( $is_lesson_completed ){
1747
-                $completed_lesson_ids[] = $lesson->ID;
1748
-            }
1749
-
1750
-        }
1751
-
1752
-        return $completed_lesson_ids;
1847
+		// generate checked html
1848
+		$checked_html = '';
1849
+		if( $checked ){
1850
+			$checked_html = 'checked="checked"';
1851
+		}
1852
+		wp_nonce_field( 'update-course-notification-setting','_sensei_course_notification' );
1853
+
1854
+		echo '<input id="disable_sensei_course_notification" '.$checked_html .' type="checkbox" name="disable_sensei_course_notification" >';
1855
+		echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei'). '</label>';
1753 1856
 
1754
-    }// end get_completed_lesson_ids
1857
+	}// end course_notification_meta_box_content
1858
+
1859
+	/**
1860
+	 * Store the setting for the course notification setting.
1861
+	 *
1862
+	 * @hooked int save_post
1863
+	 * @since 1.8.0
1864
+	 *
1865
+	 * @param $course_id
1866
+	 */
1867
+	public function save_course_notification_meta_box( $course_id ){
1755 1868
 
1756
-    /**
1757
-     * Calculate the perceantage completed in the course
1758
-     *
1759
-     * @since 1.8.0
1760
-     *
1761
-     * @param int $course_id
1762
-     * @param int $user_id
1763
-     * @return int $percentage
1764
-     */
1765
-    public function get_completion_percentage( $course_id, $user_id = 0 ){
1766
-
1767
-        if( !( intval( $user_id ) ) > 0 ){
1768
-            $user_id = get_current_user_id();
1769
-        }
1770
-
1771
-        $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) );
1772
-
1773
-        if( ! (  $completed  > 0 ) ){
1774
-            return 0;
1775
-        }
1776
-
1777
-        $total_lessons = count( $this->course_lessons( $course_id ) );
1778
-        $percentage = $completed / $total_lessons * 100;
1779
-
1780
-        /**
1781
-         *
1782
-         * Filter the percentage returned for a users course.
1783
-         *
1784
-         * @param $percentage
1785
-         * @param $course_id
1786
-         * @param $user_id
1787
-         * @since 1.8.0
1788
-         */
1789
-        return apply_filters( 'sensei_course_completion_percentage', $percentage, $course_id, $user_id );
1869
+		if( !isset( $_POST['_sensei_course_notification']  )
1870
+			|| ! wp_verify_nonce( $_POST['_sensei_course_notification'], 'update-course-notification-setting' ) ){
1871
+			return;
1872
+		}
1790 1873
 
1791
-    }// end get_completed_lesson_ids
1874
+		if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification']  ) {
1875
+			$new_val = true;
1876
+		}else{
1877
+			$new_val = false;
1878
+		}
1792 1879
 
1793
-    /**
1794
-     * Block email notifications for the specific courses
1795
-     * that the user disabled the notifications.
1796
-     *
1797
-     * @since 1.8.0
1798
-     * @param $should_send
1799
-     * @return bool
1800
-     */
1801
-    public function block_notification_emails( $should_send ){
1802
-        global $sensei_email_data;
1803
-        $email = $sensei_email_data;
1880
+	   update_post_meta( $course_id , 'disable_notification', $new_val );
1804 1881
 
1805
-        $course_id = '';
1882
+	}// end save notification meta box
1806 1883
 
1807
-        if( isset( $email['course_id'] ) ){
1884
+	/**
1885
+	 * Backwards compatibility hooks added to ensure that
1886
+	 * plugins and other parts of sensei still works.
1887
+	 *
1888
+	 * This function hooks into `sensei_course_content_inside_before`
1889
+	 *
1890
+	 * @since 1.9
1891
+	 *
1892
+	 * @param WP_Post $post
1893
+	 */
1894
+	public function content_before_backwards_compatibility_hooks( $post ){
1808 1895
 
1809
-            $course_id = $email['course_id'];
1810
-
1811
-        }elseif( isset( $email['lesson_id'] ) ){
1896
+		sensei_do_deprecated_action( 'sensei_course_image','1.9.0','sensei_course_content_inside_before' );
1897
+		sensei_do_deprecated_action( 'sensei_course_archive_course_title','1.9.0','sensei_course_content_inside_before' );
1812 1898
 
1813
-            $course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] );
1899
+	}
1814 1900
 
1815
-        }elseif( isset( $email['quiz_id'] ) ){
1901
+	/**
1902
+	 * Backwards compatibility hooks that should be hooked into sensei_loop_course_before
1903
+	 *
1904
+	 * hooked into 'sensei_loop_course_before'
1905
+	 *
1906
+	 * @since 1.9
1907
+	 *
1908
+	 * @global WP_Post $post
1909
+	 */
1910
+	public  function loop_before_backwards_compatibility_hooks( ){
1816 1911
 
1817
-            $lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] );
1818
-            $course_id = Sensei()->lesson->get_course_id( $lesson_id );
1912
+		global $post;
1913
+		sensei_do_deprecated_action( 'sensei_course_archive_header','1.9.0','sensei_course_content_inside_before', $post->post_type  );
1819 1914
 
1820
-        }
1915
+	}
1821 1916
 
1822
-        if( !empty( $course_id ) && 'course'== get_post_type( $course_id ) ) {
1823
-
1824
-            $course_emails_disabled = get_post_meta($course_id, 'disable_notification', true);
1825
-
1826
-            if ($course_emails_disabled) {
1827
-
1828
-                return false;
1829
-
1830
-            }
1831
-
1832
-        }// end if
1833
-
1834
-        return $should_send;
1835
-    }// end block_notification_emails
1836
-
1837
-    /**
1838
-     * Render the course notification setting meta box
1839
-     *
1840
-     * @since 1.8.0
1841
-     * @param $course
1842
-     */
1843
-    public function course_notification_meta_box_content( $course ){
1844
-
1845
-        $checked = get_post_meta( $course->ID , 'disable_notification', true );
1846
-
1847
-        // generate checked html
1848
-        $checked_html = '';
1849
-        if( $checked ){
1850
-            $checked_html = 'checked="checked"';
1851
-        }
1852
-        wp_nonce_field( 'update-course-notification-setting','_sensei_course_notification' );
1853
-
1854
-        echo '<input id="disable_sensei_course_notification" '.$checked_html .' type="checkbox" name="disable_sensei_course_notification" >';
1855
-        echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei'). '</label>';
1856
-
1857
-    }// end course_notification_meta_box_content
1858
-
1859
-    /**
1860
-     * Store the setting for the course notification setting.
1861
-     *
1862
-     * @hooked int save_post
1863
-     * @since 1.8.0
1864
-     *
1865
-     * @param $course_id
1866
-     */
1867
-    public function save_course_notification_meta_box( $course_id ){
1868
-
1869
-        if( !isset( $_POST['_sensei_course_notification']  )
1870
-            || ! wp_verify_nonce( $_POST['_sensei_course_notification'], 'update-course-notification-setting' ) ){
1871
-            return;
1872
-        }
1873
-
1874
-        if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification']  ) {
1875
-            $new_val = true;
1876
-        }else{
1877
-            $new_val = false;
1878
-        }
1879
-
1880
-       update_post_meta( $course_id , 'disable_notification', $new_val );
1881
-
1882
-    }// end save notification meta box
1883
-
1884
-    /**
1885
-     * Backwards compatibility hooks added to ensure that
1886
-     * plugins and other parts of sensei still works.
1887
-     *
1888
-     * This function hooks into `sensei_course_content_inside_before`
1889
-     *
1890
-     * @since 1.9
1891
-     *
1892
-     * @param WP_Post $post
1893
-     */
1894
-    public function content_before_backwards_compatibility_hooks( $post ){
1895
-
1896
-        sensei_do_deprecated_action( 'sensei_course_image','1.9.0','sensei_course_content_inside_before' );
1897
-        sensei_do_deprecated_action( 'sensei_course_archive_course_title','1.9.0','sensei_course_content_inside_before' );
1898
-
1899
-    }
1917
+	/**
1918
+	 * Output a link to view course. The button text is different depending on the amount of preview lesson available.
1919
+	 *
1920
+	 * hooked into 'sensei_course_content_inside_after'
1921
+	 *
1922
+	 * @since 1.9.0
1923
+	 *
1924
+	 * @param integer $course_id
1925
+	 */
1926
+	public function the_course_free_lesson_preview( $course_id ){
1927
+		// Meta data
1928
+		$course = get_post( $course_id );
1929
+		$preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course->ID ) );
1930
+		$is_user_taking_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() );
1900 1931
 
1901
-    /**
1902
-     * Backwards compatibility hooks that should be hooked into sensei_loop_course_before
1903
-     *
1904
-     * hooked into 'sensei_loop_course_before'
1905
-     *
1906
-     * @since 1.9
1907
-     *
1908
-     * @global WP_Post $post
1909
-     */
1910
-    public  function loop_before_backwards_compatibility_hooks( ){
1911
-
1912
-        global $post;
1913
-        sensei_do_deprecated_action( 'sensei_course_archive_header','1.9.0','sensei_course_content_inside_before', $post->post_type  );
1914
-
1915
-    }
1916
-
1917
-    /**
1918
-     * Output a link to view course. The button text is different depending on the amount of preview lesson available.
1919
-     *
1920
-     * hooked into 'sensei_course_content_inside_after'
1921
-     *
1922
-     * @since 1.9.0
1923
-     *
1924
-     * @param integer $course_id
1925
-     */
1926
-    public function the_course_free_lesson_preview( $course_id ){
1927
-        // Meta data
1928
-        $course = get_post( $course_id );
1929
-        $preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course->ID ) );
1930
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() );
1931
-
1932
-        if ( 0 < $preview_lesson_count && !$is_user_taking_course ) {
1933
-            ?>
1932
+		if ( 0 < $preview_lesson_count && !$is_user_taking_course ) {
1933
+			?>
1934 1934
             <p class="sensei-free-lessons">
1935 1935
                 <a href="<?php echo get_permalink(); ?>">
1936 1936
                     <?php _e( 'Preview this course', 'woothemes-sensei' ) ?>
@@ -1939,23 +1939,23 @@  discard block
 block discarded – undo
1939 1939
             </p>
1940 1940
 
1941 1941
         <?php
1942
-        }
1943
-    }
1942
+		}
1943
+	}
1944 1944
 
1945
-    /**
1946
-     * Add course mata to the course meta hook
1947
-     *
1948
-     * @since 1.9.0
1949
-     * @param integer $course_id
1950
-     */
1951
-    public function the_course_meta( $course_id ){
1952
-        echo '<p class="sensei-course-meta">';
1945
+	/**
1946
+	 * Add course mata to the course meta hook
1947
+	 *
1948
+	 * @since 1.9.0
1949
+	 * @param integer $course_id
1950
+	 */
1951
+	public function the_course_meta( $course_id ){
1952
+		echo '<p class="sensei-course-meta">';
1953 1953
 
1954
-        $course = get_post( $course_id );
1955
-        $category_output = get_the_term_list( $course->ID, 'course-category', '', ', ', '' );
1956
-        $author_display_name = get_the_author_meta( 'display_name', $course->post_author  );
1954
+		$course = get_post( $course_id );
1955
+		$category_output = get_the_term_list( $course->ID, 'course-category', '', ', ', '' );
1956
+		$author_display_name = get_the_author_meta( 'display_name', $course->post_author  );
1957 1957
 
1958
-        if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {?>
1958
+		if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {?>
1959 1959
 
1960 1960
             <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?>
1961 1961
 
@@ -1973,62 +1973,62 @@  discard block
 block discarded – undo
1973 1973
 
1974 1974
         <?php } // End If Statement
1975 1975
 
1976
-        // number of completed lessons
1977
-        if( Sensei_Utils::user_started_course( $course->ID,  get_current_user_id() )
1978
-            || Sensei_Utils::user_completed_course( $course->ID,  get_current_user_id() )  ){
1976
+		// number of completed lessons
1977
+		if( Sensei_Utils::user_started_course( $course->ID,  get_current_user_id() )
1978
+			|| Sensei_Utils::user_completed_course( $course->ID,  get_current_user_id() )  ){
1979 1979
 
1980
-            $completed = count( $this->get_completed_lesson_ids( $course->ID, get_current_user_id() ) );
1981
-            $lesson_count = count( $this->course_lessons( $course->ID ) );
1982
-            echo '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $completed, $lesson_count  ) . '</span>';
1980
+			$completed = count( $this->get_completed_lesson_ids( $course->ID, get_current_user_id() ) );
1981
+			$lesson_count = count( $this->course_lessons( $course->ID ) );
1982
+			echo '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $completed, $lesson_count  ) . '</span>';
1983 1983
 
1984
-        }
1984
+		}
1985 1985
 
1986
-        sensei_simple_course_price( $course->ID );
1986
+		sensei_simple_course_price( $course->ID );
1987 1987
 
1988
-        echo '</p>';
1989
-    } // end the course meta
1988
+		echo '</p>';
1989
+	} // end the course meta
1990 1990
 
1991
-    /**
1992
-     * Filter the classes attached to a post types for courses
1993
-     * and add a status class for when the user is logged in.
1994
-     *
1995
-     * @param $classes
1996
-     * @param $class
1997
-     * @param $post_id
1998
-     *
1999
-     * @return array $classes
2000
-     */
2001
-    public static function add_course_user_status_class( $classes, $class, $course_id ){
1991
+	/**
1992
+	 * Filter the classes attached to a post types for courses
1993
+	 * and add a status class for when the user is logged in.
1994
+	 *
1995
+	 * @param $classes
1996
+	 * @param $class
1997
+	 * @param $post_id
1998
+	 *
1999
+	 * @return array $classes
2000
+	 */
2001
+	public static function add_course_user_status_class( $classes, $class, $course_id ){
2002 2002
 
2003
-        if( 'course' == get_post_type( $course_id )  &&  is_user_logged_in() ){
2003
+		if( 'course' == get_post_type( $course_id )  &&  is_user_logged_in() ){
2004 2004
 
2005
-            if( Sensei_Utils::user_completed_course( $course_id, get_current_user_id() ) ){
2005
+			if( Sensei_Utils::user_completed_course( $course_id, get_current_user_id() ) ){
2006 2006
 
2007
-                $classes[] = 'user-status-completed';
2007
+				$classes[] = 'user-status-completed';
2008 2008
 
2009
-            }else{
2009
+			}else{
2010 2010
 
2011
-                $classes[] = 'user-status-active';
2011
+				$classes[] = 'user-status-active';
2012 2012
 
2013
-            }
2013
+			}
2014 2014
 
2015
-        }
2015
+		}
2016 2016
 
2017
-        return $classes;
2017
+		return $classes;
2018 2018
 
2019
-    }// end add_course_user_status_class
2019
+	}// end add_course_user_status_class
2020 2020
 
2021
-    /**
2022
-     * Prints out the course action buttons links
2023
-     *
2024
-     * - complete course
2025
-     * - delete course
2026
-     *
2027
-     * @param WP_Post $course
2028
-     */
2029
-    public static function the_course_action_buttons( $course ){
2021
+	/**
2022
+	 * Prints out the course action buttons links
2023
+	 *
2024
+	 * - complete course
2025
+	 * - delete course
2026
+	 *
2027
+	 * @param WP_Post $course
2028
+	 */
2029
+	public static function the_course_action_buttons( $course ){
2030 2030
 
2031
-        if( is_user_logged_in() ) { ?>
2031
+		if( is_user_logged_in() ) { ?>
2032 2032
 
2033 2033
             <section class="entry-actions">
2034 2034
                 <form method="POST" action="<?php  echo esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ); ?>">
@@ -2047,32 +2047,32 @@  discard block
 block discarded – undo
2047 2047
 
2048 2048
                    <?php  } // End If Statement
2049 2049
 
2050
-                    $course_purchased = false;
2051
-                    if ( Sensei_WC::is_woocommerce_active() ) {
2052
-                        // Get the product ID
2053
-                        $wc_post_id = get_post_meta( intval( $course->ID ), '_course_woocommerce_product', true );
2054
-                        if ( 0 < $wc_post_id ) {
2050
+					$course_purchased = false;
2051
+					if ( Sensei_WC::is_woocommerce_active() ) {
2052
+						// Get the product ID
2053
+						$wc_post_id = get_post_meta( intval( $course->ID ), '_course_woocommerce_product', true );
2054
+						if ( 0 < $wc_post_id ) {
2055 2055
 
2056
-                            $user = wp_get_current_user();
2057
-                            $course_purchased = Sensei_Utils::sensei_customer_bought_product( $user->user_email, $user->ID, $wc_post_id );
2056
+							$user = wp_get_current_user();
2057
+							$course_purchased = Sensei_Utils::sensei_customer_bought_product( $user->user_email, $user->ID, $wc_post_id );
2058 2058
 
2059
-                        } // End If Statement
2060
-                    } // End If Statement
2059
+						} // End If Statement
2060
+					} // End If Statement
2061 2061
 
2062
-                    if ( ! $course_purchased && ! Sensei_Utils::user_completed_course( $course->ID, get_current_user_id() ) ) {?>
2062
+					if ( ! $course_purchased && ! Sensei_Utils::user_completed_course( $course->ID, get_current_user_id() ) ) {?>
2063 2063
 
2064 2064
                         <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __( 'Delete Course', 'woothemes-sensei' ); ?>"/></span>
2065 2065
 
2066 2066
                     <?php } // End If Statement
2067 2067
 
2068
-                    $has_quizzes = Sensei()->course->course_quizzes( $course->ID, true );
2069
-                    $results_link = '';
2070
-                    if( $has_quizzes ){
2071
-                        $results_link = '<a class="button view-results" href="' . Sensei()->course_results->get_permalink( $course->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>';
2072
-                    }
2068
+					$has_quizzes = Sensei()->course->course_quizzes( $course->ID, true );
2069
+					$results_link = '';
2070
+					if( $has_quizzes ){
2071
+						$results_link = '<a class="button view-results" href="' . Sensei()->course_results->get_permalink( $course->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>';
2072
+					}
2073 2073
 
2074
-                    // Output only if there is content to display
2075
-                    if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?>
2074
+					// Output only if there is content to display
2075
+					if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?>
2076 2076
 
2077 2077
                         <p class="sensei-results-links">
2078 2078
                             <?php echo apply_filters( 'sensei_results_links', $results_link ); ?>
@@ -2084,456 +2084,456 @@  discard block
 block discarded – undo
2084 2084
 
2085 2085
         <?php  }// end if is user logged in
2086 2086
 
2087
-    }// end the_course_action_buttons
2088
-
2089
-    /**
2090
-     * This function alter the main query on the course archive page.
2091
-     * This also gives Sensei specific filters that allows variables to be altered specifically on the course archive.
2092
-     *
2093
-     * This function targets only the course archives and the my courses page. Shortcodes can set their own
2094
-     * query parameters via the arguments.
2095
-     *
2096
-     * This function is hooked into pre_get_posts filter
2097
-     *
2098
-     * @since 1.9.0
2099
-     *
2100
-     * @param WP_Query $query
2101
-     * @return WP_Query $query
2102
-     */
2103
-    public static function course_query_filter( $query ){
2104
-
2105
-        // exit early for no course queries and admin queries
2106
-        if( is_admin( ) || 'course' != $query->get( 'post_type' ) ){
2107
-            return $query;
2108
-        }
2109
-
2110
-        global $post; // used to get the current page id for my courses
2111
-
2112
-        // for the course archive page
2113
-        if( $query->is_main_query() && is_post_type_archive('course') )
2114
-        {
2115
-            /**
2116
-             * sensei_archive_courses_per_page
2117
-             *
2118
-             * Sensei courses per page on the course
2119
-             * archive
2120
-             *
2121
-             * @since 1.9.0
2122
-             * @param integer $posts_per_page default 10
2123
-             */
2124
-            $query->set( 'posts_per_page', apply_filters( 'sensei_archive_courses_per_page', 10 ) );
2125
-
2126
-        }
2127
-        // for the my courses page
2128
-        elseif( is_page() && Sensei()->settings->get( 'my_course_page' ) == $post->ID  )
2129
-        {
2130
-            /**
2131
-             * sensei_my_courses_per_page
2132
-             *
2133
-             * Sensei courses per page on the my courses page
2134
-             * as set in the settings
2135
-             *
2136
-             * @since 1.9.0
2137
-             * @param integer $posts_per_page default 10
2138
-             */
2139
-            $query->set( 'posts_per_page', apply_filters( 'sensei_my_courses_per_page', 10 ) );
2140
-
2141
-        }
2142
-
2143
-        return $query;
2144
-
2145
-    }// end course_query_filter
2146
-
2147
-    /**
2148
-     * Determine the class of the course loop
2149
-     *
2150
-     * This will output .first or .last and .course-item-number-x
2151
-     *
2152
-     * @return array $extra_classes
2153
-     * @since 1.9.0
2154
-     */
2155
-    public static function get_course_loop_content_class ()
2156
-    {
2157
-
2158
-        global $sensei_course_loop;
2159
-
2160
-
2161
-        if( !isset( $sensei_course_loop ) ){
2162
-            $sensei_course_loop = array();
2163
-        }
2164
-
2165
-        if (!isset($sensei_course_loop['counter'])) {
2166
-            $sensei_course_loop['counter'] = 0;
2167
-        }
2168
-
2169
-        if (!isset($sensei_course_loop['columns'])) {
2170
-            $sensei_course_loop['columns'] = self::get_loop_number_of_columns();
2171
-        }
2172
-
2173
-        // increment the counter
2174
-        $sensei_course_loop['counter']++;
2175
-
2176
-        $extra_classes = array();
2177
-        if( 0 == ( $sensei_course_loop['counter'] - 1 ) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns']  ){
2178
-            $extra_classes[] = 'first';
2179
-        }
2180
-
2181
-        if( 0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns']  ){
2182
-            $extra_classes[] = 'last';
2183
-        }
2184
-
2185
-        // add the item number to the classes as well.
2186
-        $extra_classes[] = 'loop-item-number-'. $sensei_course_loop['counter'];
2187
-
2188
-        /**
2189
-         * Filter the course loop class the fires in the  in get_course_loop_content_class function
2190
-         * which is called from the course loop content-course.php
2191
-         *
2192
-         * @since 1.9.0
2193
-         *
2194
-         * @param array $extra_classes
2195
-         * @param WP_Post $loop_current_course
2196
-         */
2197
-        return apply_filters( 'sensei_course_loop_content_class', $extra_classes ,get_post() );
2198
-
2199
-    }// end get_course_loop_class
2200
-
2201
-    /**
2202
-     * Get the number of columns set for Sensei courses
2203
-     *
2204
-     * @since 1.9.0
2205
-     * @return mixed|void
2206
-     */
2207
-    public static function get_loop_number_of_columns(){
2208
-
2209
-        /**
2210
-         * Filter the number of columns on the course archive page.
2211
-         *
2212
-         * @since 1.9.0
2213
-         * @param int $number_of_columns default 1
2214
-         */
2215
-        return apply_filters('sensei_course_loop_number_of_columns', 1);
2216
-
2217
-    }
2218
-
2219
-    /**
2220
-     * Output the course archive filter markup
2221
-     *
2222
-     * hooked into sensei_loop_course_before
2223
-     *
2224
-     * @since 1.9.0
2225
-     * @param
2226
-     */
2227
-    public static function course_archive_sorting( $query ){
2228
-
2229
-        // don't show on category pages and other pages
2230
-        if( ! is_archive(  'course ') || is_tax('course-category') ){
2231
-            return;
2232
-        }
2233
-
2234
-        /**
2235
-         * Filter the sensei archive course order by values
2236
-         *
2237
-         * @since 1.9.0
2238
-         * @param array $options {
2239
-         *  @type string $option_value
2240
-         *  @type string $option_string
2241
-         * }
2242
-         */
2243
-        $course_order_by_options = apply_filters( 'sensei_archive_course_order_by_options', array(
2244
-            "newness"     => __( "Sort by newest first", "woothemes-sensei"),
2245
-            "title"       => __( "Sort by title A-Z", "woothemes-sensei" ),
2246
-        ));
2247
-
2248
-        // setup the currently selected item
2249
-        $selected = 'newness';
2250
-        if( isset( $_GET['orderby'] ) ){
2251
-
2252
-            $selected =  $_GET[ 'orderby' ];
2253
-
2254
-        }
2255
-
2256
-        ?>
2087
+	}// end the_course_action_buttons
2088
+
2089
+	/**
2090
+	 * This function alter the main query on the course archive page.
2091
+	 * This also gives Sensei specific filters that allows variables to be altered specifically on the course archive.
2092
+	 *
2093
+	 * This function targets only the course archives and the my courses page. Shortcodes can set their own
2094
+	 * query parameters via the arguments.
2095
+	 *
2096
+	 * This function is hooked into pre_get_posts filter
2097
+	 *
2098
+	 * @since 1.9.0
2099
+	 *
2100
+	 * @param WP_Query $query
2101
+	 * @return WP_Query $query
2102
+	 */
2103
+	public static function course_query_filter( $query ){
2104
+
2105
+		// exit early for no course queries and admin queries
2106
+		if( is_admin( ) || 'course' != $query->get( 'post_type' ) ){
2107
+			return $query;
2108
+		}
2109
+
2110
+		global $post; // used to get the current page id for my courses
2111
+
2112
+		// for the course archive page
2113
+		if( $query->is_main_query() && is_post_type_archive('course') )
2114
+		{
2115
+			/**
2116
+			 * sensei_archive_courses_per_page
2117
+			 *
2118
+			 * Sensei courses per page on the course
2119
+			 * archive
2120
+			 *
2121
+			 * @since 1.9.0
2122
+			 * @param integer $posts_per_page default 10
2123
+			 */
2124
+			$query->set( 'posts_per_page', apply_filters( 'sensei_archive_courses_per_page', 10 ) );
2125
+
2126
+		}
2127
+		// for the my courses page
2128
+		elseif( is_page() && Sensei()->settings->get( 'my_course_page' ) == $post->ID  )
2129
+		{
2130
+			/**
2131
+			 * sensei_my_courses_per_page
2132
+			 *
2133
+			 * Sensei courses per page on the my courses page
2134
+			 * as set in the settings
2135
+			 *
2136
+			 * @since 1.9.0
2137
+			 * @param integer $posts_per_page default 10
2138
+			 */
2139
+			$query->set( 'posts_per_page', apply_filters( 'sensei_my_courses_per_page', 10 ) );
2140
+
2141
+		}
2142
+
2143
+		return $query;
2144
+
2145
+	}// end course_query_filter
2146
+
2147
+	/**
2148
+	 * Determine the class of the course loop
2149
+	 *
2150
+	 * This will output .first or .last and .course-item-number-x
2151
+	 *
2152
+	 * @return array $extra_classes
2153
+	 * @since 1.9.0
2154
+	 */
2155
+	public static function get_course_loop_content_class ()
2156
+	{
2157
+
2158
+		global $sensei_course_loop;
2159
+
2160
+
2161
+		if( !isset( $sensei_course_loop ) ){
2162
+			$sensei_course_loop = array();
2163
+		}
2164
+
2165
+		if (!isset($sensei_course_loop['counter'])) {
2166
+			$sensei_course_loop['counter'] = 0;
2167
+		}
2168
+
2169
+		if (!isset($sensei_course_loop['columns'])) {
2170
+			$sensei_course_loop['columns'] = self::get_loop_number_of_columns();
2171
+		}
2172
+
2173
+		// increment the counter
2174
+		$sensei_course_loop['counter']++;
2175
+
2176
+		$extra_classes = array();
2177
+		if( 0 == ( $sensei_course_loop['counter'] - 1 ) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns']  ){
2178
+			$extra_classes[] = 'first';
2179
+		}
2180
+
2181
+		if( 0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns']  ){
2182
+			$extra_classes[] = 'last';
2183
+		}
2184
+
2185
+		// add the item number to the classes as well.
2186
+		$extra_classes[] = 'loop-item-number-'. $sensei_course_loop['counter'];
2187
+
2188
+		/**
2189
+		 * Filter the course loop class the fires in the  in get_course_loop_content_class function
2190
+		 * which is called from the course loop content-course.php
2191
+		 *
2192
+		 * @since 1.9.0
2193
+		 *
2194
+		 * @param array $extra_classes
2195
+		 * @param WP_Post $loop_current_course
2196
+		 */
2197
+		return apply_filters( 'sensei_course_loop_content_class', $extra_classes ,get_post() );
2198
+
2199
+	}// end get_course_loop_class
2200
+
2201
+	/**
2202
+	 * Get the number of columns set for Sensei courses
2203
+	 *
2204
+	 * @since 1.9.0
2205
+	 * @return mixed|void
2206
+	 */
2207
+	public static function get_loop_number_of_columns(){
2208
+
2209
+		/**
2210
+		 * Filter the number of columns on the course archive page.
2211
+		 *
2212
+		 * @since 1.9.0
2213
+		 * @param int $number_of_columns default 1
2214
+		 */
2215
+		return apply_filters('sensei_course_loop_number_of_columns', 1);
2216
+
2217
+	}
2218
+
2219
+	/**
2220
+	 * Output the course archive filter markup
2221
+	 *
2222
+	 * hooked into sensei_loop_course_before
2223
+	 *
2224
+	 * @since 1.9.0
2225
+	 * @param
2226
+	 */
2227
+	public static function course_archive_sorting( $query ){
2228
+
2229
+		// don't show on category pages and other pages
2230
+		if( ! is_archive(  'course ') || is_tax('course-category') ){
2231
+			return;
2232
+		}
2233
+
2234
+		/**
2235
+		 * Filter the sensei archive course order by values
2236
+		 *
2237
+		 * @since 1.9.0
2238
+		 * @param array $options {
2239
+		 *  @type string $option_value
2240
+		 *  @type string $option_string
2241
+		 * }
2242
+		 */
2243
+		$course_order_by_options = apply_filters( 'sensei_archive_course_order_by_options', array(
2244
+			"newness"     => __( "Sort by newest first", "woothemes-sensei"),
2245
+			"title"       => __( "Sort by title A-Z", "woothemes-sensei" ),
2246
+		));
2247
+
2248
+		// setup the currently selected item
2249
+		$selected = 'newness';
2250
+		if( isset( $_GET['orderby'] ) ){
2251
+
2252
+			$selected =  $_GET[ 'orderby' ];
2253
+
2254
+		}
2255
+
2256
+		?>
2257 2257
 
2258 2258
         <form class="sensei-ordering" name="sensei-course-order" action="<?php echo esc_attr( Sensei_Utils::get_current_url() ) ; ?>" method="POST">
2259 2259
             <select name="course-orderby" class="orderby">
2260 2260
                 <?php
2261
-                foreach( $course_order_by_options as $value => $text ){
2261
+				foreach( $course_order_by_options as $value => $text ){
2262 2262
 
2263
-                    echo '<option value="'. $value . ' "' . selected( $selected, $value, false ) . '>'. $text. '</option>';
2263
+					echo '<option value="'. $value . ' "' . selected( $selected, $value, false ) . '>'. $text. '</option>';
2264 2264
 
2265
-                }
2266
-                ?>
2265
+				}
2266
+				?>
2267 2267
             </select>
2268 2268
         </form>
2269 2269
 
2270 2270
     <?php
2271
-    }// end course archive filters
2272
-
2273
-    /**
2274
-     * Output the course archive filter markup
2275
-     *
2276
-     * hooked into sensei_loop_course_before
2277
-     *
2278
-     * @since 1.9.0
2279
-     * @param
2280
-     */
2281
-    public static function course_archive_filters( $query ){
2282
-
2283
-        // don't show on category pages
2284
-        if( is_tax('course-category') ){
2285
-            return;
2286
-        }
2287
-
2288
-        /**
2289
-         * filter the course archive filter buttons
2290
-         *
2291
-         * @since 1.9.0
2292
-         * @param array $filters{
2293
-         *   @type array ( $id, $url , $title )
2294
-         * }
2295
-         *
2296
-         */
2297
-        $filters = apply_filters( 'sensei_archive_course_filter_by_options', array(
2298
-            array( 'id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __( 'All', 'woothemes-sensei' ) ),
2299
-            array( 'id' => 'featured', 'url' => add_query_arg( array( 'course_filter'=>'featured'), self::get_courses_page_url()  ), 'title'=> __( 'Featured', 'woothemes-sensei' ) ),
2300
-        ));
2301
-
2302
-
2303
-        ?>
2271
+	}// end course archive filters
2272
+
2273
+	/**
2274
+	 * Output the course archive filter markup
2275
+	 *
2276
+	 * hooked into sensei_loop_course_before
2277
+	 *
2278
+	 * @since 1.9.0
2279
+	 * @param
2280
+	 */
2281
+	public static function course_archive_filters( $query ){
2282
+
2283
+		// don't show on category pages
2284
+		if( is_tax('course-category') ){
2285
+			return;
2286
+		}
2287
+
2288
+		/**
2289
+		 * filter the course archive filter buttons
2290
+		 *
2291
+		 * @since 1.9.0
2292
+		 * @param array $filters{
2293
+		 *   @type array ( $id, $url , $title )
2294
+		 * }
2295
+		 *
2296
+		 */
2297
+		$filters = apply_filters( 'sensei_archive_course_filter_by_options', array(
2298
+			array( 'id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __( 'All', 'woothemes-sensei' ) ),
2299
+			array( 'id' => 'featured', 'url' => add_query_arg( array( 'course_filter'=>'featured'), self::get_courses_page_url()  ), 'title'=> __( 'Featured', 'woothemes-sensei' ) ),
2300
+		));
2301
+
2302
+
2303
+		?>
2304 2304
         <ul class="sensei-course-filters clearfix" >
2305 2305
             <?php
2306 2306
 
2307
-            //determine the current active url
2308
-            $current_url = Sensei_Utils::get_current_url();
2307
+			//determine the current active url
2308
+			$current_url = Sensei_Utils::get_current_url();
2309 2309
 
2310
-            foreach( $filters as $filter ) {
2310
+			foreach( $filters as $filter ) {
2311 2311
 
2312
-                $active_class =  $current_url == $filter['url'] ? ' class="active" ' : '';
2312
+				$active_class =  $current_url == $filter['url'] ? ' class="active" ' : '';
2313 2313
 
2314
-                echo '<li><a '. $active_class .' id="'. $filter['id'] .'" href="'. esc_url( $filter['url'] ).'" >'. $filter['title']  .'</a></li>';
2314
+				echo '<li><a '. $active_class .' id="'. $filter['id'] .'" href="'. esc_url( $filter['url'] ).'" >'. $filter['title']  .'</a></li>';
2315 2315
 
2316
-            }
2317
-            ?>
2316
+			}
2317
+			?>
2318 2318
 
2319 2319
         </ul>
2320 2320
 
2321 2321
         <?php
2322 2322
 
2323
-    }
2323
+	}
2324 2324
 
2325
-    /**
2326
-     * if the featured link is clicked on the course archive page
2327
-     * filter the courses returned to only show those featured
2328
-     *
2329
-     * Hooked into pre_get_posts
2330
-     *
2331
-     * @since 1.9.0
2332
-     * @param WP_Query $query
2333
-     * @return WP_Query $query
2334
-     */
2335
-    public static function course_archive_featured_filter( $query ){
2336
-
2337
-        if( isset ( $_GET[ 'course_filter' ] ) && 'featured'== $_GET['course_filter'] && $query->is_main_query()  ){
2338
-            //setup meta query for featured courses
2339
-            $query->set( 'meta_value', 'featured'  );
2340
-            $query->set( 'meta_key', '_course_featured'  );
2341
-            $query->set( 'meta_compare', '='  );
2342
-        }
2343
-
2344
-        return $query;
2345
-    }
2346
-
2347
-    /**
2348
-     * if the course order drop down is changed
2349
-     *
2350
-     * Hooked into pre_get_posts
2351
-     *
2352
-     * @since 1.9.0
2353
-     * @param WP_Query $query
2354
-     * @return WP_Query $query
2355
-     */
2356
-    public static function course_archive_order_by_title( $query ){
2357
-
2358
-        if( isset ( $_POST[ 'course-orderby' ] ) && 'title '== $_POST['course-orderby']
2359
-            && 'course'== $query->get('post_type') && $query->is_main_query()  ){
2360
-            // setup the order by title for this query
2361
-            $query->set( 'orderby', 'title'  );
2362
-            $query->set( 'order', 'ASC'  );
2363
-        }
2364
-
2365
-        return $query;
2366
-    }
2367
-
2368
-
2369
-    /**
2370
-     * Get the link to the courses page. This will be the course post type archive
2371
-     * page link or the page the user set in their settings
2372
-     *
2373
-     * @since 1.9.0
2374
-     * @return string $course_page_url
2375
-     */
2376
-    public static function get_courses_page_url(){
2377
-
2378
-        $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
2379
-        $course_page_url = empty( $course_page_id ) ? get_post_type_archive_link('course') : get_permalink( $course_page_id );
2325
+	/**
2326
+	 * if the featured link is clicked on the course archive page
2327
+	 * filter the courses returned to only show those featured
2328
+	 *
2329
+	 * Hooked into pre_get_posts
2330
+	 *
2331
+	 * @since 1.9.0
2332
+	 * @param WP_Query $query
2333
+	 * @return WP_Query $query
2334
+	 */
2335
+	public static function course_archive_featured_filter( $query ){
2380 2336
 
2381
-        return $course_page_url;
2382
-
2383
-    }// get_course_url
2337
+		if( isset ( $_GET[ 'course_filter' ] ) && 'featured'== $_GET['course_filter'] && $query->is_main_query()  ){
2338
+			//setup meta query for featured courses
2339
+			$query->set( 'meta_value', 'featured'  );
2340
+			$query->set( 'meta_key', '_course_featured'  );
2341
+			$query->set( 'meta_compare', '='  );
2342
+		}
2384 2343
 
2385
-    /**
2386
-     * Output the headers on the course archive page
2387
-     *
2388
-     * Hooked into the sensei_archive_title
2389
-     *
2390
-     * @since 1.9.0
2391
-     * @param string $query_type
2392
-     * @param string $before_html
2393
-     * @param string $after_html
2394
-     * @return void
2395
-     */
2396
-    public static function archive_header( $query_type ='' , $before_html='', $after_html =''  ){
2344
+		return $query;
2345
+	}
2397 2346
 
2398
-        if( ! is_post_type_archive('course') ){
2399
-            return;
2400
-        }
2347
+	/**
2348
+	 * if the course order drop down is changed
2349
+	 *
2350
+	 * Hooked into pre_get_posts
2351
+	 *
2352
+	 * @since 1.9.0
2353
+	 * @param WP_Query $query
2354
+	 * @return WP_Query $query
2355
+	 */
2356
+	public static function course_archive_order_by_title( $query ){
2401 2357
 
2402
-        // deprecated since 1.9.0
2403
-        sensei_do_deprecated_action('sensei_archive_title','1.9.0','sensei_archive_before_course_loop');
2358
+		if( isset ( $_POST[ 'course-orderby' ] ) && 'title '== $_POST['course-orderby']
2359
+			&& 'course'== $query->get('post_type') && $query->is_main_query()  ){
2360
+			// setup the order by title for this query
2361
+			$query->set( 'orderby', 'title'  );
2362
+			$query->set( 'order', 'ASC'  );
2363
+		}
2404 2364
 
2405
-        $html = '';
2365
+		return $query;
2366
+	}
2406 2367
 
2407
-        if( empty( $before_html ) ){
2408 2368
 
2409
-            $before_html = '<header class="archive-header"><h1>';
2369
+	/**
2370
+	 * Get the link to the courses page. This will be the course post type archive
2371
+	 * page link or the page the user set in their settings
2372
+	 *
2373
+	 * @since 1.9.0
2374
+	 * @return string $course_page_url
2375
+	 */
2376
+	public static function get_courses_page_url(){
2410 2377
 
2411
-        }
2378
+		$course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
2379
+		$course_page_url = empty( $course_page_id ) ? get_post_type_archive_link('course') : get_permalink( $course_page_id );
2412 2380
 
2413
-        if( empty( $after_html ) ){
2381
+		return $course_page_url;
2414 2382
 
2415
-            $after_html = '</h1></header>';
2383
+	}// get_course_url
2416 2384
 
2417
-        }
2385
+	/**
2386
+	 * Output the headers on the course archive page
2387
+	 *
2388
+	 * Hooked into the sensei_archive_title
2389
+	 *
2390
+	 * @since 1.9.0
2391
+	 * @param string $query_type
2392
+	 * @param string $before_html
2393
+	 * @param string $after_html
2394
+	 * @return void
2395
+	 */
2396
+	public static function archive_header( $query_type ='' , $before_html='', $after_html =''  ){
2397
+
2398
+		if( ! is_post_type_archive('course') ){
2399
+			return;
2400
+		}
2401
+
2402
+		// deprecated since 1.9.0
2403
+		sensei_do_deprecated_action('sensei_archive_title','1.9.0','sensei_archive_before_course_loop');
2404
+
2405
+		$html = '';
2406
+
2407
+		if( empty( $before_html ) ){
2418 2408
 
2419
-        if ( is_tax( 'course-category' ) ) {
2409
+			$before_html = '<header class="archive-header"><h1>';
2420 2410
 
2421
-            global $wp_query;
2411
+		}
2412
+
2413
+		if( empty( $after_html ) ){
2422 2414
 
2423
-            $taxonomy_obj = $wp_query->get_queried_object();
2424
-            $taxonomy_short_name = $taxonomy_obj->taxonomy;
2425
-            $taxonomy_raw_obj = get_taxonomy( $taxonomy_short_name );
2426
-            $title = sprintf( __( '%1$s Archives: %2$s', 'woothemes-sensei' ), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name );
2427
-            echo apply_filters( 'course_category_archive_title', $before_html . $title . $after_html );
2428
-            return;
2415
+			$after_html = '</h1></header>';
2429 2416
 
2430
-        } // End If Statement
2417
+		}
2431 2418
 
2432
-        switch ( $query_type ) {
2433
-            case 'newcourses':
2434
-                $html .= $before_html . __( 'New Courses', 'woothemes-sensei' ) . $after_html;
2435
-                break;
2436
-            case 'featuredcourses':
2437
-                $html .= $before_html .  __( 'Featured Courses', 'woothemes-sensei' ) . $after_html;
2438
-                break;
2439
-            case 'freecourses':
2440
-                $html .= $before_html .  __( 'Free Courses', 'woothemes-sensei' ) . $after_html;
2441
-                break;
2442
-            case 'paidcourses':
2443
-                $html .= $before_html .  __( 'Paid Courses', 'woothemes-sensei' ) . $after_html;
2444
-                break;
2445
-            default:
2446
-                $html .= $before_html . __( 'Courses', 'woothemes-sensei' ) . $after_html;
2447
-                break;
2448
-        } // End Switch Statement
2419
+		if ( is_tax( 'course-category' ) ) {
2449 2420
 
2450
-        echo apply_filters( 'course_archive_title', $html );
2421
+			global $wp_query;
2451 2422
 
2452
-    }//course_archive_header
2423
+			$taxonomy_obj = $wp_query->get_queried_object();
2424
+			$taxonomy_short_name = $taxonomy_obj->taxonomy;
2425
+			$taxonomy_raw_obj = get_taxonomy( $taxonomy_short_name );
2426
+			$title = sprintf( __( '%1$s Archives: %2$s', 'woothemes-sensei' ), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name );
2427
+			echo apply_filters( 'course_category_archive_title', $before_html . $title . $after_html );
2428
+			return;
2453 2429
 
2430
+		} // End If Statement
2454 2431
 
2455
-    /**
2456
-     * Filter the single course content
2457
-     * taking into account if the user has access.
2458
-     *
2459
-     * @1.9.0
2460
-     *
2461
-     * @param string $content
2462
-     * @return string $content or $excerpt
2463
-     */
2464
-    public static function single_course_content( $content ){
2432
+		switch ( $query_type ) {
2433
+			case 'newcourses':
2434
+				$html .= $before_html . __( 'New Courses', 'woothemes-sensei' ) . $after_html;
2435
+				break;
2436
+			case 'featuredcourses':
2437
+				$html .= $before_html .  __( 'Featured Courses', 'woothemes-sensei' ) . $after_html;
2438
+				break;
2439
+			case 'freecourses':
2440
+				$html .= $before_html .  __( 'Free Courses', 'woothemes-sensei' ) . $after_html;
2441
+				break;
2442
+			case 'paidcourses':
2443
+				$html .= $before_html .  __( 'Paid Courses', 'woothemes-sensei' ) . $after_html;
2444
+				break;
2445
+			default:
2446
+				$html .= $before_html . __( 'Courses', 'woothemes-sensei' ) . $after_html;
2447
+				break;
2448
+		} // End Switch Statement
2449
+
2450
+		echo apply_filters( 'course_archive_title', $html );
2451
+
2452
+	}//course_archive_header
2453
+
2454
+
2455
+	/**
2456
+	 * Filter the single course content
2457
+	 * taking into account if the user has access.
2458
+	 *
2459
+	 * @1.9.0
2460
+	 *
2461
+	 * @param string $content
2462
+	 * @return string $content or $excerpt
2463
+	 */
2464
+	public static function single_course_content( $content ){
2465 2465
 
2466
-        if( ! is_singular('course') ){
2466
+		if( ! is_singular('course') ){
2467 2467
 
2468
-            return $content;
2468
+			return $content;
2469 2469
 
2470
-        }
2470
+		}
2471 2471
 
2472
-        // Content Access Permissions
2473
-        $access_permission = false;
2472
+		// Content Access Permissions
2473
+		$access_permission = false;
2474 2474
 
2475
-        if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) {
2475
+		if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) {
2476 2476
 
2477
-            $access_permission = true;
2477
+			$access_permission = true;
2478 2478
 
2479
-        } // End If Statement
2479
+		} // End If Statement
2480 2480
 
2481
-        // Check if the user is taking the course
2482
-        $is_user_taking_course = Sensei_Utils::user_started_course( get_the_ID(), get_current_user_id() );
2481
+		// Check if the user is taking the course
2482
+		$is_user_taking_course = Sensei_Utils::user_started_course( get_the_ID(), get_current_user_id() );
2483 2483
 
2484
-        if(Sensei_WC::is_woocommerce_active()) {
2484
+		if(Sensei_WC::is_woocommerce_active()) {
2485 2485
 
2486
-            $wc_post_id = get_post_meta( get_the_ID(), '_course_woocommerce_product', true );
2487
-            $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
2486
+			$wc_post_id = get_post_meta( get_the_ID(), '_course_woocommerce_product', true );
2487
+			$product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
2488 2488
 
2489
-            $has_product_attached = isset ( $product ) && is_object ( $product );
2489
+			$has_product_attached = isset ( $product ) && is_object ( $product );
2490 2490
 
2491
-        } else {
2491
+		} else {
2492 2492
 
2493
-            $has_product_attached = false;
2493
+			$has_product_attached = false;
2494 2494
 
2495
-        }
2495
+		}
2496 2496
 
2497
-        if ( ( is_user_logged_in() && $is_user_taking_course )
2498
-            || ( $access_permission && !$has_product_attached)
2499
-            || 'full' == Sensei()->settings->get( 'course_single_content_display' ) ) {
2497
+		if ( ( is_user_logged_in() && $is_user_taking_course )
2498
+			|| ( $access_permission && !$has_product_attached)
2499
+			|| 'full' == Sensei()->settings->get( 'course_single_content_display' ) ) {
2500 2500
 
2501
-            return $content;
2501
+			return $content;
2502 2502
 
2503
-        } else {
2503
+		} else {
2504 2504
 
2505
-            return '<p class="course-excerpt">' . get_post(  get_the_ID() )->post_excerpt . '</p>';
2505
+			return '<p class="course-excerpt">' . get_post(  get_the_ID() )->post_excerpt . '</p>';
2506 2506
 
2507
-        }
2507
+		}
2508 2508
 
2509
-    }// end single_course_content
2509
+	}// end single_course_content
2510 2510
 
2511
-    /**
2512
-     * Output the the single course lessons title with markup.
2513
-     *
2514
-     * @since 1.9.0
2515
-     */
2516
-    public static function the_course_lessons_title(){
2517
-        global $post;
2518
-        $none_module_lessons = Sensei()->modules->get_none_module_lessons( $post->ID  );
2519
-        $course_lessons = Sensei()->course->course_lessons( $post->ID );
2511
+	/**
2512
+	 * Output the the single course lessons title with markup.
2513
+	 *
2514
+	 * @since 1.9.0
2515
+	 */
2516
+	public static function the_course_lessons_title(){
2517
+		global $post;
2518
+		$none_module_lessons = Sensei()->modules->get_none_module_lessons( $post->ID  );
2519
+		$course_lessons = Sensei()->course->course_lessons( $post->ID );
2520 2520
 
2521
-        // title should be Other Lessons if there are lessons belonging to models.
2522
-        $title = __('Other Lessons', 'woothemes-sensei');
2523
-        if( count( $course_lessons ) == count( $none_module_lessons )  ){
2521
+		// title should be Other Lessons if there are lessons belonging to models.
2522
+		$title = __('Other Lessons', 'woothemes-sensei');
2523
+		if( count( $course_lessons ) == count( $none_module_lessons )  ){
2524 2524
 
2525
-            $title = __('Lessons', 'woothemes-sensei');
2525
+			$title = __('Lessons', 'woothemes-sensei');
2526 2526
 
2527
-        }
2527
+		}
2528 2528
 
2529
-        /**
2530
-         * hook document in class-woothemes-sensei-message.php
2531
-         */
2532
-        $title = apply_filters( 'sensei_single_title', $title, $post->post_type );
2529
+		/**
2530
+		 * hook document in class-woothemes-sensei-message.php
2531
+		 */
2532
+		$title = apply_filters( 'sensei_single_title', $title, $post->post_type );
2533 2533
 
2534
-        ob_start(); // start capturing the following output.
2534
+		ob_start(); // start capturing the following output.
2535 2535
 
2536
-        ?>
2536
+		?>
2537 2537
 
2538 2538
             <header>
2539 2539
                 <h2> <?php echo $title; ?> </h2>
@@ -2541,277 +2541,277 @@  discard block
 block discarded – undo
2541 2541
 
2542 2542
         <?php
2543 2543
 
2544
-        /**
2545
-         * Filter the title and markup that appears above the lessons on a single course
2546
-         * page.
2547
-         *
2548
-         * @since 1.9.0
2549
-         * @param string $lessons_title_html
2550
-         */
2551
-        echo apply_filters('the_course_lessons_title', ob_get_clean() ); // output and filter the captured output and stop capturing.
2552
-
2553
-    }// end the_course_lessons_title
2554
-
2555
-    /**
2556
-     * This function loads the global wp_query object with with lessons
2557
-     * of the current course. It is designed to be used on the single-course template
2558
-     * and expects the global post to be a singular course.
2559
-     *
2560
-     * This function excludes lessons belonging to modules as they are
2561
-     * queried separately.
2562
-     *
2563
-     * @since 1.9.0
2564
-     * @global $wp_query
2565
-     */
2566
-    public static function load_single_course_lessons_query(){
2567
-
2568
-        global $post, $wp_query;
2544
+		/**
2545
+		 * Filter the title and markup that appears above the lessons on a single course
2546
+		 * page.
2547
+		 *
2548
+		 * @since 1.9.0
2549
+		 * @param string $lessons_title_html
2550
+		 */
2551
+		echo apply_filters('the_course_lessons_title', ob_get_clean() ); // output and filter the captured output and stop capturing.
2569 2552
 
2570
-        $course_id = $post->ID;
2553
+	}// end the_course_lessons_title
2571 2554
 
2572
-        if( 'course' != get_post_type( $course_id ) ){
2573
-            return;
2574
-        }
2555
+	/**
2556
+	 * This function loads the global wp_query object with with lessons
2557
+	 * of the current course. It is designed to be used on the single-course template
2558
+	 * and expects the global post to be a singular course.
2559
+	 *
2560
+	 * This function excludes lessons belonging to modules as they are
2561
+	 * queried separately.
2562
+	 *
2563
+	 * @since 1.9.0
2564
+	 * @global $wp_query
2565
+	 */
2566
+	public static function load_single_course_lessons_query(){
2575 2567
 
2576
-        $course_lesson_query_args = array(
2577
-            'post_type'         => 'lesson',
2578
-            'posts_per_page'    => 500,
2579
-            'orderby'           => 'date',
2580
-            'order'             => 'ASC',
2581
-            'meta_query'        => array(
2582
-                array(
2583
-                    'key' => '_lesson_course',
2584
-                    'value' => intval( $course_id ),
2585
-                ),
2586
-            ),
2587
-            'post_status'       => 'public',
2588
-            'suppress_filters'  => 0,
2589
-        );
2568
+		global $post, $wp_query;
2590 2569
 
2591
-        // Exclude lessons belonging to modules as they are queried along with the modules.
2592
-        $modules = Sensei()->modules->get_course_modules( $course_id );
2593
-        if( !is_wp_error( $modules ) && ! empty( $modules ) && is_array( $modules ) ){
2570
+		$course_id = $post->ID;
2594 2571
 
2595
-            $terms_ids = array();
2596
-            foreach( $modules as $term ){
2572
+		if( 'course' != get_post_type( $course_id ) ){
2573
+			return;
2574
+		}
2597 2575
 
2598
-                $terms_ids[] = $term->term_id;
2576
+		$course_lesson_query_args = array(
2577
+			'post_type'         => 'lesson',
2578
+			'posts_per_page'    => 500,
2579
+			'orderby'           => 'date',
2580
+			'order'             => 'ASC',
2581
+			'meta_query'        => array(
2582
+				array(
2583
+					'key' => '_lesson_course',
2584
+					'value' => intval( $course_id ),
2585
+				),
2586
+			),
2587
+			'post_status'       => 'public',
2588
+			'suppress_filters'  => 0,
2589
+		);
2590
+
2591
+		// Exclude lessons belonging to modules as they are queried along with the modules.
2592
+		$modules = Sensei()->modules->get_course_modules( $course_id );
2593
+		if( !is_wp_error( $modules ) && ! empty( $modules ) && is_array( $modules ) ){
2594
+
2595
+			$terms_ids = array();
2596
+			foreach( $modules as $term ){
2597
+
2598
+				$terms_ids[] = $term->term_id;
2599 2599
 
2600
-            }
2600
+			}
2601 2601
 
2602
-            $course_lesson_query_args[ 'tax_query'] = array(
2603
-                array(
2604
-                    'taxonomy' => 'module',
2605
-                    'field'    => 'id',
2606
-                    'terms'    => $terms_ids,
2607
-                    'operator' => 'NOT IN',
2608
-                ),
2609
-            );
2610
-        }
2602
+			$course_lesson_query_args[ 'tax_query'] = array(
2603
+				array(
2604
+					'taxonomy' => 'module',
2605
+					'field'    => 'id',
2606
+					'terms'    => $terms_ids,
2607
+					'operator' => 'NOT IN',
2608
+				),
2609
+			);
2610
+		}
2611 2611
 
2612
-        $wp_query = new WP_Query( $course_lesson_query_args );
2612
+		$wp_query = new WP_Query( $course_lesson_query_args );
2613 2613
 
2614
-    }// load_single_course_lessons
2614
+	}// load_single_course_lessons
2615 2615
 
2616
-    /**
2617
-     * Flush the rewrite rules for a course post type
2618
-     *
2619
-     * @since 1.9.0
2620
-     *
2621
-     * @param $post_id
2622
-     */
2623
-    public static function flush_rewrite_rules( $post_id ){
2616
+	/**
2617
+	 * Flush the rewrite rules for a course post type
2618
+	 *
2619
+	 * @since 1.9.0
2620
+	 *
2621
+	 * @param $post_id
2622
+	 */
2623
+	public static function flush_rewrite_rules( $post_id ){
2624 2624
 
2625
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
2625
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
2626 2626
 
2627
-            return;
2627
+			return;
2628 2628
 
2629
-        }
2629
+		}
2630 2630
 
2631 2631
 
2632
-        if( 'course' == get_post_type( $post_id )  ){
2632
+		if( 'course' == get_post_type( $post_id )  ){
2633 2633
 
2634
-            Sensei()->initiate_rewrite_rules_flush();
2634
+			Sensei()->initiate_rewrite_rules_flush();
2635 2635
 
2636
-        }
2636
+		}
2637 2637
 
2638
-    }
2638
+	}
2639 2639
 
2640
-    /**
2641
-     * Optionally return the full content on the single course pages
2642
-     * depending on the users course_single_content_display setting
2643
-     *
2644
-     * @since 1.9.0
2645
-     * @param $excerpt
2646
-     * @return string
2647
-     */
2648
-    public static function full_content_excerpt_override( $excerpt ){
2640
+	/**
2641
+	 * Optionally return the full content on the single course pages
2642
+	 * depending on the users course_single_content_display setting
2643
+	 *
2644
+	 * @since 1.9.0
2645
+	 * @param $excerpt
2646
+	 * @return string
2647
+	 */
2648
+	public static function full_content_excerpt_override( $excerpt ){
2649 2649
 
2650
-        if (   is_singular('course')  &&
2651
-                'full' == Sensei()->settings->get( 'course_single_content_display' ) ){
2650
+		if (   is_singular('course')  &&
2651
+				'full' == Sensei()->settings->get( 'course_single_content_display' ) ){
2652 2652
 
2653
-            return get_the_content();
2653
+			return get_the_content();
2654 2654
 
2655
-        } else {
2655
+		} else {
2656 2656
 
2657
-            return $excerpt;
2657
+			return $excerpt;
2658 2658
 
2659
-        }
2659
+		}
2660 2660
 
2661
-    }
2661
+	}
2662 2662
 
2663
-    /**
2664
-     * Output the course actions like start taking course, register, add to cart etc.
2665
-     *
2666
-     * @since 1.9.0
2667
-     */
2668
-    public static function the_course_enrolment_actions(){
2669
-        ?>
2663
+	/**
2664
+	 * Output the course actions like start taking course, register, add to cart etc.
2665
+	 *
2666
+	 * @since 1.9.0
2667
+	 */
2668
+	public static function the_course_enrolment_actions(){
2669
+		?>
2670 2670
         <section class="course-meta course-enrolment">
2671 2671
         <?php
2672
-        global  $post, $current_user;
2673
-        $is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
2674
-        if ( is_user_logged_in() && ! $is_user_taking_course ) {
2675
-
2676
-            // Get the product ID
2677
-            $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
2678
-
2679
-            // Check for woocommerce
2680
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) {
2681
-                sensei_wc_add_to_cart($post->ID);
2682
-            } else {
2683
-                sensei_start_course_form($post->ID);
2684
-            } // End If Statement
2685
-
2686
-        } elseif ( is_user_logged_in() ) {
2687
-
2688
-            // Check if course is completed
2689
-            $user_course_status = Sensei_Utils::user_course_status( $post->ID, $current_user->ID );
2690
-            $completed_course = Sensei_Utils::user_completed_course( $user_course_status );
2691
-            // Success message
2692
-            if ( $completed_course ) { ?>
2672
+		global  $post, $current_user;
2673
+		$is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
2674
+		if ( is_user_logged_in() && ! $is_user_taking_course ) {
2675
+
2676
+			// Get the product ID
2677
+			$wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
2678
+
2679
+			// Check for woocommerce
2680
+			if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) {
2681
+				sensei_wc_add_to_cart($post->ID);
2682
+			} else {
2683
+				sensei_start_course_form($post->ID);
2684
+			} // End If Statement
2685
+
2686
+		} elseif ( is_user_logged_in() ) {
2687
+
2688
+			// Check if course is completed
2689
+			$user_course_status = Sensei_Utils::user_course_status( $post->ID, $current_user->ID );
2690
+			$completed_course = Sensei_Utils::user_completed_course( $user_course_status );
2691
+			// Success message
2692
+			if ( $completed_course ) { ?>
2693 2693
                 <div class="status completed"><?php  _e( 'Completed', 'woothemes-sensei' ); ?></div>
2694 2694
                 <?php
2695
-                $has_quizzes = Sensei()->course->course_quizzes( $post->ID, true );
2696
-                if( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?>
2695
+				$has_quizzes = Sensei()->course->course_quizzes( $post->ID, true );
2696
+				if( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?>
2697 2697
                     <p class="sensei-results-links">
2698 2698
                         <?php
2699
-                        $results_link = '';
2700
-                        if( $has_quizzes ) {
2701
-                            $results_link = '<a class="view-results" href="' . Sensei()->course_results->get_permalink( $post->ID ) . '">' .  __( 'View results', 'woothemes-sensei' ) . '</a>';
2702
-                        }
2703
-                        $results_link = apply_filters( 'sensei_results_links', $results_link );
2704
-                        echo $results_link;
2705
-                        ?></p>
2699
+						$results_link = '';
2700
+						if( $has_quizzes ) {
2701
+							$results_link = '<a class="view-results" href="' . Sensei()->course_results->get_permalink( $post->ID ) . '">' .  __( 'View results', 'woothemes-sensei' ) . '</a>';
2702
+						}
2703
+						$results_link = apply_filters( 'sensei_results_links', $results_link );
2704
+						echo $results_link;
2705
+						?></p>
2706 2706
                 <?php } ?>
2707 2707
             <?php } else { ?>
2708 2708
                 <div class="status in-progress"><?php echo __( 'In Progress', 'woothemes-sensei' ); ?></div>
2709 2709
             <?php }
2710 2710
 
2711
-        } else {
2712
-            // Get the product ID
2713
-            $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
2714
-            // Check for woocommerce
2715
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) {
2711
+		} else {
2712
+			// Get the product ID
2713
+			$wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
2714
+			// Check for woocommerce
2715
+			if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) {
2716 2716
 
2717
-                sensei_wc_add_to_cart($post->ID);
2717
+				sensei_wc_add_to_cart($post->ID);
2718 2718
 
2719
-            } else {
2719
+			} else {
2720 2720
 
2721
-                if( get_option( 'users_can_register') ) {
2721
+				if( get_option( 'users_can_register') ) {
2722 2722
 
2723 2723
 
2724
-                    $my_courses_page_id = '';
2724
+					$my_courses_page_id = '';
2725 2725
 
2726
-                    /**
2727
-                     * Filter to force Sensei to output the default WordPress user
2728
-                     * registration link.
2729
-                     *
2730
-                     * @since 1.9.0
2731
-                     * @param bool $wp_register_link default false
2732
-                     */
2726
+					/**
2727
+					 * Filter to force Sensei to output the default WordPress user
2728
+					 * registration link.
2729
+					 *
2730
+					 * @since 1.9.0
2731
+					 * @param bool $wp_register_link default false
2732
+					 */
2733 2733
 
2734
-                    $wp_register_link = apply_filters('sensei_use_wp_register_link', false);
2734
+					$wp_register_link = apply_filters('sensei_use_wp_register_link', false);
2735 2735
 
2736
-                    $settings = Sensei()->settings->get_settings();
2737
-                    if( isset( $settings[ 'my_course_page' ] )
2738
-                        && 0 < intval( $settings[ 'my_course_page' ] ) ){
2736
+					$settings = Sensei()->settings->get_settings();
2737
+					if( isset( $settings[ 'my_course_page' ] )
2738
+						&& 0 < intval( $settings[ 'my_course_page' ] ) ){
2739 2739
 
2740
-                        $my_courses_page_id = $settings[ 'my_course_page' ];
2740
+						$my_courses_page_id = $settings[ 'my_course_page' ];
2741 2741
 
2742
-                    }
2742
+					}
2743 2743
 
2744
-                    // If a My Courses page was set in Settings, and 'sensei_use_wp_register_link'
2745
-                    // is false, link to My Courses. If not, link to default WordPress registration page.
2746
-                    if( !empty( $my_courses_page_id ) && $my_courses_page_id && !$wp_register_link){
2744
+					// If a My Courses page was set in Settings, and 'sensei_use_wp_register_link'
2745
+					// is false, link to My Courses. If not, link to default WordPress registration page.
2746
+					if( !empty( $my_courses_page_id ) && $my_courses_page_id && !$wp_register_link){
2747 2747
 
2748
-                        $my_courses_url = get_permalink( $my_courses_page_id  );
2749
-                        $register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>';
2750
-                        echo '<div class="status register">' . $register_link . '</div>' ;
2748
+						$my_courses_url = get_permalink( $my_courses_page_id  );
2749
+						$register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>';
2750
+						echo '<div class="status register">' . $register_link . '</div>' ;
2751 2751
 
2752
-                    } else{
2752
+					} else{
2753 2753
 
2754
-                        wp_register( '<div class="status register">', '</div>' );
2754
+						wp_register( '<div class="status register">', '</div>' );
2755 2755
 
2756
-                    }
2756
+					}
2757 2757
 
2758
-                } // end if user can register
2758
+				} // end if user can register
2759 2759
 
2760
-            } // End If Statement
2760
+			} // End If Statement
2761 2761
 
2762
-        } // End If Statement ?>
2762
+		} // End If Statement ?>
2763 2763
 
2764 2764
         </section><?php
2765 2765
 
2766
-    }// end the_course_enrolment_actions
2766
+	}// end the_course_enrolment_actions
2767 2767
 
2768
-    /**
2769
-     * Output the course video inside the loop.
2770
-     *
2771
-     * @since 1.9.0
2772
-     */
2773
-    public static function the_course_video(){
2768
+	/**
2769
+	 * Output the course video inside the loop.
2770
+	 *
2771
+	 * @since 1.9.0
2772
+	 */
2773
+	public static function the_course_video(){
2774 2774
 
2775
-        global $post;
2776
-        // Get the meta info
2777
-        $course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true );
2775
+		global $post;
2776
+		// Get the meta info
2777
+		$course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true );
2778 2778
 
2779
-        if ( 'http' == substr( $course_video_embed, 0, 4) ) {
2779
+		if ( 'http' == substr( $course_video_embed, 0, 4) ) {
2780 2780
 
2781
-            $course_video_embed = wp_oembed_get( esc_url( $course_video_embed ) );
2781
+			$course_video_embed = wp_oembed_get( esc_url( $course_video_embed ) );
2782 2782
 
2783
-        } // End If Statement
2783
+		} // End If Statement
2784 2784
 
2785
-        if ( '' != $course_video_embed ) { ?>
2785
+		if ( '' != $course_video_embed ) { ?>
2786 2786
 
2787 2787
             <div class="course-video">
2788 2788
                 <?php echo html_entity_decode($course_video_embed); ?>
2789 2789
             </div>
2790 2790
 
2791 2791
         <?php } // End If Statement
2792
-    }
2792
+	}
2793 2793
 
2794
-    /**
2795
-     * Output the title for the single lesson page
2796
-     *
2797
-     * @global $post
2798
-     * @since 1.9.0
2799
-     */
2800
-    public static function the_title(){
2794
+	/**
2795
+	 * Output the title for the single lesson page
2796
+	 *
2797
+	 * @global $post
2798
+	 * @since 1.9.0
2799
+	 */
2800
+	public static function the_title(){
2801 2801
 
2802
-        global $post;
2802
+		global $post;
2803 2803
 
2804
-        ?>
2804
+		?>
2805 2805
         <header>
2806 2806
 
2807 2807
             <h1>
2808 2808
 
2809 2809
                 <?php
2810
-                /**
2811
-                 * Filter documented in class-sensei-messages.php the_title
2812
-                 */
2813
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
2814
-                ?>
2810
+				/**
2811
+				 * Filter documented in class-sensei-messages.php the_title
2812
+				 */
2813
+				echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
2814
+				?>
2815 2815
 
2816 2816
             </h1>
2817 2817
 
@@ -2819,111 +2819,111 @@  discard block
 block discarded – undo
2819 2819
 
2820 2820
         <?php
2821 2821
 
2822
-    }//the_title
2823
-
2824
-    /**
2825
-     * Show the title on the course category pages
2826
-     *
2827
-     * @since 1.9.0
2828
-     */
2829
-    public static function course_category_title(){
2830
-
2831
-        if( ! is_tax( 'course-category' ) ){
2832
-            return;
2833
-        }
2834
-
2835
-        $category_slug = get_query_var('course-category');
2836
-        $term  = get_term_by('slug',$category_slug,'course-category');
2837
-
2838
-        if( ! empty($term) ){
2839
-
2840
-            $title = $term->name;
2841
-
2842
-        }else{
2843
-
2844
-            $title = 'Course Category';
2845
-
2846
-        }
2847
-
2848
-        $html = '<h2 class="sensei-category-title">';
2849
-        $html .= __('Category') . ' ' . $title;
2850
-        $html .= '</h2>';
2851
-
2852
-        echo apply_filters( 'course_category_title', $html , $term->term_id );
2853
-
2854
-    }// course_category_title
2855
-
2856
-    /**
2857
-     * Alter the course query to respect the order set for courses and apply
2858
-     * this on the course-category pages.
2859
-     *
2860
-     * @since 1.9.0
2861
-     *
2862
-     * @param WP_Query $query
2863
-     * @return WP_Query
2864
-     */
2865
-    public static function alter_course_category_order( $query ){
2866
-
2867
-        if( ! is_tax( 'course-category' ) || ! $query->is_main_query() ){
2868
-            return $query;
2869
-        }
2870
-
2871
-        $order = get_option( 'sensei_course_order', '' );
2872
-        if( !empty( $order )  ){
2873
-            $query->set('orderby', 'menu_order' );
2874
-            $query->set('order', 'ASC' );
2875
-        }
2876
-
2877
-        return $query;
2878
-
2879
-    }
2880
-
2881
-    /**
2882
-     * The very basic course query arguments
2883
-     * so we don't have to repeat this througout
2884
-     * the code base.
2885
-     *
2886
-     * Usage:
2887
-     * $args = Sensei_Course::get_default_query_args();
2888
-     * $args['custom_arg'] ='custom value';
2889
-     * $courses = get_posts( $args )
2890
-     *
2891
-     * @since 1.9.0
2892
-     *
2893
-     * @return array
2894
-     */
2895
-    public static function get_default_query_args(){
2896
-        return array(
2897
-            'post_type' 		=> 'course',
2898
-            'posts_per_page' 		=> 1000,
2899
-            'orderby'         	=> 'date',
2900
-            'order'           	=> 'DESC',
2901
-            'suppress_filters' 	=> 0
2902
-        );
2903
-    }
2904
-
2905
-    /**
2906
-     * Check if the prerequisite course is completed
2907
-     * Courses with no pre-requisite should always return true
2908
-     *
2909
-     * @since 1.9.0
2910
-     * @param $course_id
2911
-     * @return bool
2912
-     */
2913
-    public static function is_prerequisite_complete( $course_id ){
2914
-
2915
-        $course_prerequisite_id = get_post_meta( $course_id, '_course_prerequisite', true );
2916
-
2917
-        // if it has a pre requisite course check it
2918
-        if( ! empty(  $course_prerequisite_id ) ){
2919
-
2920
-            return Sensei_Utils::user_completed_course( $course_prerequisite_id, get_current_user_id() );
2921
-
2922
-        }
2923
-
2924
-        return true;
2925
-
2926
-    }// end is_prerequisite_complete
2822
+	}//the_title
2823
+
2824
+	/**
2825
+	 * Show the title on the course category pages
2826
+	 *
2827
+	 * @since 1.9.0
2828
+	 */
2829
+	public static function course_category_title(){
2830
+
2831
+		if( ! is_tax( 'course-category' ) ){
2832
+			return;
2833
+		}
2834
+
2835
+		$category_slug = get_query_var('course-category');
2836
+		$term  = get_term_by('slug',$category_slug,'course-category');
2837
+
2838
+		if( ! empty($term) ){
2839
+
2840
+			$title = $term->name;
2841
+
2842
+		}else{
2843
+
2844
+			$title = 'Course Category';
2845
+
2846
+		}
2847
+
2848
+		$html = '<h2 class="sensei-category-title">';
2849
+		$html .= __('Category') . ' ' . $title;
2850
+		$html .= '</h2>';
2851
+
2852
+		echo apply_filters( 'course_category_title', $html , $term->term_id );
2853
+
2854
+	}// course_category_title
2855
+
2856
+	/**
2857
+	 * Alter the course query to respect the order set for courses and apply
2858
+	 * this on the course-category pages.
2859
+	 *
2860
+	 * @since 1.9.0
2861
+	 *
2862
+	 * @param WP_Query $query
2863
+	 * @return WP_Query
2864
+	 */
2865
+	public static function alter_course_category_order( $query ){
2866
+
2867
+		if( ! is_tax( 'course-category' ) || ! $query->is_main_query() ){
2868
+			return $query;
2869
+		}
2870
+
2871
+		$order = get_option( 'sensei_course_order', '' );
2872
+		if( !empty( $order )  ){
2873
+			$query->set('orderby', 'menu_order' );
2874
+			$query->set('order', 'ASC' );
2875
+		}
2876
+
2877
+		return $query;
2878
+
2879
+	}
2880
+
2881
+	/**
2882
+	 * The very basic course query arguments
2883
+	 * so we don't have to repeat this througout
2884
+	 * the code base.
2885
+	 *
2886
+	 * Usage:
2887
+	 * $args = Sensei_Course::get_default_query_args();
2888
+	 * $args['custom_arg'] ='custom value';
2889
+	 * $courses = get_posts( $args )
2890
+	 *
2891
+	 * @since 1.9.0
2892
+	 *
2893
+	 * @return array
2894
+	 */
2895
+	public static function get_default_query_args(){
2896
+		return array(
2897
+			'post_type' 		=> 'course',
2898
+			'posts_per_page' 		=> 1000,
2899
+			'orderby'         	=> 'date',
2900
+			'order'           	=> 'DESC',
2901
+			'suppress_filters' 	=> 0
2902
+		);
2903
+	}
2904
+
2905
+	/**
2906
+	 * Check if the prerequisite course is completed
2907
+	 * Courses with no pre-requisite should always return true
2908
+	 *
2909
+	 * @since 1.9.0
2910
+	 * @param $course_id
2911
+	 * @return bool
2912
+	 */
2913
+	public static function is_prerequisite_complete( $course_id ){
2914
+
2915
+		$course_prerequisite_id = get_post_meta( $course_id, '_course_prerequisite', true );
2916
+
2917
+		// if it has a pre requisite course check it
2918
+		if( ! empty(  $course_prerequisite_id ) ){
2919
+
2920
+			return Sensei_Utils::user_completed_course( $course_prerequisite_id, get_current_user_id() );
2921
+
2922
+		}
2923
+
2924
+		return true;
2925
+
2926
+	}// end is_prerequisite_complete
2927 2927
 
2928 2928
 
2929 2929
 }// End Class
Please login to merge, or discard this patch.
Spacing   +641 added lines, -641 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Course Class
@@ -33,72 +33,72 @@  discard block
 block discarded – undo
33 33
 	 * Constructor.
34 34
 	 * @since  1.0.0
35 35
 	 */
36
-	public function __construct () {
36
+	public function __construct() {
37 37
 
38 38
         $this->token = 'course';
39 39
 
40 40
 		// Setup meta fields for this post type
41
-		$this->meta_fields = array( 'course_prerequisite', 'course_featured', 'course_video_embed', 'course_woocommerce_product' );
41
+		$this->meta_fields = array('course_prerequisite', 'course_featured', 'course_video_embed', 'course_woocommerce_product');
42 42
 		// Admin actions
43
-		if ( is_admin() ) {
43
+		if (is_admin()) {
44 44
 			// Metabox functions
45
-            add_action( 'add_meta_boxes', array( $this, 'meta_box_setup' ), 20 );
46
-			add_action( 'save_post', array( $this, 'meta_box_save' ) );
45
+            add_action('add_meta_boxes', array($this, 'meta_box_setup'), 20);
46
+			add_action('save_post', array($this, 'meta_box_save'));
47 47
 			// Custom Write Panel Columns
48
-			add_filter( 'manage_edit-course_columns', array( $this, 'add_column_headings' ), 10, 1 );
49
-			add_action( 'manage_posts_custom_column', array( $this, 'add_column_data' ), 10, 2 );
48
+			add_filter('manage_edit-course_columns', array($this, 'add_column_headings'), 10, 1);
49
+			add_action('manage_posts_custom_column', array($this, 'add_column_data'), 10, 2);
50 50
 		} else {
51 51
 			$this->my_courses_page = false;
52 52
 		} // End If Statement
53 53
 
54 54
 		// Update course completion upon completion of a lesson
55
-		add_action( 'sensei_user_lesson_end', array( $this, 'update_status_after_lesson_change' ), 10, 2 );
55
+		add_action('sensei_user_lesson_end', array($this, 'update_status_after_lesson_change'), 10, 2);
56 56
 		// Update course completion upon reset of a lesson
57
-		add_action( 'sensei_user_lesson_reset', array( $this, 'update_status_after_lesson_change' ), 10, 2 );
57
+		add_action('sensei_user_lesson_reset', array($this, 'update_status_after_lesson_change'), 10, 2);
58 58
 		// Update course completion upon grading of a quiz
59
-		add_action( 'sensei_user_quiz_grade', array( $this, 'update_status_after_quiz_submission' ), 10, 2 );
59
+		add_action('sensei_user_quiz_grade', array($this, 'update_status_after_quiz_submission'), 10, 2);
60 60
 
61 61
         // show the progress bar ont he single course page
62
-        add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_statement' ), 15 );
63
-        add_action( 'sensei_single_course_content_inside_before' , array( $this, 'the_progress_meter' ), 16 );
62
+        add_action('sensei_single_course_content_inside_before', array($this, 'the_progress_statement'), 15);
63
+        add_action('sensei_single_course_content_inside_before', array($this, 'the_progress_meter'), 16);
64 64
 
65 65
         // provide an option to block all emails related to a selected course
66
-        add_filter( 'sensei_send_emails', array( $this, 'block_notification_emails' ) );
67
-        add_action( 'save_post', array( $this, 'save_course_notification_meta_box' ) );
66
+        add_filter('sensei_send_emails', array($this, 'block_notification_emails'));
67
+        add_action('save_post', array($this, 'save_course_notification_meta_box'));
68 68
 
69 69
         // preview lessons on the course content
70
-        add_action( 'sensei_course_content_inside_after',array( $this, 'the_course_free_lesson_preview' ) );
70
+        add_action('sensei_course_content_inside_after', array($this, 'the_course_free_lesson_preview'));
71 71
 
72 72
         // the course meta
73
-        add_action('sensei_course_content_inside_before', array( $this, 'the_course_meta' ) );
73
+        add_action('sensei_course_content_inside_before', array($this, 'the_course_meta'));
74 74
 
75 75
         // backwards compatible template hooks
76
-        add_action('sensei_course_content_inside_before', array( $this, 'content_before_backwards_compatibility_hooks' ));
77
-        add_action('sensei_loop_course_before', array( $this,'loop_before_backwards_compatibility_hooks' ) );
76
+        add_action('sensei_course_content_inside_before', array($this, 'content_before_backwards_compatibility_hooks'));
77
+        add_action('sensei_loop_course_before', array($this, 'loop_before_backwards_compatibility_hooks'));
78 78
 
79 79
         // add the user status on the course to the markup as a class
80
-        add_filter('post_class', array( __CLASS__ , 'add_course_user_status_class' ), 20, 3 );
80
+        add_filter('post_class', array(__CLASS__, 'add_course_user_status_class'), 20, 3);
81 81
 
82 82
         //filter the course query in Sensei specific instances
83
-        add_filter( 'pre_get_posts', array( __CLASS__, 'course_query_filter' ) );
83
+        add_filter('pre_get_posts', array(__CLASS__, 'course_query_filter'));
84 84
 
85 85
         //attache the sorting to the course archive
86
-        add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_sorting' ) );
86
+        add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'course_archive_sorting'));
87 87
 
88 88
         //attach the filter links to the course archive
89
-        add_action ( 'sensei_archive_before_course_loop' , array( 'Sensei_Course', 'course_archive_filters' ) );
89
+        add_action('sensei_archive_before_course_loop', array('Sensei_Course', 'course_archive_filters'));
90 90
 
91 91
         //filter the course query when featured filter is applied
92
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'course_archive_featured_filter'));
92
+        add_filter('pre_get_posts', array(__CLASS__, 'course_archive_featured_filter'));
93 93
 
94 94
         // handle the order by title post submission
95
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'course_archive_order_by_title'));
95
+        add_filter('pre_get_posts', array(__CLASS__, 'course_archive_order_by_title'));
96 96
 
97 97
         // ensure the course category page respects the manual order set for courses
98
-        add_filter( 'pre_get_posts',  array( __CLASS__, 'alter_course_category_order'));
98
+        add_filter('pre_get_posts', array(__CLASS__, 'alter_course_category_order'));
99 99
 
100 100
         // flush rewrite rules when saving a course
101
-        add_action('save_post', array( 'Sensei_Course', 'flush_rewrite_rules' ) );
101
+        add_action('save_post', array('Sensei_Course', 'flush_rewrite_rules'));
102 102
 
103 103
 	} // End __construct()
104 104
 
@@ -108,10 +108,10 @@  discard block
 block discarded – undo
108 108
 	 * @param type $user_id
109 109
 	 * @param type $quiz_id
110 110
 	 */
111
-	public function update_status_after_quiz_submission( $user_id, $quiz_id ) {
112
-		if ( intval( $user_id ) > 0 && intval( $quiz_id ) > 0 ) {
113
-			$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
114
-			$this->update_status_after_lesson_change( $user_id, $lesson_id );
111
+	public function update_status_after_quiz_submission($user_id, $quiz_id) {
112
+		if (intval($user_id) > 0 && intval($quiz_id) > 0) {
113
+			$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
114
+			$this->update_status_after_lesson_change($user_id, $lesson_id);
115 115
 		}
116 116
 	}
117 117
 
@@ -121,12 +121,12 @@  discard block
 block discarded – undo
121 121
 	 * @param int $user_id
122 122
 	 * @param int $lesson_id
123 123
 	 */
124
-	public function update_status_after_lesson_change( $user_id, $lesson_id ) {
125
-		if ( intval( $user_id ) > 0 && intval( $lesson_id ) > 0 ) {
126
-			$course_id = get_post_meta( $lesson_id, '_lesson_course', true );
127
-			if ( intval( $course_id ) > 0 ) {
124
+	public function update_status_after_lesson_change($user_id, $lesson_id) {
125
+		if (intval($user_id) > 0 && intval($lesson_id) > 0) {
126
+			$course_id = get_post_meta($lesson_id, '_lesson_course', true);
127
+			if (intval($course_id) > 0) {
128 128
 				// Updates the Course status and it's meta data
129
-				Sensei_Utils::user_complete_course( $course_id, $user_id );
129
+				Sensei_Utils::user_complete_course($course_id, $user_id);
130 130
 			}
131 131
 		}
132 132
 	}
@@ -137,27 +137,27 @@  discard block
 block discarded – undo
137 137
 	 * @access public
138 138
 	 * @return void
139 139
 	 */
140
-	public function meta_box_setup () {
140
+	public function meta_box_setup() {
141 141
 
142
-		if ( Sensei_WC::is_woocommerce_active() ) {
142
+		if (Sensei_WC::is_woocommerce_active()) {
143 143
 			// Add Meta Box for WooCommerce Course
144
-			add_meta_box( 'course-wc-product', __( 'WooCommerce Product', 'woothemes-sensei' ), array( $this, 'course_woocommerce_product_meta_box_content' ), $this->token, 'side', 'default' );
144
+			add_meta_box('course-wc-product', __('WooCommerce Product', 'woothemes-sensei'), array($this, 'course_woocommerce_product_meta_box_content'), $this->token, 'side', 'default');
145 145
 		} // End If Statement
146 146
 		// Add Meta Box for Prerequisite Course
147
-		add_meta_box( 'course-prerequisite', __( 'Course Prerequisite', 'woothemes-sensei' ), array( $this, 'course_prerequisite_meta_box_content' ), $this->token, 'side', 'default' );
147
+		add_meta_box('course-prerequisite', __('Course Prerequisite', 'woothemes-sensei'), array($this, 'course_prerequisite_meta_box_content'), $this->token, 'side', 'default');
148 148
 		// Add Meta Box for Featured Course
149
-		add_meta_box( 'course-featured', __( 'Featured Course', 'woothemes-sensei' ), array( $this, 'course_featured_meta_box_content' ), $this->token, 'side', 'default' );
149
+		add_meta_box('course-featured', __('Featured Course', 'woothemes-sensei'), array($this, 'course_featured_meta_box_content'), $this->token, 'side', 'default');
150 150
 		// Add Meta Box for Course Meta
151
-		add_meta_box( 'course-video', __( 'Course Video', 'woothemes-sensei' ), array( $this, 'course_video_meta_box_content' ), $this->token, 'normal', 'default' );
151
+		add_meta_box('course-video', __('Course Video', 'woothemes-sensei'), array($this, 'course_video_meta_box_content'), $this->token, 'normal', 'default');
152 152
 		// Add Meta Box for Course Lessons
153
-		add_meta_box( 'course-lessons', __( 'Course Lessons', 'woothemes-sensei' ), array( $this, 'course_lessons_meta_box_content' ), $this->token, 'normal', 'default' );
153
+		add_meta_box('course-lessons', __('Course Lessons', 'woothemes-sensei'), array($this, 'course_lessons_meta_box_content'), $this->token, 'normal', 'default');
154 154
         // Add Meta Box to link to Manage Learners
155
-        add_meta_box( 'course-manage', __( 'Course Management', 'woothemes-sensei' ), array( $this, 'course_manage_meta_box_content' ), $this->token, 'side', 'default' );
155
+        add_meta_box('course-manage', __('Course Management', 'woothemes-sensei'), array($this, 'course_manage_meta_box_content'), $this->token, 'side', 'default');
156 156
         // Remove "Custom Settings" meta box.
157
-		remove_meta_box( 'woothemes-settings', $this->token, 'normal' );
157
+		remove_meta_box('woothemes-settings', $this->token, 'normal');
158 158
 
159 159
         // add Disable email notification box
160
-        add_meta_box( 'course-notifications', __( 'Course Notifications', 'woothemes-sensei' ), array( $this, 'course_notification_meta_box_content' ), 'course', 'normal', 'default' );
160
+        add_meta_box('course-notifications', __('Course Notifications', 'woothemes-sensei'), array($this, 'course_notification_meta_box_content'), 'course', 'normal', 'default');
161 161
 
162 162
 	} // End meta_box_setup()
163 163
 
@@ -167,58 +167,58 @@  discard block
 block discarded – undo
167 167
 	 * @access public
168 168
 	 * @return void
169 169
 	 */
170
-	public function course_woocommerce_product_meta_box_content () {
170
+	public function course_woocommerce_product_meta_box_content() {
171 171
 		global $post;
172 172
 
173
-		$select_course_woocommerce_product = get_post_meta( $post->ID, '_course_woocommerce_product', true );
173
+		$select_course_woocommerce_product = get_post_meta($post->ID, '_course_woocommerce_product', true);
174 174
 
175
-		$post_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
175
+		$post_args = array('post_type' 		=> array('product', 'product_variation'),
176 176
 							'posts_per_page' 		=> -1,
177 177
 							'orderby'         	=> 'title',
178 178
     						'order'           	=> 'DESC',
179 179
     						'exclude' 			=> $post->ID,
180
-    						'post_status'		=> array( 'publish', 'private', 'draft' ),
180
+    						'post_status'		=> array('publish', 'private', 'draft'),
181 181
     						'tax_query'			=> array(
182 182
 								array(
183 183
 									'taxonomy'	=> 'product_type',
184 184
 									'field'		=> 'slug',
185
-									'terms'		=> array( 'variable', 'grouped' ),
185
+									'terms'		=> array('variable', 'grouped'),
186 186
 									'operator'	=> 'NOT IN'
187 187
 								)
188 188
 							),
189 189
 							'suppress_filters' 	=> 0
190 190
 							);
191
-		$posts_array = get_posts( $post_args );
191
+		$posts_array = get_posts($post_args);
192 192
 
193 193
 		$html = '';
194 194
 
195
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
195
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
196 196
 
197
-		if ( count( $posts_array ) > 0 ) {
197
+		if (count($posts_array) > 0) {
198 198
 
199
-			$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n";
200
-			$html .= '<option value="-">' . __( 'None', 'woothemes-sensei' ) . '</option>';
199
+			$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">'."\n";
200
+			$html .= '<option value="-">'.__('None', 'woothemes-sensei').'</option>';
201 201
 				$prev_parent_id = 0;
202
-				foreach ( $posts_array as $post_item ) {
202
+				foreach ($posts_array as $post_item) {
203 203
 
204
-					if ( 'product_variation' == $post_item->post_type ) {
204
+					if ('product_variation' == $post_item->post_type) {
205 205
 
206
-						$product_object = get_product( $post_item->ID );
207
-						$parent_id = wp_get_post_parent_id( $post_item->ID );
206
+						$product_object = get_product($post_item->ID);
207
+						$parent_id = wp_get_post_parent_id($post_item->ID);
208 208
 
209
-                        if( sensei_check_woocommerce_version( '2.1' ) ) {
210
-							$formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true );
209
+                        if (sensei_check_woocommerce_version('2.1')) {
210
+							$formatted_variation = wc_get_formatted_variation($product_object->variation_data, true);
211 211
 
212 212
 						} else {
213 213
                             // fall back to pre wc 2.1
214
-							$formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true );
214
+							$formatted_variation = woocommerce_get_formatted_variation($product_object->variation_data, true);
215 215
 
216 216
 						}
217 217
 
218
-                        $product_name = ucwords( $formatted_variation );
219
-                        if( empty( $product_name ) ){
218
+                        $product_name = ucwords($formatted_variation);
219
+                        if (empty($product_name)) {
220 220
 
221
-                            $product_name = __( 'Variation #', 'woothemes-sensei' ) . $product_object->variation_id;
221
+                            $product_name = __('Variation #', 'woothemes-sensei').$product_object->variation_id;
222 222
 
223 223
                         }
224 224
 
@@ -231,47 +231,47 @@  discard block
 block discarded – undo
231 231
 					}
232 232
 
233 233
 					// Show variations in groups
234
-					if( $parent_id && $parent_id != $prev_parent_id ) {
234
+					if ($parent_id && $parent_id != $prev_parent_id) {
235 235
 
236
-						if( 0 != $prev_parent_id ) {
236
+						if (0 != $prev_parent_id) {
237 237
 
238 238
 							$html .= '</optgroup>';
239 239
 
240 240
 						}
241
-						$html .= '<optgroup label="' . get_the_title( $parent_id ) . '">';
241
+						$html .= '<optgroup label="'.get_the_title($parent_id).'">';
242 242
 						$prev_parent_id = $parent_id;
243 243
 
244
-					} elseif( ! $parent_id && 0 == $prev_parent_id ) {
244
+					} elseif ( ! $parent_id && 0 == $prev_parent_id) {
245 245
 
246 246
 						$html .= '</optgroup>';
247 247
 
248 248
 					}
249 249
 
250
-					$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_course_woocommerce_product, false ) . '>' . esc_html( $product_name ) . '</option>' . "\n";
250
+					$html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_course_woocommerce_product, false).'>'.esc_html($product_name).'</option>'."\n";
251 251
 
252 252
 				} // End For Loop
253 253
 
254
-			$html .= '</select>' . "\n";
255
-			if ( current_user_can( 'publish_product' )) {
254
+			$html .= '</select>'."\n";
255
+			if (current_user_can('publish_product')) {
256 256
 
257
-				$html .= '<p>' . "\n";
258
-					$html .= '<a href="' . admin_url( 'post-new.php?post_type=product' ) . '" title="' . esc_attr( __( 'Add a Product', 'woothemes-sensei' ) ) . '">' . __( 'Add a Product', 'woothemes-sensei' ) . '</a>' . "\n";
257
+				$html .= '<p>'."\n";
258
+					$html .= '<a href="'.admin_url('post-new.php?post_type=product').'" title="'.esc_attr(__('Add a Product', 'woothemes-sensei')).'">'.__('Add a Product', 'woothemes-sensei').'</a>'."\n";
259 259
 				$html .= '</p>'."\n";
260 260
 
261 261
 			} // End If Statement
262 262
 
263 263
 		} else {
264 264
 
265
-			if ( current_user_can( 'publish_product' )) {
265
+			if (current_user_can('publish_product')) {
266 266
 
267
-				$html .= '<p>' . "\n";
268
-					$html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . '&nbsp;<a href="' . admin_url( 'post-new.php?post_type=product' ) . '" title="' . esc_attr( __( 'Add a Product', 'woothemes-sensei' ) ) . '">' . __( 'Please add some first', 'woothemes-sensei' ) . '</a>' . "\n";
267
+				$html .= '<p>'."\n";
268
+					$html .= esc_html(__('No products exist yet.', 'woothemes-sensei')).'&nbsp;<a href="'.admin_url('post-new.php?post_type=product').'" title="'.esc_attr(__('Add a Product', 'woothemes-sensei')).'">'.__('Please add some first', 'woothemes-sensei').'</a>'."\n";
269 269
 				$html .= '</p>'."\n";
270 270
 
271 271
 			} else {
272 272
 
273
-                $html .= '<p>' . "\n";
274
-					$html .= esc_html( __( 'No products exist yet.', 'woothemes-sensei' ) ) . "\n";
273
+                $html .= '<p>'."\n";
274
+					$html .= esc_html(__('No products exist yet.', 'woothemes-sensei'))."\n";
275 275
 				$html .= '</p>'."\n";
276 276
 
277 277
 			} // End If Statement
@@ -288,33 +288,33 @@  discard block
 block discarded – undo
288 288
 	 * @access public
289 289
 	 * @return void
290 290
 	 */
291
-	public function course_prerequisite_meta_box_content () {
291
+	public function course_prerequisite_meta_box_content() {
292 292
 		global $post;
293 293
 
294
-		$select_course_prerequisite = get_post_meta( $post->ID, '_course_prerequisite', true );
294
+		$select_course_prerequisite = get_post_meta($post->ID, '_course_prerequisite', true);
295 295
 
296
-		$post_args = array(	'post_type' 		=> 'course',
296
+		$post_args = array('post_type' 		=> 'course',
297 297
 							'posts_per_page' 		=> -1,
298 298
 							'orderby'         	=> 'title',
299 299
     						'order'           	=> 'DESC',
300 300
     						'exclude' 			=> $post->ID,
301 301
 							'suppress_filters' 	=> 0
302 302
 							);
303
-		$posts_array = get_posts( $post_args );
303
+		$posts_array = get_posts($post_args);
304 304
 
305 305
 		$html = '';
306 306
 
307
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
307
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
308 308
 
309
-		if ( count( $posts_array ) > 0 ) {
310
-			$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n";
311
-			$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
312
-				foreach ($posts_array as $post_item){
313
-					$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_course_prerequisite, false ) . '>' . esc_html( $post_item->post_title ) . '</option>' . "\n";
309
+		if (count($posts_array) > 0) {
310
+			$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">'."\n";
311
+			$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
312
+				foreach ($posts_array as $post_item) {
313
+					$html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_course_prerequisite, false).'>'.esc_html($post_item->post_title).'</option>'."\n";
314 314
 				} // End For Loop
315
-			$html .= '</select>' . "\n";
315
+			$html .= '</select>'."\n";
316 316
 		} else {
317
-			$html .= '<p>' . esc_html( __( 'No courses exist yet. Please add some first.', 'woothemes-sensei' ) ) . '</p>';
317
+			$html .= '<p>'.esc_html(__('No courses exist yet. Please add some first.', 'woothemes-sensei')).'</p>';
318 318
 		} // End If Statement
319 319
 
320 320
 		echo $html;
@@ -327,21 +327,21 @@  discard block
 block discarded – undo
327 327
 	 * @access public
328 328
 	 * @return void
329 329
 	 */
330
-	public function course_featured_meta_box_content () {
330
+	public function course_featured_meta_box_content() {
331 331
 		global $post;
332 332
 
333
-		$course_featured = get_post_meta( $post->ID, '_course_featured', true );
333
+		$course_featured = get_post_meta($post->ID, '_course_featured', true);
334 334
 
335 335
 		$html = '';
336 336
 
337
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
337
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'.esc_attr('woo_'.$this->token.'_noonce').'" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
338 338
 
339 339
 		$checked = '';
340
-		if ( isset( $course_featured ) && ( '' != $course_featured ) ) {
341
-	 	    $checked = checked( 'featured', $course_featured, false );
340
+		if (isset($course_featured) && ('' != $course_featured)) {
341
+	 	    $checked = checked('featured', $course_featured, false);
342 342
 	 	} // End If Statement
343 343
 
344
-	 	$html .= '<input type="checkbox" name="course_featured" value="featured" ' . $checked . '>&nbsp;' . __( 'Feature this course', 'woothemes-sensei' ) . '<br>';
344
+	 	$html .= '<input type="checkbox" name="course_featured" value="featured" '.$checked.'>&nbsp;'.__('Feature this course', 'woothemes-sensei').'<br>';
345 345
 
346 346
 		echo $html;
347 347
 
@@ -353,16 +353,16 @@  discard block
 block discarded – undo
353 353
 	 * @access public
354 354
 	 * @return void
355 355
 	 */
356
-	public function course_video_meta_box_content () {
356
+	public function course_video_meta_box_content() {
357 357
 		global $post;
358 358
 
359
-		$course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true );
359
+		$course_video_embed = get_post_meta($post->ID, '_course_video_embed', true);
360 360
 
361 361
 		$html = '';
362 362
 
363
-		$html .= '<label class="screen-reader-text" for="course_video_embed">' . __( 'Video Embed Code', 'woothemes-sensei' ) . '</label>';
364
-		$html .= '<textarea rows="5" cols="50" name="course_video_embed" tabindex="6" id="course-video-embed">' . $course_video_embed . '</textarea>';
365
-		$html .= '<p>' .  __( 'Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei' ) . '</p>';
363
+		$html .= '<label class="screen-reader-text" for="course_video_embed">'.__('Video Embed Code', 'woothemes-sensei').'</label>';
364
+		$html .= '<textarea rows="5" cols="50" name="course_video_embed" tabindex="6" id="course-video-embed">'.$course_video_embed.'</textarea>';
365
+		$html .= '<p>'.__('Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei').'</p>';
366 366
 
367 367
 		echo $html;
368 368
 
@@ -377,36 +377,36 @@  discard block
 block discarded – undo
377 377
 	 * @param int $post_id
378 378
 	 * @return int
379 379
 	 */
380
-	public function meta_box_save ( $post_id ) {
380
+	public function meta_box_save($post_id) {
381 381
 		global $post;
382 382
 
383 383
 		/* Verify the nonce before proceeding. */
384
-		if ( ( get_post_type() != $this->token ) || ! wp_verify_nonce( $_POST['woo_' . $this->token . '_noonce'], plugin_basename(__FILE__) ) ) {
384
+		if ((get_post_type() != $this->token) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_noonce'], plugin_basename(__FILE__))) {
385 385
 			return $post_id;
386 386
 		}
387 387
 
388 388
 		/* Get the post type object. */
389
-		$post_type = get_post_type_object( $post->post_type );
389
+		$post_type = get_post_type_object($post->post_type);
390 390
 
391 391
 		/* Check if the current user has permission to edit the post. */
392
-		if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) {
392
+		if ( ! current_user_can($post_type->cap->edit_post, $post_id)) {
393 393
 			return $post_id;
394 394
 		} // End If Statement
395 395
 
396
-		if ( 'page' == $_POST['post_type'] ) {
397
-			if ( ! current_user_can( 'edit_page', $post_id ) ) {
396
+		if ('page' == $_POST['post_type']) {
397
+			if ( ! current_user_can('edit_page', $post_id)) {
398 398
 				return $post_id;
399 399
 			} // End If Statement
400 400
 		} else {
401
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
401
+			if ( ! current_user_can('edit_post', $post_id)) {
402 402
 				return $post_id;
403 403
 			} // End If Statement
404 404
 		} // End If Statement
405 405
 
406 406
 		// Save the post meta data fields
407
-		if ( isset($this->meta_fields) && is_array($this->meta_fields) ) {
408
-			foreach ( $this->meta_fields as $meta_key ) {
409
-				$this->save_post_meta( $meta_key, $post_id );
407
+		if (isset($this->meta_fields) && is_array($this->meta_fields)) {
408
+			foreach ($this->meta_fields as $meta_key) {
409
+				$this->save_post_meta($meta_key, $post_id);
410 410
 			} // End For Loop
411 411
 		} // End If Statement
412 412
 
@@ -423,18 +423,18 @@  discard block
 block discarded – undo
423 423
 	 * @param int $post_id (default: 0)
424 424
 	 * @return int new meta id | bool meta value saved status
425 425
 	 */
426
-	private function save_post_meta( $post_key = '', $post_id = 0 ) {
426
+	private function save_post_meta($post_key = '', $post_id = 0) {
427 427
 		// Get the meta key.
428
-		$meta_key = '_' . $post_key;
428
+		$meta_key = '_'.$post_key;
429 429
 		// Get the posted data and sanitize it for use as an HTML class.
430
-		if ( 'course_video_embed' == $post_key) {
431
-			$new_meta_value = esc_html( $_POST[$post_key] );
430
+		if ('course_video_embed' == $post_key) {
431
+			$new_meta_value = esc_html($_POST[$post_key]);
432 432
 		} else {
433
-			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
433
+			$new_meta_value = (isset($_POST[$post_key]) ? sanitize_html_class($_POST[$post_key]) : '');
434 434
 		} // End If Statement
435 435
 
436 436
         // update field with the new value
437
-        return update_post_meta( $post_id, $meta_key, $new_meta_value );
437
+        return update_post_meta($post_id, $meta_key, $new_meta_value);
438 438
 
439 439
 	} // End save_post_meta()
440 440
 
@@ -444,31 +444,31 @@  discard block
 block discarded – undo
444 444
 	 * @access public
445 445
 	 * @return void
446 446
 	 */
447
-	public function course_lessons_meta_box_content () {
447
+	public function course_lessons_meta_box_content() {
448 448
 
449 449
 		global $post;
450 450
 
451 451
 		// Setup Lesson Query
452 452
 		$posts_array = array();
453
-		if ( 0 < $post->ID ) {
453
+		if (0 < $post->ID) {
454 454
 
455
-			$posts_array = $this->course_lessons( $post->ID, 'any' );
455
+			$posts_array = $this->course_lessons($post->ID, 'any');
456 456
 
457 457
 		} // End If Statement
458 458
 
459 459
 		$html = '';
460
-		$html .= '<input type="hidden" name="' . esc_attr( 'woo_' . $this->token . '_noonce' ) . '" id="'
461
-                 . esc_attr( 'woo_' . $this->token . '_noonce' )
462
-                 . '" value="' . esc_attr( wp_create_nonce( plugin_basename(__FILE__) ) ) . '" />';
460
+		$html .= '<input type="hidden" name="'.esc_attr('woo_'.$this->token.'_noonce').'" id="'
461
+                 . esc_attr('woo_'.$this->token.'_noonce')
462
+                 . '" value="'.esc_attr(wp_create_nonce(plugin_basename(__FILE__))).'" />';
463 463
 
464
-		if ( count( $posts_array ) > 0 ) {
464
+		if (count($posts_array) > 0) {
465 465
 
466
-			foreach ($posts_array as $post_item){
466
+			foreach ($posts_array as $post_item) {
467 467
 
468 468
 				$html .= '<p>'."\n";
469 469
 
470 470
 					$html .= $post_item->post_title."\n";
471
-					$html .= '<a href="' . esc_url( get_edit_post_link( $post_item->ID ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $post_item->post_title ) ) . '" class="edit-lesson-action">' . __( 'Edit this lesson', 'woothemes-sensei' ) . '</a>';
471
+					$html .= '<a href="'.esc_url(get_edit_post_link($post_item->ID)).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), $post_item->post_title)).'" class="edit-lesson-action">'.__('Edit this lesson', 'woothemes-sensei').'</a>';
472 472
 
473 473
 				$html .= '</p>'."\n";
474 474
 
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
 
477 477
 		} else {
478 478
 			$course_id = '';
479
-			if ( 0 < $post->ID ) { $course_id = '&course_id=' . $post->ID; }
480
-			$html .= '<p>' . esc_html( __( 'No lessons exist yet for this course.', 'woothemes-sensei' ) ) . "\n";
479
+			if (0 < $post->ID) { $course_id = '&course_id='.$post->ID; }
480
+			$html .= '<p>'.esc_html(__('No lessons exist yet for this course.', 'woothemes-sensei'))."\n";
481 481
 
482
-				$html .= '<a href="' . admin_url( 'post-new.php?post_type=lesson' . $course_id )
483
-                         . '" title="' . esc_attr( __( 'Add a Lesson', 'woothemes-sensei' ) ) . '">'
484
-                         . __( 'Please add some.', 'woothemes-sensei' ) . '</a>' . "\n";
482
+				$html .= '<a href="'.admin_url('post-new.php?post_type=lesson'.$course_id)
483
+                         . '" title="'.esc_attr(__('Add a Lesson', 'woothemes-sensei')).'">'
484
+                         . __('Please add some.', 'woothemes-sensei').'</a>'."\n";
485 485
 
486 486
 			$html .= '</p>'."\n";
487 487
 		} // End If Statement
@@ -498,12 +498,12 @@  discard block
 block discarded – undo
498 498
      * @return void
499 499
      */
500 500
 
501
-    public function course_manage_meta_box_content () {
501
+    public function course_manage_meta_box_content() {
502 502
         global $post;
503 503
         
504
-        $manage_url = esc_url( add_query_arg( array( 'page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) );
504
+        $manage_url = esc_url(add_query_arg(array('page' => 'sensei_learners', 'course_id' => $post->ID, 'view' => 'learners'), admin_url('admin.php')));
505 505
 
506
-        $grading_url = esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners' ), admin_url( 'admin.php') ) );
506
+        $grading_url = esc_url(add_query_arg(array('page' => 'sensei_grading', 'course_id' => $post->ID, 'view' => 'learners'), admin_url('admin.php')));
507 507
 
508 508
 
509 509
         echo "<ul><li><a href='$manage_url'>".__("Manage Learners", 'woothemes-sensei')."</a></li>";
@@ -521,16 +521,16 @@  discard block
 block discarded – undo
521 521
 	 * @param  array $defaults
522 522
 	 * @return array $new_columns
523 523
 	 */
524
-	public function add_column_headings ( $defaults ) {
524
+	public function add_column_headings($defaults) {
525 525
 		$new_columns['cb'] = '<input type="checkbox" />';
526 526
 		// $new_columns['id'] = __( 'ID' );
527
-		$new_columns['title'] = _x( 'Course Title', 'column name', 'woothemes-sensei' );
528
-		$new_columns['course-prerequisite'] = _x( 'Pre-requisite Course', 'column name', 'woothemes-sensei' );
529
-		if ( Sensei_WC::is_woocommerce_active() ) {
530
-			$new_columns['course-woocommerce-product'] = _x( 'WooCommerce Product', 'column name', 'woothemes-sensei' );
527
+		$new_columns['title'] = _x('Course Title', 'column name', 'woothemes-sensei');
528
+		$new_columns['course-prerequisite'] = _x('Pre-requisite Course', 'column name', 'woothemes-sensei');
529
+		if (Sensei_WC::is_woocommerce_active()) {
530
+			$new_columns['course-woocommerce-product'] = _x('WooCommerce Product', 'column name', 'woothemes-sensei');
531 531
 		} // End If Statement
532
-		$new_columns['course-category'] = _x( 'Category', 'column name', 'woothemes-sensei' );
533
-		if ( isset( $defaults['date'] ) ) {
532
+		$new_columns['course-category'] = _x('Category', 'column name', 'woothemes-sensei');
533
+		if (isset($defaults['date'])) {
534 534
 			$new_columns['date'] = $defaults['date'];
535 535
 		}
536 536
 
@@ -545,45 +545,45 @@  discard block
 block discarded – undo
545 545
 	 * @param  int $id
546 546
 	 * @return void
547 547
 	 */
548
-	public function add_column_data ( $column_name, $id ) {
548
+	public function add_column_data($column_name, $id) {
549 549
 		global $wpdb, $post;
550 550
 
551
-		switch ( $column_name ) {
551
+		switch ($column_name) {
552 552
 			case 'id':
553 553
 				echo $id;
554 554
 			break;
555 555
 
556 556
 			case 'course-prerequisite':
557
-				$course_prerequisite_id = get_post_meta( $id, '_course_prerequisite', true);
558
-				if ( 0 < absint( $course_prerequisite_id ) ) { echo '<a href="' . esc_url( get_edit_post_link( absint( $course_prerequisite_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $course_prerequisite_id ) ) ) ) . '">' . get_the_title( absint( $course_prerequisite_id ) ) . '</a>'; }
557
+				$course_prerequisite_id = get_post_meta($id, '_course_prerequisite', true);
558
+				if (0 < absint($course_prerequisite_id)) { echo '<a href="'.esc_url(get_edit_post_link(absint($course_prerequisite_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($course_prerequisite_id)))).'">'.get_the_title(absint($course_prerequisite_id)).'</a>'; }
559 559
 
560 560
 			break;
561 561
 
562 562
 			case 'course-woocommerce-product':
563
-				if ( Sensei_WC::is_woocommerce_active() ) {
564
-					$course_woocommerce_product_id = get_post_meta( $id, '_course_woocommerce_product', true);
565
-					if ( 0 < absint( $course_woocommerce_product_id ) ) {
566
-						if ( 'product_variation' == get_post_type( $course_woocommerce_product_id ) ) {
567
-							$product_object = get_product( $course_woocommerce_product_id );
568
-							if( sensei_check_woocommerce_version( '2.1' ) ) {
569
-								$formatted_variation = wc_get_formatted_variation( $product_object->variation_data, true );
563
+				if (Sensei_WC::is_woocommerce_active()) {
564
+					$course_woocommerce_product_id = get_post_meta($id, '_course_woocommerce_product', true);
565
+					if (0 < absint($course_woocommerce_product_id)) {
566
+						if ('product_variation' == get_post_type($course_woocommerce_product_id)) {
567
+							$product_object = get_product($course_woocommerce_product_id);
568
+							if (sensei_check_woocommerce_version('2.1')) {
569
+								$formatted_variation = wc_get_formatted_variation($product_object->variation_data, true);
570 570
 							} else {
571
-								$formatted_variation = woocommerce_get_formatted_variation( $product_object->variation_data, true );
571
+								$formatted_variation = woocommerce_get_formatted_variation($product_object->variation_data, true);
572 572
 							}
573 573
 							$course_woocommerce_product_id = $product_object->parent->post->ID;
574
-							$product_name = $product_object->parent->post->post_title . '<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' . ucwords( $formatted_variation );
574
+							$product_name = $product_object->parent->post->post_title.'<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'.ucwords($formatted_variation);
575 575
 						} else {
576
-							$product_name = get_the_title( absint( $course_woocommerce_product_id ) );
576
+							$product_name = get_the_title(absint($course_woocommerce_product_id));
577 577
 						} // End If Statement
578
-						echo '<a href="' . esc_url( get_edit_post_link( absint( $course_woocommerce_product_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), $product_name ) ) . '">' . $product_name . '</a>';
578
+						echo '<a href="'.esc_url(get_edit_post_link(absint($course_woocommerce_product_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), $product_name)).'">'.$product_name.'</a>';
579 579
 					} // End If Statement
580 580
 				} // End If Statement
581 581
 			break;
582 582
 
583 583
 			case 'course-category':
584
-				$output = get_the_term_list( $id, 'course-category', '', ', ', '' );
585
-				if ( '' == $output ) {
586
-					$output = __( 'None', 'woothemes-sensei' );
584
+				$output = get_the_term_list($id, 'course-category', '', ', ', '');
585
+				if ('' == $output) {
586
+					$output = __('None', 'woothemes-sensei');
587 587
 				} // End If Statement
588 588
 				echo $output;
589 589
 			break;
@@ -603,29 +603,29 @@  discard block
 block discarded – undo
603 603
 	 * @param array $includes (default: array())
604 604
 	 * @return array
605 605
 	 */
606
-	public function course_query( $amount = 0, $type = 'default', $includes = array(), $excludes = array() ) {
607
-		global $my_courses_page ;
606
+	public function course_query($amount = 0, $type = 'default', $includes = array(), $excludes = array()) {
607
+		global $my_courses_page;
608 608
 
609 609
 		$results_array = array();
610 610
 
611
-		if( $my_courses_page ) { add_action( 'pre_get_posts', array( $this, 'filter_my_courses' ) ); }
611
+		if ($my_courses_page) { add_action('pre_get_posts', array($this, 'filter_my_courses')); }
612 612
 
613
-		$post_args = $this->get_archive_query_args( $type, $amount, $includes, $excludes );
613
+		$post_args = $this->get_archive_query_args($type, $amount, $includes, $excludes);
614 614
 
615 615
 		// get the posts
616
-		if( empty( $post_args ) ) {
616
+		if (empty($post_args)) {
617 617
 
618 618
 			return $results_array;
619 619
 
620
-		}else{
620
+		} else {
621 621
 
622 622
 			//reset the pagination as this widgets do not need it
623 623
 			$post_args['paged'] = 1;
624
-			$results_array = get_posts( $post_args );
624
+			$results_array = get_posts($post_args);
625 625
 
626 626
 		}
627 627
 
628
-		if( $my_courses_page ) { remove_action( 'pre_get_posts', array( $this, 'filter_my_courses' ) ); }
628
+		if ($my_courses_page) { remove_action('pre_get_posts', array($this, 'filter_my_courses')); }
629 629
 
630 630
 		return $results_array;
631 631
 
@@ -641,22 +641,22 @@  discard block
 block discarded – undo
641 641
 	 * @param array $includes (default: array())
642 642
 	 * @return array
643 643
 	 */
644
-	public function get_archive_query_args( $type = '', $amount = 0 , $includes = array(), $excludes = array() ) {
644
+	public function get_archive_query_args($type = '', $amount = 0, $includes = array(), $excludes = array()) {
645 645
 
646 646
 		global $wp_query;
647 647
 
648
-		if ( 0 == $amount && ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && 'usercourses' != $type && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) ) {
649
-			$amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] );
648
+		if (0 == $amount && (isset(Sensei()->settings->settings['course_archive_amount']) && 'usercourses' != $type && (0 < absint(Sensei()->settings->settings['course_archive_amount'])))) {
649
+			$amount = absint(Sensei()->settings->settings['course_archive_amount']);
650 650
 		} else {
651
-			if ( 0 == $amount) {
652
-				$amount = $wp_query->get( 'posts_per_page' );
651
+			if (0 == $amount) {
652
+				$amount = $wp_query->get('posts_per_page');
653 653
 			} // End If Statement
654 654
 		} // End If Statement
655 655
 
656
-        $stored_order = get_option( 'sensei_course_order', '' );
656
+        $stored_order = get_option('sensei_course_order', '');
657 657
         $order = 'ASC';
658 658
         $orderby = 'menu_order';
659
-        if( empty( $stored_order ) ){
659
+        if (empty($stored_order)) {
660 660
 
661 661
             $order = 'DESC';
662 662
             $orderby = 'date';
@@ -666,7 +666,7 @@  discard block
 block discarded – undo
666 666
 		switch ($type) {
667 667
 
668 668
 			case 'usercourses':
669
-				$post_args = array(	'post_type' 		=> 'course',
669
+				$post_args = array('post_type' 		=> 'course',
670 670
 									'orderby'         	=> $orderby,
671 671
     								'order'           	=> $order,
672 672
     								'post_status'      	=> 'publish',
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 				break;
708 708
 
709 709
 			case 'featuredcourses':
710
-                $post_args = array(	'post_type' 		=> 'course',
710
+                $post_args = array('post_type' 		=> 'course',
711 711
                                     'orderby'         	=> $orderby,
712 712
                                     'order'           	=> $order,
713 713
     								'post_status'      	=> 'publish',
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
 									);
720 720
 				break;
721 721
 			default:
722
-				$post_args = array(	'post_type' 		=> 'course',
722
+				$post_args = array('post_type' 		=> 'course',
723 723
                                     'orderby'         	=> $orderby,
724 724
                                     'order'           	=> $order,
725 725
     								'post_status'      	=> 'publish',
@@ -731,13 +731,13 @@  discard block
 block discarded – undo
731 731
 		}
732 732
 
733 733
         $post_args['posts_per_page'] = $amount;
734
-        $paged = $wp_query->get( 'paged' );
735
-        $post_args['paged'] = empty( $paged) ? 1 : $paged;
734
+        $paged = $wp_query->get('paged');
735
+        $post_args['paged'] = empty($paged) ? 1 : $paged;
736 736
 
737
-        if( 'newcourses' == $type ){
737
+        if ('newcourses' == $type) {
738 738
 
739
-            $post_args[ 'orderby' ] = 'date';
740
-            $post_args[ 'order' ] = 'DESC';
739
+            $post_args['orderby'] = 'date';
740
+            $post_args['order'] = 'DESC';
741 741
         }
742 742
 
743 743
 		return $post_args;
@@ -759,35 +759,35 @@  discard block
 block discarded – undo
759 759
      *
760 760
 	 * @return string | void
761 761
 	 */
762
-	public function course_image( $course_id = 0, $width = '100', $height = '100', $return = false ) {
762
+	public function course_image($course_id = 0, $width = '100', $height = '100', $return = false) {
763 763
 
764
-        if( is_a( $course_id, 'WP_Post' ) ){
764
+        if (is_a($course_id, 'WP_Post')) {
765 765
             $course_id = $course_id->ID;
766 766
         }
767 767
 
768 768
 		$html = '';
769 769
 
770 770
 		// Get Width and Height settings
771
-		if ( ( $width == '100' ) && ( $height == '100' ) ) {
771
+		if (($width == '100') && ($height == '100')) {
772 772
 
773
-			if ( is_singular( 'course' ) ) {
773
+			if (is_singular('course')) {
774 774
 
775
-				if ( !Sensei()->settings->settings[ 'course_single_image_enable' ] ) {
775
+				if ( ! Sensei()->settings->settings['course_single_image_enable']) {
776 776
 					return '';
777 777
 				} // End If Statement
778 778
 				$image_thumb_size = 'course_single_image';
779
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
779
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
780 780
 				$width = $dimensions['width'];
781 781
 				$height = $dimensions['height'];
782 782
 
783 783
 			} else {
784 784
 
785
-				if ( !Sensei()->settings->settings[ 'course_archive_image_enable' ] ) {
785
+				if ( ! Sensei()->settings->settings['course_archive_image_enable']) {
786 786
 					return '';
787 787
 				} // End If Statement
788 788
 
789 789
 				$image_thumb_size = 'course_archive_image';
790
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
790
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
791 791
 				$width = $dimensions['width'];
792 792
 				$height = $dimensions['height'];
793 793
 
@@ -796,31 +796,31 @@  discard block
 block discarded – undo
796 796
 		} // End If Statement
797 797
 
798 798
 		$img_url = '';
799
-		if ( has_post_thumbnail( $course_id ) ) {
799
+		if (has_post_thumbnail($course_id)) {
800 800
    			// Get Featured Image
801
-   			$img_url = get_the_post_thumbnail( $course_id, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') );
801
+   			$img_url = get_the_post_thumbnail($course_id, array($width, $height), array('class' => 'woo-image thumbnail alignleft'));
802 802
  		} else {
803 803
 
804 804
 			// Check for a Lesson Image
805
-			$course_lessons = $this->course_lessons( $course_id );
805
+			$course_lessons = $this->course_lessons($course_id);
806 806
 
807
-			foreach ($course_lessons as $lesson_item){
808
-				if ( has_post_thumbnail( $lesson_item->ID ) ) {
807
+			foreach ($course_lessons as $lesson_item) {
808
+				if (has_post_thumbnail($lesson_item->ID)) {
809 809
 					// Get Featured Image
810
-					$img_url = get_the_post_thumbnail( $lesson_item->ID, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') );
811
-					if ( '' != $img_url ) {
810
+					$img_url = get_the_post_thumbnail($lesson_item->ID, array($width, $height), array('class' => 'woo-image thumbnail alignleft'));
811
+					if ('' != $img_url) {
812 812
 						break;
813 813
 					} // End If Statement
814 814
 
815 815
 				} // End If Statement
816 816
 			} // End For Loop
817 817
 
818
- 			if ( '' == $img_url ) {
818
+ 			if ('' == $img_url) {
819 819
 
820 820
  				// Display Image Placeholder if none
821
-				if ( Sensei()->settings->get( 'placeholder_images_enable' ) ) {
821
+				if (Sensei()->settings->get('placeholder_images_enable')) {
822 822
 
823
-                    $img_url = apply_filters( 'sensei_course_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
823
+                    $img_url = apply_filters('sensei_course_placeholder_image_url', '<img src="http://placehold.it/'.$width.'x'.$height.'" class="woo-image thumbnail alignleft" />');
824 824
 
825 825
 				} // End If Statement
826 826
 
@@ -828,17 +828,17 @@  discard block
 block discarded – undo
828 828
 
829 829
 		} // End If Statement
830 830
 
831
-		if ( '' != $img_url ) {
831
+		if ('' != $img_url) {
832 832
 
833
-			$html .= '<a href="' . get_permalink( $course_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $course_id ) ) . '">' . $img_url  .'</a>';
833
+			$html .= '<a href="'.get_permalink($course_id).'" title="'.esc_attr(get_post_field('post_title', $course_id)).'">'.$img_url.'</a>';
834 834
 
835 835
 		} // End If Statement
836 836
 
837
-        if( $return ){
837
+        if ($return) {
838 838
 
839 839
             return $html;
840 840
 
841
-        }else{
841
+        } else {
842 842
 
843 843
             echo $html;
844 844
 
@@ -855,9 +855,9 @@  discard block
 block discarded – undo
855 855
 	 * @param string $post_status (default: 'publish')
856 856
 	 * @return int
857 857
 	 */
858
-	public function course_count( $post_status = 'publish' ) {
858
+	public function course_count($post_status = 'publish') {
859 859
 
860
-		$post_args = array(	'post_type'         => 'course',
860
+		$post_args = array('post_type'         => 'course',
861 861
 							'posts_per_page'    => -1,
862 862
 //							'orderby'           => 'menu_order date',
863 863
 //							'order'             => 'ASC',
@@ -868,10 +868,10 @@  discard block
 block discarded – undo
868 868
 
869 869
 		// Allow WP to generate the complex final query, just shortcut to only do an overall count
870 870
 //		add_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
871
-		$courses_query = new WP_Query( apply_filters( 'sensei_course_count', $post_args ) );
871
+		$courses_query = new WP_Query(apply_filters('sensei_course_count', $post_args));
872 872
 //		remove_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
873 873
 
874
-		return count( $courses_query->posts );
874
+		return count($courses_query->posts);
875 875
 	} // End course_count()
876 876
 
877 877
 
@@ -884,42 +884,42 @@  discard block
 block discarded – undo
884 884
 	 * @param string $fields (default: 'all'). WP only allows 3 types, but we will limit it to only 'ids' or 'all'
885 885
 	 * @return array{ type WP_Post }  $posts_array
886 886
 	 */
887
-	public function course_lessons( $course_id = 0, $post_status = 'publish', $fields = 'all' ) {
887
+	public function course_lessons($course_id = 0, $post_status = 'publish', $fields = 'all') {
888 888
 
889
-        if( is_a( $course_id, 'WP_Post' ) ){
889
+        if (is_a($course_id, 'WP_Post')) {
890 890
             $course_id = $course_id->ID;
891 891
         }
892 892
 
893
-		$post_args = array(	'post_type'         => 'lesson',
893
+		$post_args = array('post_type'         => 'lesson',
894 894
 							'posts_per_page'       => -1,
895 895
 							'orderby'           => 'date',
896 896
 							'order'             => 'ASC',
897 897
 							'meta_query'        => array(
898 898
 								array(
899 899
 									'key' => '_lesson_course',
900
-									'value' => intval( $course_id ),
900
+									'value' => intval($course_id),
901 901
 								),
902 902
 							),
903 903
 							'post_status'       => $post_status,
904 904
 							'suppress_filters'  => 0,
905 905
 							);
906
-		$query_results = new WP_Query( $post_args );
906
+		$query_results = new WP_Query($post_args);
907 907
         $lessons = $query_results->posts;
908 908
 
909 909
         // re order the lessons. This could not be done via the OR meta query as there may be lessons
910 910
         // with the course order for a different course and this should not be included. It could also not
911 911
         // be done via the AND meta query as it excludes lesson that does not have the _order_$course_id but
912 912
         // that have been added to the course.
913
-        if( count( $lessons) > 1  ){
913
+        if (count($lessons) > 1) {
914 914
 
915
-            foreach( $lessons as $lesson ){
915
+            foreach ($lessons as $lesson) {
916 916
 
917
-                $order = intval( get_post_meta( $lesson->ID, '_order_'. $course_id, true ) );
917
+                $order = intval(get_post_meta($lesson->ID, '_order_'.$course_id, true));
918 918
                 // for lessons with no order set it to be 10000 so that it show up at the end
919 919
                 $lesson->course_order = $order ? $order : 100000;
920 920
             }
921 921
 
922
-            uasort( $lessons, array( $this, '_short_course_lessons_callback' )   );
922
+            uasort($lessons, array($this, '_short_course_lessons_callback'));
923 923
         }
924 924
 
925 925
         /**
@@ -930,12 +930,12 @@  discard block
 block discarded – undo
930 930
          * @param array $lessons
931 931
          * @param int $course_id
932 932
          */
933
-        $lessons = apply_filters( 'sensei_course_get_lessons', $lessons, $course_id  );
933
+        $lessons = apply_filters('sensei_course_get_lessons', $lessons, $course_id);
934 934
 
935 935
         //return the requested fields
936 936
         // runs after the sensei_course_get_lessons filter so the filter always give an array of lesson
937 937
         // objects
938
-        if( 'ids' == $fields ) {
938
+        if ('ids' == $fields) {
939 939
             $lesson_objects = $lessons;
940 940
             $lessons = array();
941 941
 
@@ -957,9 +957,9 @@  discard block
 block discarded – undo
957 957
      * @param array $lesson_2
958 958
      * @return int
959 959
      */
960
-    protected function _short_course_lessons_callback( $lesson_1, $lesson_2 ){
960
+    protected function _short_course_lessons_callback($lesson_1, $lesson_2) {
961 961
 
962
-        if ( $lesson_1->course_order == $lesson_2->course_order ) {
962
+        if ($lesson_1->course_order == $lesson_2->course_order) {
963 963
             return 0;
964 964
         }
965 965
 
@@ -973,21 +973,21 @@  discard block
 block discarded – undo
973 973
 	 * @param  boolean $boolean_check True if a simple yes/no is required
974 974
 	 * @return array              Array of quiz post objects
975 975
 	 */
976
-	public function course_quizzes( $course_id = 0, $boolean_check = false ) {
976
+	public function course_quizzes($course_id = 0, $boolean_check = false) {
977 977
 
978 978
 
979 979
 		$course_quizzes = array();
980 980
 
981
-		if( $course_id ) {
982
-			$lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' );
981
+		if ($course_id) {
982
+			$lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids');
983 983
 
984
-			foreach( $lesson_ids as $lesson_id ) {
985
-				$has_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
986
-				if ( $has_questions && $boolean_check ) {
984
+			foreach ($lesson_ids as $lesson_id) {
985
+				$has_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
986
+				if ($has_questions && $boolean_check) {
987 987
 					return true;
988 988
 				}
989
-				elseif ( $has_questions ) {
990
-					$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
989
+				elseif ($has_questions) {
990
+					$quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
991 991
 //					$questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
992 992
 //					if( count( $questions ) > 0 ) {
993 993
 						$course_quizzes[] = $quiz_id;
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 				}
996 996
 			}
997 997
 		}
998
-		if ( $boolean_check && empty($course_quizzes) ) {
998
+		if ($boolean_check && empty($course_quizzes)) {
999 999
 			$course_quizzes = false;
1000 1000
 		}
1001 1001
 		return $course_quizzes;
@@ -1010,9 +1010,9 @@  discard block
 block discarded – undo
1010 1010
 	 * @param  string $post_status (default: 'publish')
1011 1011
 	 * @return array
1012 1012
 	 */
1013
-	public function course_lessons_completed( $course_id = 0, $post_status = 'publish' ) {
1013
+	public function course_lessons_completed($course_id = 0, $post_status = 'publish') {
1014 1014
 
1015
-		return $this->course_lessons( $course_id, $post_status );
1015
+		return $this->course_lessons($course_id, $post_status);
1016 1016
 
1017 1017
 	} // End course_lessons_completed()
1018 1018
 
@@ -1025,9 +1025,9 @@  discard block
 block discarded – undo
1025 1025
 	 * @param  int $course_id (default: 0)
1026 1026
 	 * @return int
1027 1027
 	 */
1028
-	public function course_author_lesson_count( $author_id = 0, $course_id = 0 ) {
1028
+	public function course_author_lesson_count($author_id = 0, $course_id = 0) {
1029 1029
 
1030
-        $lesson_args = array(	'post_type' 		=> 'lesson',
1030
+        $lesson_args = array('post_type' 		=> 'lesson',
1031 1031
 								'posts_per_page' 		=> -1,
1032 1032
 		    					'author'         	=> $author_id,
1033 1033
 		    					'meta_key'        	=> '_lesson_course',
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
     	    					'suppress_filters' 	=> 0,
1037 1037
 								'fields'            => 'ids', // less data to retrieve
1038 1038
 		    				);
1039
-		$lessons_array = get_posts( $lesson_args );
1040
-		$count = count( $lessons_array );
1039
+		$lessons_array = get_posts($lesson_args);
1040
+		$count = count($lessons_array);
1041 1041
 		return $count;
1042 1042
 
1043 1043
 	} // End course_author_lesson_count()
@@ -1049,9 +1049,9 @@  discard block
 block discarded – undo
1049 1049
 	 * @param  int $course_id (default: 0)
1050 1050
 	 * @return int
1051 1051
 	 */
1052
-	public function course_lesson_count( $course_id = 0 ) {
1052
+	public function course_lesson_count($course_id = 0) {
1053 1053
 
1054
-		$lesson_args = array(	'post_type' 		=> 'lesson',
1054
+		$lesson_args = array('post_type' 		=> 'lesson',
1055 1055
 								'posts_per_page' 		=> -1,
1056 1056
 		    					'meta_key'        	=> '_lesson_course',
1057 1057
     							'meta_value'      	=> $course_id,
@@ -1059,9 +1059,9 @@  discard block
 block discarded – undo
1059 1059
     	    					'suppress_filters' 	=> 0,
1060 1060
 								'fields'            => 'ids', // less data to retrieve
1061 1061
 		    				);
1062
-		$lessons_array = get_posts( $lesson_args );
1062
+		$lessons_array = get_posts($lesson_args);
1063 1063
 
1064
-        $count = count( $lessons_array );
1064
+        $count = count($lessons_array);
1065 1065
 
1066 1066
         return $count;
1067 1067
 
@@ -1074,9 +1074,9 @@  discard block
 block discarded – undo
1074 1074
 	 * @param  int $course_id (default: 0)
1075 1075
 	 * @return int
1076 1076
 	 */
1077
-	public function course_lesson_preview_count( $course_id = 0 ) {
1077
+	public function course_lesson_preview_count($course_id = 0) {
1078 1078
 
1079
-		$lesson_args = array(	'post_type' 		=> 'lesson',
1079
+		$lesson_args = array('post_type' 		=> 'lesson',
1080 1080
 								'posts_per_page' 		=> -1,
1081 1081
     	    					'post_status'      	=> 'publish',
1082 1082
     	    					'suppress_filters' 	=> 0,
@@ -1092,9 +1092,9 @@  discard block
 block discarded – undo
1092 1092
 								),
1093 1093
 								'fields'            => 'ids', // less data to retrieve
1094 1094
 		    				);
1095
-		$lessons_array = get_posts( $lesson_args );
1095
+		$lessons_array = get_posts($lesson_args);
1096 1096
 
1097
-		$count = count( $lessons_array );
1097
+		$count = count($lessons_array);
1098 1098
 
1099 1099
         return $count;
1100 1100
 
@@ -1107,12 +1107,12 @@  discard block
 block discarded – undo
1107 1107
 	 * @param  int $product_id (default: 0)
1108 1108
 	 * @return array
1109 1109
 	 */
1110
-	public function get_product_courses( $product_id = 0 ) {
1110
+	public function get_product_courses($product_id = 0) {
1111 1111
 
1112 1112
 		$posts_array = array();
1113 1113
 		// Check for WooCommerce
1114
-		if ( Sensei_WC::is_woocommerce_active() && 0 < $product_id ) {
1115
-			$post_args = array(	'post_type' 		=> 'course',
1114
+		if (Sensei_WC::is_woocommerce_active() && 0 < $product_id) {
1115
+			$post_args = array('post_type' 		=> 'course',
1116 1116
 								'posts_per_page' 		=> -1,
1117 1117
 								'meta_key'        	=> '_course_woocommerce_product',
1118 1118
 	    						'meta_value'      	=> $product_id,
@@ -1121,7 +1121,7 @@  discard block
 block discarded – undo
1121 1121
 								'orderby' 			=> 'menu_order date',
1122 1122
 								'order' 			=> 'ASC',
1123 1123
 								);
1124
-			$posts_array = get_posts( $post_args );
1124
+			$posts_array = get_posts($post_args);
1125 1125
 		} // End If Statement
1126 1126
 		return $posts_array;
1127 1127
 
@@ -1141,17 +1141,17 @@  discard block
 block discarded – undo
1141 1141
 	 * @param  WP_Query $query
1142 1142
 	 * @return void
1143 1143
 	 */
1144
-	public function filter_my_courses( $query ) {
1144
+	public function filter_my_courses($query) {
1145 1145
 		global  $my_courses_section;
1146 1146
 
1147
-		if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) {
1148
-			$amount = absint( Sensei()->settings->settings[ 'my_course_amount' ] );
1149
-			$query->set( 'posts_per_page', $amount );
1147
+		if (isset(Sensei()->settings->settings['my_course_amount']) && (0 < absint(Sensei()->settings->settings['my_course_amount']))) {
1148
+			$amount = absint(Sensei()->settings->settings['my_course_amount']);
1149
+			$query->set('posts_per_page', $amount);
1150 1150
 		}
1151 1151
 
1152
-		if( isset( $_GET[ $my_courses_section . '_page' ] ) && 0 < intval( $_GET[ $my_courses_section . '_page' ] ) ) {
1153
-			$page = intval( $_GET[ $my_courses_section . '_page' ] );
1154
-			$query->set( 'paged', $page );
1152
+		if (isset($_GET[$my_courses_section.'_page']) && 0 < intval($_GET[$my_courses_section.'_page'])) {
1153
+			$page = intval($_GET[$my_courses_section.'_page']);
1154
+			$query->set('paged', $page);
1155 1155
 		}
1156 1156
 	}
1157 1157
 
@@ -1165,48 +1165,48 @@  discard block
 block discarded – undo
1165 1165
 	 * @param  boolean $manage Whether the user has permission to manage the courses
1166 1166
 	 * @return string          HTML displayng course data
1167 1167
 	 */
1168
-	public function load_user_courses_content( $user = false ) {
1168
+	public function load_user_courses_content($user = false) {
1169 1169
 		global $course, $my_courses_page, $my_courses_section;
1170 1170
 
1171
-        if( ! isset( Sensei()->settings->settings[ 'learner_profile_show_courses' ] )
1172
-            || ! Sensei()->settings->settings[ 'learner_profile_show_courses' ] ) {
1171
+        if ( ! isset(Sensei()->settings->settings['learner_profile_show_courses'])
1172
+            || ! Sensei()->settings->settings['learner_profile_show_courses']) {
1173 1173
 
1174 1174
             // do not show the content if the settings doesn't allow for it
1175 1175
             return;
1176 1176
 
1177 1177
         }
1178 1178
 
1179
-        $manage = ( $user->ID == get_current_user_id() ) ? true : false;
1179
+        $manage = ($user->ID == get_current_user_id()) ? true : false;
1180 1180
 
1181
-        do_action( 'sensei_before_learner_course_content', $user );
1181
+        do_action('sensei_before_learner_course_content', $user);
1182 1182
 
1183 1183
 		// Build Output HTML
1184 1184
 		$complete_html = $active_html = '';
1185 1185
 
1186
-		if( is_a( $user, 'WP_User' ) ) {
1186
+		if (is_a($user, 'WP_User')) {
1187 1187
 
1188 1188
 			$my_courses_page = true;
1189 1189
 
1190 1190
 			// Allow action to be run before My Courses content has loaded
1191
-			do_action( 'sensei_before_my_courses', $user->ID );
1191
+			do_action('sensei_before_my_courses', $user->ID);
1192 1192
 
1193 1193
 			// Logic for Active and Completed Courses
1194 1194
 			$per_page = 20;
1195
-			if ( isset( Sensei()->settings->settings[ 'my_course_amount' ] )
1196
-                && ( 0 < absint( Sensei()->settings->settings[ 'my_course_amount' ] ) ) ) {
1195
+			if (isset(Sensei()->settings->settings['my_course_amount'])
1196
+                && (0 < absint(Sensei()->settings->settings['my_course_amount']))) {
1197 1197
 
1198
-				$per_page = absint( Sensei()->settings->settings[ 'my_course_amount' ] );
1198
+				$per_page = absint(Sensei()->settings->settings['my_course_amount']);
1199 1199
 
1200 1200
 			}
1201 1201
 
1202
-			$course_statuses = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user->ID, 'type' => 'sensei_course_status' ), true );
1202
+			$course_statuses = Sensei_Utils::sensei_check_for_activity(array('user_id' => $user->ID, 'type' => 'sensei_course_status'), true);
1203 1203
 			// User may only be on 1 Course
1204
-			if ( !is_array($course_statuses) ) {
1205
-				$course_statuses = array( $course_statuses );
1204
+			if ( ! is_array($course_statuses)) {
1205
+				$course_statuses = array($course_statuses);
1206 1206
 			}
1207 1207
 			$completed_ids = $active_ids = array();
1208
-			foreach( $course_statuses as $course_status ) {
1209
-				if ( Sensei_Utils::user_completed_course( $course_status, $user->ID ) ) {
1208
+			foreach ($course_statuses as $course_status) {
1209
+				if (Sensei_Utils::user_completed_course($course_status, $user->ID)) {
1210 1210
 					$completed_ids[] = $course_status->comment_post_ID;
1211 1211
 				} else {
1212 1212
 					$active_ids[] = $course_status->comment_post_ID;
@@ -1216,41 +1216,41 @@  discard block
 block discarded – undo
1216 1216
 			$active_count = $completed_count = 0;
1217 1217
 
1218 1218
 			$active_courses = array();
1219
-			if ( 0 < intval( count( $active_ids ) ) ) {
1219
+			if (0 < intval(count($active_ids))) {
1220 1220
 				$my_courses_section = 'active';
1221
-				$active_courses = Sensei()->course->course_query( $per_page, 'usercourses', $active_ids );
1222
-				$active_count = count( $active_ids );
1221
+				$active_courses = Sensei()->course->course_query($per_page, 'usercourses', $active_ids);
1222
+				$active_count = count($active_ids);
1223 1223
 			} // End If Statement
1224 1224
 
1225 1225
 			$completed_courses = array();
1226
-			if ( 0 < intval( count( $completed_ids ) ) ) {
1226
+			if (0 < intval(count($completed_ids))) {
1227 1227
 				$my_courses_section = 'completed';
1228
-				$completed_courses = Sensei()->course->course_query( $per_page, 'usercourses', $completed_ids );
1229
-				$completed_count = count( $completed_ids );
1228
+				$completed_courses = Sensei()->course->course_query($per_page, 'usercourses', $completed_ids);
1229
+				$completed_count = count($completed_ids);
1230 1230
 			} // End If Statement
1231 1231
 
1232
-			foreach ( $active_courses as $course_item ) {
1232
+			foreach ($active_courses as $course_item) {
1233 1233
 
1234
-				$course_lessons =  Sensei()->course->course_lessons( $course_item->ID );
1234
+				$course_lessons = Sensei()->course->course_lessons($course_item->ID);
1235 1235
 				$lessons_completed = 0;
1236
-				foreach ( $course_lessons as $lesson ) {
1237
-					if ( Sensei_Utils::user_completed_lesson( $lesson->ID, $user->ID ) ) {
1236
+				foreach ($course_lessons as $lesson) {
1237
+					if (Sensei_Utils::user_completed_lesson($lesson->ID, $user->ID)) {
1238 1238
 						++$lessons_completed;
1239 1239
 					}
1240 1240
 				}
1241 1241
 
1242 1242
 			    // Get Course Categories
1243
-			    $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );
1243
+			    $category_output = get_the_term_list($course_item->ID, 'course-category', '', ', ', '');
1244 1244
 
1245
-                $active_html .= '<article class="' . esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) ) . '">';
1245
+                $active_html .= '<article class="'.esc_attr(join(' ', get_post_class(array('course', 'post'), $course_item->ID))).'">';
1246 1246
 
1247 1247
                 // Image
1248
-                $active_html .= Sensei()->course->course_image( absint( $course_item->ID ), '100','100', true );
1248
+                $active_html .= Sensei()->course->course_image(absint($course_item->ID), '100', '100', true);
1249 1249
 
1250 1250
                 // Title
1251 1251
                 $active_html .= '<header>';
1252 1252
 
1253
-                $active_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>';
1253
+                $active_html .= '<h2><a href="'.esc_url(get_permalink(absint($course_item->ID))).'" title="'.esc_attr($course_item->post_title).'">'.esc_html($course_item->post_title).'</a></h2>';
1254 1254
 
1255 1255
                 $active_html .= '</header>';
1256 1256
 
@@ -1259,82 +1259,82 @@  discard block
 block discarded – undo
1259 1259
                 $active_html .= '<p class="sensei-course-meta">';
1260 1260
 
1261 1261
                 // Author
1262
-                $user_info = get_userdata( absint( $course_item->post_author ) );
1263
-                if ( isset( Sensei()->settings->settings[ 'course_author' ] )
1264
-                    && ( Sensei()->settings->settings[ 'course_author' ] ) ) {
1262
+                $user_info = get_userdata(absint($course_item->post_author));
1263
+                if (isset(Sensei()->settings->settings['course_author'])
1264
+                    && (Sensei()->settings->settings['course_author'])) {
1265 1265
 
1266 1266
                     $active_html .= '<span class="course-author">'
1267
-                        . __( 'by ', 'woothemes-sensei' )
1268
-                        . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) )
1269
-                        . '" title="' . esc_attr( $user_info->display_name ) . '">'
1270
-                        . esc_html( $user_info->display_name )
1267
+                        . __('by ', 'woothemes-sensei')
1268
+                        . '<a href="'.esc_url(get_author_posts_url(absint($course_item->post_author)))
1269
+                        . '" title="'.esc_attr($user_info->display_name).'">'
1270
+                        . esc_html($user_info->display_name)
1271 1271
                         . '</a></span>';
1272 1272
 
1273 1273
                 } // End If Statement
1274 1274
 
1275 1275
                 // Lesson count for this author
1276
-                $lesson_count = Sensei()->course->course_lesson_count( absint( $course_item->ID ) );
1276
+                $lesson_count = Sensei()->course->course_lesson_count(absint($course_item->ID));
1277 1277
                 // Handle Division by Zero
1278
-                if ( 0 == $lesson_count ) {
1278
+                if (0 == $lesson_count) {
1279 1279
 
1280 1280
                     $lesson_count = 1;
1281 1281
 
1282 1282
                 } // End If Statement
1283
-                $active_html .= '<span class="course-lesson-count">' . $lesson_count . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ) . '</span>';
1283
+                $active_html .= '<span class="course-lesson-count">'.$lesson_count.'&nbsp;'.__('Lessons', 'woothemes-sensei').'</span>';
1284 1284
                 // Course Categories
1285
-                if ( '' != $category_output ) {
1285
+                if ('' != $category_output) {
1286 1286
 
1287
-                    $active_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>';
1287
+                    $active_html .= '<span class="course-category">'.sprintf(__('in %s', 'woothemes-sensei'), $category_output).'</span>';
1288 1288
 
1289 1289
                 } // End If Statement
1290
-                $active_html .= '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $lessons_completed, $lesson_count  ) . '</span>';
1290
+                $active_html .= '<span class="course-lesson-progress">'.sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $lessons_completed, $lesson_count).'</span>';
1291 1291
 
1292 1292
                 $active_html .= '</p>';
1293 1293
 
1294
-                $active_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>';
1294
+                $active_html .= '<p class="course-excerpt">'.$course_item->post_excerpt.'</p>';
1295 1295
 
1296 1296
 
1297 1297
 
1298
-                $progress_percentage = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $lesson_count ), 0 ) );
1298
+                $progress_percentage = abs(round((doubleval($lessons_completed) * 100) / ($lesson_count), 0));
1299 1299
 
1300
-                $active_html .= $this->get_progress_meter( $progress_percentage );
1300
+                $active_html .= $this->get_progress_meter($progress_percentage);
1301 1301
 
1302 1302
                 $active_html .= '</section>';
1303 1303
 
1304
-                if( is_user_logged_in() ) {
1304
+                if (is_user_logged_in()) {
1305 1305
 
1306 1306
                     $active_html .= '<section class="entry-actions">';
1307 1307
 
1308
-                    $active_html .= '<form method="POST" action="' . esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ) . '">';
1308
+                    $active_html .= '<form method="POST" action="'.esc_url(remove_query_arg(array('active_page', 'completed_page'))).'">';
1309 1309
 
1310
-                    $active_html .= '<input type="hidden" name="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" id="' . esc_attr( 'woothemes_sensei_complete_course_noonce' ) . '" value="' . esc_attr( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ) . '" />';
1310
+                    $active_html .= '<input type="hidden" name="'.esc_attr('woothemes_sensei_complete_course_noonce').'" id="'.esc_attr('woothemes_sensei_complete_course_noonce').'" value="'.esc_attr(wp_create_nonce('woothemes_sensei_complete_course_noonce')).'" />';
1311 1311
 
1312
-                    $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="' . esc_attr( absint( $course_item->ID ) ) . '" />';
1312
+                    $active_html .= '<input type="hidden" name="course_complete_id" id="course-complete-id" value="'.esc_attr(absint($course_item->ID)).'" />';
1313 1313
 
1314
-                    if ( 0 < absint( count( $course_lessons ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) {
1314
+                    if (0 < absint(count($course_lessons)) && Sensei()->settings->settings['course_completion'] == 'complete') {
1315 1315
 
1316 1316
                         $active_html .= '<span><input name="course_complete" type="submit" class="course-complete" value="'
1317
-                            .  __( 'Mark as Complete', 'woothemes-sensei' ) . '"/> </span>';
1317
+                            .  __('Mark as Complete', 'woothemes-sensei').'"/> </span>';
1318 1318
 
1319 1319
                     } // End If Statement
1320 1320
 
1321 1321
                     $course_purchased = false;
1322
-                    if ( Sensei_WC::is_woocommerce_active() ) {
1322
+                    if (Sensei_WC::is_woocommerce_active()) {
1323 1323
 
1324 1324
                         // Get the product ID
1325
-                        $wc_post_id = get_post_meta( absint( $course_item->ID ), '_course_woocommerce_product', true );
1326
-                        if ( 0 < $wc_post_id ) {
1325
+                        $wc_post_id = get_post_meta(absint($course_item->ID), '_course_woocommerce_product', true);
1326
+                        if (0 < $wc_post_id) {
1327 1327
 
1328
-                            $course_purchased = Sensei_WC::has_customer_bought_product(  $user->ID, $wc_post_id );
1328
+                            $course_purchased = Sensei_WC::has_customer_bought_product($user->ID, $wc_post_id);
1329 1329
 
1330 1330
                         } // End If Statement
1331 1331
 
1332 1332
                     } // End If Statement
1333 1333
 
1334
-                    if ( false == $course_purchased ) {
1334
+                    if (false == $course_purchased) {
1335 1335
 
1336 1336
                         $active_html .= '<span><input name="course_complete" type="submit" class="course-delete" value="'
1337
-                            .  __( 'Delete Course', 'woothemes-sensei' ) . '"/></span>';
1337
+                            .  __('Delete Course', 'woothemes-sensei').'"/></span>';
1338 1338
 
1339 1339
                     } // End If Statement
1340 1340
 
@@ -1347,54 +1347,54 @@  discard block
 block discarded – undo
1347 1347
 			}
1348 1348
 
1349 1349
 			// Active pagination
1350
-			if( $active_count > $per_page ) {
1350
+			if ($active_count > $per_page) {
1351 1351
 
1352 1352
 				$current_page = 1;
1353
-				if( isset( $_GET['active_page'] ) && 0 < intval( $_GET['active_page'] ) ) {
1353
+				if (isset($_GET['active_page']) && 0 < intval($_GET['active_page'])) {
1354 1354
 					$current_page = $_GET['active_page'];
1355 1355
 				}
1356 1356
 
1357 1357
 				$active_html .= '<nav class="pagination woo-pagination">';
1358
-				$total_pages = ceil( $active_count / $per_page );
1358
+				$total_pages = ceil($active_count / $per_page);
1359 1359
 
1360
-				if( $current_page > 1 ) {
1361
-					$prev_link = add_query_arg( 'active_page', $current_page - 1 );
1362
-					$active_html .= '<a class="prev page-numbers" href="' . esc_url( $prev_link ) . '">' . __( 'Previous' , 'woothemes-sensei' ) . '</a> ';
1360
+				if ($current_page > 1) {
1361
+					$prev_link = add_query_arg('active_page', $current_page - 1);
1362
+					$active_html .= '<a class="prev page-numbers" href="'.esc_url($prev_link).'">'.__('Previous', 'woothemes-sensei').'</a> ';
1363 1363
 				}
1364 1364
 
1365
-				for ( $i = 1; $i <= $total_pages; $i++ ) {
1366
-					$link = add_query_arg( 'active_page', $i );
1365
+				for ($i = 1; $i <= $total_pages; $i++) {
1366
+					$link = add_query_arg('active_page', $i);
1367 1367
 
1368
-					if( $i == $current_page ) {
1369
-						$active_html .= '<span class="page-numbers current">' . $i . '</span> ';
1368
+					if ($i == $current_page) {
1369
+						$active_html .= '<span class="page-numbers current">'.$i.'</span> ';
1370 1370
 					} else {
1371
-						$active_html .= '<a class="page-numbers" href="' . esc_url( $link ). '">' . $i . '</a> ';
1371
+						$active_html .= '<a class="page-numbers" href="'.esc_url($link).'">'.$i.'</a> ';
1372 1372
 					}
1373 1373
 				}
1374 1374
 
1375
-				if( $current_page < $total_pages ) {
1376
-					$next_link = add_query_arg( 'active_page', $current_page + 1 );
1377
-					$active_html .= '<a class="next page-numbers" href="' . esc_url( $next_link ) . '">' . __( 'Next' , 'woothemes-sensei' ) . '</a> ';
1375
+				if ($current_page < $total_pages) {
1376
+					$next_link = add_query_arg('active_page', $current_page + 1);
1377
+					$active_html .= '<a class="next page-numbers" href="'.esc_url($next_link).'">'.__('Next', 'woothemes-sensei').'</a> ';
1378 1378
 				}
1379 1379
 
1380 1380
 				$active_html .= '</nav>';
1381 1381
 			}
1382 1382
 
1383
-			foreach ( $completed_courses as $course_item ) {
1383
+			foreach ($completed_courses as $course_item) {
1384 1384
 				$course = $course_item;
1385 1385
 
1386 1386
 			    // Get Course Categories
1387
-			    $category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );
1387
+			    $category_output = get_the_term_list($course_item->ID, 'course-category', '', ', ', '');
1388 1388
 
1389
-		    	$complete_html .= '<article class="' . join( ' ', get_post_class( array( 'course', 'post' ), $course_item->ID ) ) . '">';
1389
+		    	$complete_html .= '<article class="'.join(' ', get_post_class(array('course', 'post'), $course_item->ID)).'">';
1390 1390
 
1391 1391
 		    	    // Image
1392
-		    		$complete_html .= Sensei()->course->course_image( absint( $course_item->ID ),100, 100, true );
1392
+		    		$complete_html .= Sensei()->course->course_image(absint($course_item->ID), 100, 100, true);
1393 1393
 
1394 1394
 		    		// Title
1395 1395
 		    		$complete_html .= '<header>';
1396 1396
 
1397
-		    		    $complete_html .= '<h2><a href="' . esc_url( get_permalink( absint( $course_item->ID ) ) ) . '" title="' . esc_attr( $course_item->post_title ) . '">' . esc_html( $course_item->post_title ) . '</a></h2>';
1397
+		    		    $complete_html .= '<h2><a href="'.esc_url(get_permalink(absint($course_item->ID))).'" title="'.esc_attr($course_item->post_title).'">'.esc_html($course_item->post_title).'</a></h2>';
1398 1398
 
1399 1399
 		    		$complete_html .= '</header>';
1400 1400
 
@@ -1403,46 +1403,46 @@  discard block
 block discarded – undo
1403 1403
 		    			$complete_html .= '<p class="sensei-course-meta">';
1404 1404
 
1405 1405
 		    		    	// Author
1406
-		    		    	$user_info = get_userdata( absint( $course_item->post_author ) );
1407
-		    		    	if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {
1408
-		    		    		$complete_html .= '<span class="course-author">' . __( 'by ', 'woothemes-sensei' ) . '<a href="' . esc_url( get_author_posts_url( absint( $course_item->post_author ) ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
1406
+		    		    	$user_info = get_userdata(absint($course_item->post_author));
1407
+		    		    	if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) {
1408
+		    		    		$complete_html .= '<span class="course-author">'.__('by ', 'woothemes-sensei').'<a href="'.esc_url(get_author_posts_url(absint($course_item->post_author))).'" title="'.esc_attr($user_info->display_name).'">'.esc_html($user_info->display_name).'</a></span>';
1409 1409
 		    		    	} // End If Statement
1410 1410
 
1411 1411
 		    		    	// Lesson count for this author
1412 1412
 		    		    	$complete_html .= '<span class="course-lesson-count">'
1413
-                                . Sensei()->course->course_lesson_count( absint( $course_item->ID ) )
1414
-                                . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' )
1413
+                                . Sensei()->course->course_lesson_count(absint($course_item->ID))
1414
+                                . '&nbsp;'.__('Lessons', 'woothemes-sensei')
1415 1415
                                 . '</span>';
1416 1416
 
1417 1417
 		    		    	// Course Categories
1418
-		    		    	if ( '' != $category_output ) {
1418
+		    		    	if ('' != $category_output) {
1419 1419
 
1420
-		    		    		$complete_html .= '<span class="course-category">' . sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ) . '</span>';
1420
+		    		    		$complete_html .= '<span class="course-category">'.sprintf(__('in %s', 'woothemes-sensei'), $category_output).'</span>';
1421 1421
 
1422 1422
 		    		    	} // End If Statement
1423 1423
 
1424 1424
 						$complete_html .= '</p>';
1425 1425
 
1426
-						$complete_html .= '<p class="course-excerpt">' . $course_item->post_excerpt . '</p>';
1426
+						$complete_html .= '<p class="course-excerpt">'.$course_item->post_excerpt.'</p>';
1427 1427
 
1428
-                        $complete_html .= $this->get_progress_meter( 100 );
1428
+                        $complete_html .= $this->get_progress_meter(100);
1429 1429
 
1430
-						if( $manage ) {
1431
-							$has_quizzes = Sensei()->course->course_quizzes( $course_item->ID, true );
1430
+						if ($manage) {
1431
+							$has_quizzes = Sensei()->course->course_quizzes($course_item->ID, true);
1432 1432
 							// Output only if there is content to display
1433
-							if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) {
1433
+							if (has_filter('sensei_results_links') || $has_quizzes) {
1434 1434
 
1435 1435
 
1436 1436
 								$complete_html .= '<p class="sensei-results-links">';
1437 1437
 								$results_link = '';
1438
-								if( $has_quizzes ) {
1438
+								if ($has_quizzes) {
1439 1439
 
1440 1440
 									$results_link = '<a class="button view-results" href="'
1441
-                                        . Sensei()->course_results->get_permalink( $course_item->ID )
1442
-                                        . '">' . __( 'View results', 'woothemes-sensei' )
1441
+                                        . Sensei()->course_results->get_permalink($course_item->ID)
1442
+                                        . '">'.__('View results', 'woothemes-sensei')
1443 1443
                                         . '</a>';
1444 1444
 								}
1445
-								$complete_html .= apply_filters( 'sensei_results_links', $results_link );
1445
+								$complete_html .= apply_filters('sensei_results_links', $results_link);
1446 1446
 								$complete_html .= '</p>';
1447 1447
 
1448 1448
 							}
@@ -1454,35 +1454,35 @@  discard block
 block discarded – undo
1454 1454
 			}
1455 1455
 
1456 1456
 			// Active pagination
1457
-			if( $completed_count > $per_page ) {
1457
+			if ($completed_count > $per_page) {
1458 1458
 
1459 1459
 				$current_page = 1;
1460
-				if( isset( $_GET['completed_page'] ) && 0 < intval( $_GET['completed_page'] ) ) {
1460
+				if (isset($_GET['completed_page']) && 0 < intval($_GET['completed_page'])) {
1461 1461
 					$current_page = $_GET['completed_page'];
1462 1462
 				}
1463 1463
 
1464 1464
 				$complete_html .= '<nav class="pagination woo-pagination">';
1465
-				$total_pages = ceil( $completed_count / $per_page );
1465
+				$total_pages = ceil($completed_count / $per_page);
1466 1466
 
1467 1467
 
1468
-				if( $current_page > 1 ) {
1469
-					$prev_link = add_query_arg( 'completed_page', $current_page - 1 );
1470
-					$complete_html .= '<a class="prev page-numbers" href="' . esc_url( $prev_link ) . '">' . __( 'Previous' , 'woothemes-sensei' ) . '</a> ';
1468
+				if ($current_page > 1) {
1469
+					$prev_link = add_query_arg('completed_page', $current_page - 1);
1470
+					$complete_html .= '<a class="prev page-numbers" href="'.esc_url($prev_link).'">'.__('Previous', 'woothemes-sensei').'</a> ';
1471 1471
 				}
1472 1472
 
1473
-				for ( $i = 1; $i <= $total_pages; $i++ ) {
1474
-					$link = add_query_arg( 'completed_page', $i );
1473
+				for ($i = 1; $i <= $total_pages; $i++) {
1474
+					$link = add_query_arg('completed_page', $i);
1475 1475
 
1476
-					if( $i == $current_page ) {
1477
-						$complete_html .= '<span class="page-numbers current">' . $i . '</span> ';
1476
+					if ($i == $current_page) {
1477
+						$complete_html .= '<span class="page-numbers current">'.$i.'</span> ';
1478 1478
 					} else {
1479
-						$complete_html .= '<a class="page-numbers" href="' . esc_url( $link ) . '">' . $i . '</a> ';
1479
+						$complete_html .= '<a class="page-numbers" href="'.esc_url($link).'">'.$i.'</a> ';
1480 1480
 					}
1481 1481
 				}
1482 1482
 
1483
-				if( $current_page < $total_pages ) {
1484
-					$next_link = add_query_arg( 'completed_page', $current_page + 1 );
1485
-					$complete_html .= '<a class="next page-numbers" href="' . esc_url( $next_link ) . '">' . __( 'Next' , 'woothemes-sensei' ) . '</a> ';
1483
+				if ($current_page < $total_pages) {
1484
+					$next_link = add_query_arg('completed_page', $current_page + 1);
1485
+					$complete_html .= '<a class="next page-numbers" href="'.esc_url($next_link).'">'.__('Next', 'woothemes-sensei').'</a> ';
1486 1486
 				}
1487 1487
 
1488 1488
 				$complete_html .= '</nav>';
@@ -1490,26 +1490,26 @@  discard block
 block discarded – undo
1490 1490
 
1491 1491
 		} // End If Statement
1492 1492
 
1493
-		if( $manage ) {
1494
-			$no_active_message = __( 'You have no active courses.', 'woothemes-sensei' );
1495
-			$no_complete_message = __( 'You have not completed any courses yet.', 'woothemes-sensei' );
1493
+		if ($manage) {
1494
+			$no_active_message = __('You have no active courses.', 'woothemes-sensei');
1495
+			$no_complete_message = __('You have not completed any courses yet.', 'woothemes-sensei');
1496 1496
 		} else {
1497
-			$no_active_message =  __( 'This learner has no active courses.', 'woothemes-sensei' );
1498
-			$no_complete_message =  __( 'This learner has not completed any courses yet.', 'woothemes-sensei' );
1497
+			$no_active_message = __('This learner has no active courses.', 'woothemes-sensei');
1498
+			$no_complete_message = __('This learner has not completed any courses yet.', 'woothemes-sensei');
1499 1499
 		}
1500 1500
 
1501 1501
 		ob_start();
1502 1502
 		?>
1503 1503
 
1504
-		<?php do_action( 'sensei_before_user_courses' ); ?>
1504
+		<?php do_action('sensei_before_user_courses'); ?>
1505 1505
 
1506 1506
 		<?php
1507
-		if( $manage && ( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) ) {
1507
+		if ($manage && ( ! isset(Sensei()->settings->settings['messages_disable']) || ! Sensei()->settings->settings['messages_disable'])) {
1508 1508
 			?>
1509 1509
 			<p class="my-messages-link-container">
1510
-                <a class="my-messages-link" href="<?php echo get_post_type_archive_link( 'sensei_message' ); ?>"
1511
-                   title="<?php _e( 'View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei' ); ?>">
1512
-                    <?php _e( 'My Messages', 'woothemes-sensei' ); ?>
1510
+                <a class="my-messages-link" href="<?php echo get_post_type_archive_link('sensei_message'); ?>"
1511
+                   title="<?php _e('View & reply to private messages sent to your course & lesson teachers.', 'woothemes-sensei'); ?>">
1512
+                    <?php _e('My Messages', 'woothemes-sensei'); ?>
1513 1513
                 </a>
1514 1514
             </p>
1515 1515
 			<?php
@@ -1518,11 +1518,11 @@  discard block
 block discarded – undo
1518 1518
 		<div id="my-courses">
1519 1519
 
1520 1520
 		    <ul>
1521
-		    	<li><a href="#active-courses"><?php  _e( 'Active Courses', 'woothemes-sensei' ); ?></a></li>
1522
-		    	<li><a href="#completed-courses"><?php  _e( 'Completed Courses', 'woothemes-sensei' ); ?></a></li>
1521
+		    	<li><a href="#active-courses"><?php  _e('Active Courses', 'woothemes-sensei'); ?></a></li>
1522
+		    	<li><a href="#completed-courses"><?php  _e('Completed Courses', 'woothemes-sensei'); ?></a></li>
1523 1523
 		    </ul>
1524 1524
 
1525
-		    <?php do_action( 'sensei_before_active_user_courses' ); ?>
1525
+		    <?php do_action('sensei_before_active_user_courses'); ?>
1526 1526
 
1527 1527
 		    <?php
1528 1528
             $course_page_url = Sensei_Course::get_courses_page_url();
@@ -1530,7 +1530,7 @@  discard block
 block discarded – undo
1530 1530
 
1531 1531
 		    <div id="active-courses">
1532 1532
 
1533
-		    	<?php if ( '' != $active_html ) {
1533
+		    	<?php if ('' != $active_html) {
1534 1534
 
1535 1535
 		    		echo $active_html;
1536 1536
 
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
 
1543 1543
                         <a href="<?php echo $course_page_url; ?>">
1544 1544
 
1545
-                            <?php  _e( 'Start a Course!', 'woothemes-sensei' ); ?>
1545
+                            <?php  _e('Start a Course!', 'woothemes-sensei'); ?>
1546 1546
 
1547 1547
                         </a>
1548 1548
 
@@ -1552,13 +1552,13 @@  discard block
 block discarded – undo
1552 1552
 
1553 1553
 		    </div>
1554 1554
 
1555
-		    <?php do_action( 'sensei_after_active_user_courses' ); ?>
1555
+		    <?php do_action('sensei_after_active_user_courses'); ?>
1556 1556
 
1557
-		    <?php do_action( 'sensei_before_completed_user_courses' ); ?>
1557
+		    <?php do_action('sensei_before_completed_user_courses'); ?>
1558 1558
 
1559 1559
 		    <div id="completed-courses">
1560 1560
 
1561
-		    	<?php if ( '' != $complete_html ) {
1561
+		    	<?php if ('' != $complete_html) {
1562 1562
 
1563 1563
 		    		echo $complete_html;
1564 1564
 
@@ -1574,16 +1574,16 @@  discard block
 block discarded – undo
1574 1574
 
1575 1575
 		    </div>
1576 1576
 
1577
-		    <?php do_action( 'sensei_after_completed_user_courses' ); ?>
1577
+		    <?php do_action('sensei_after_completed_user_courses'); ?>
1578 1578
 
1579 1579
 		</div>
1580 1580
 
1581
-		<?php do_action( 'sensei_after_user_courses' ); ?>
1581
+		<?php do_action('sensei_after_user_courses'); ?>
1582 1582
 
1583 1583
 		<?php
1584 1584
         echo ob_get_clean();
1585 1585
 
1586
-        do_action( 'sensei_after_learner_course_content', $user );
1586
+        do_action('sensei_after_learner_course_content', $user);
1587 1587
 
1588 1588
 	} // end load_user_courses_content
1589 1589
 
@@ -1595,7 +1595,7 @@  discard block
 block discarded – undo
1595 1595
      *  @type $course WP_Post
1596 1596
      * }
1597 1597
      */
1598
-    public static function get_all_courses(){
1598
+    public static function get_all_courses() {
1599 1599
 
1600 1600
         $args = array(
1601 1601
                'post_type' => 'course',
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
                 'suppress_filters' 	=> 0,
1607 1607
         );
1608 1608
 
1609
-        $wp_query_obj =  new WP_Query( $args );
1609
+        $wp_query_obj = new WP_Query($args);
1610 1610
 
1611 1611
         /**
1612 1612
          * sensei_get_all_courses filter
@@ -1618,7 +1618,7 @@  discard block
 block discarded – undo
1618 1618
          * }
1619 1619
          * @param array $attributes
1620 1620
          */
1621
-        return apply_filters( 'sensei_get_all_courses' , $wp_query_obj->posts );
1621
+        return apply_filters('sensei_get_all_courses', $wp_query_obj->posts);
1622 1622
 
1623 1623
     }// end get_all_courses
1624 1624
 
@@ -1629,16 +1629,16 @@  discard block
 block discarded – undo
1629 1629
      * @param int $progress_percentage 0 - 100
1630 1630
      * @return string $progress_bar_html
1631 1631
      */
1632
-    public function get_progress_meter( $progress_percentage ){
1632
+    public function get_progress_meter($progress_percentage) {
1633 1633
 
1634
-        if ( 50 < $progress_percentage ) {
1634
+        if (50 < $progress_percentage) {
1635 1635
             $class = ' green';
1636
-        } elseif ( 25 <= $progress_percentage && 50 >= $progress_percentage ) {
1636
+        } elseif (25 <= $progress_percentage && 50 >= $progress_percentage) {
1637 1637
             $class = ' orange';
1638 1638
         } else {
1639 1639
             $class = ' red';
1640 1640
         }
1641
-        $progress_bar_html = '<div class="meter' . esc_attr( $class ) . '"><span style="width: ' . $progress_percentage . '%">' . round( $progress_percentage ) . '%</span></div>';
1641
+        $progress_bar_html = '<div class="meter'.esc_attr($class).'"><span style="width: '.$progress_percentage.'%">'.round($progress_percentage).'%</span></div>';
1642 1642
 
1643 1643
         return $progress_bar_html;
1644 1644
 
@@ -1653,17 +1653,17 @@  discard block
 block discarded – undo
1653 1653
      *
1654 1654
      * @return string $statement_html
1655 1655
      */
1656
-    public function get_progress_statement( $course_id, $user_id ){
1656
+    public function get_progress_statement($course_id, $user_id) {
1657 1657
 
1658
-        if( empty( $course_id ) || empty( $user_id )
1659
-        || ! Sensei_Utils::user_started_course( $course_id, $user_id ) ){
1658
+        if (empty($course_id) || empty($user_id)
1659
+        || ! Sensei_Utils::user_started_course($course_id, $user_id)) {
1660 1660
             return '';
1661 1661
         }
1662 1662
 
1663
-        $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) );
1664
-        $total_lessons = count( $this->course_lessons( $course_id ) );
1663
+        $completed = count($this->get_completed_lesson_ids($course_id, $user_id));
1664
+        $total_lessons = count($this->course_lessons($course_id));
1665 1665
 
1666
-        $statement = sprintf( _n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons );
1666
+        $statement = sprintf(_n('Currently completed %s lesson of %s in total', 'Currently completed %s lessons of %s in total', $completed, 'woothemes-sensei'), $completed, $total_lessons);
1667 1667
 
1668 1668
         /**
1669 1669
          * Filter the course completion statement.
@@ -1671,7 +1671,7 @@  discard block
 block discarded – undo
1671 1671
          *
1672 1672
          * @param string $statement
1673 1673
          */
1674
-        return apply_filters( 'sensei_course_completion_statement', $statement );
1674
+        return apply_filters('sensei_course_completion_statement', $statement);
1675 1675
 
1676 1676
     }// end generate_progress_statement
1677 1677
 
@@ -1681,17 +1681,17 @@  discard block
 block discarded – undo
1681 1681
      * @param $course_id
1682 1682
      * @return void
1683 1683
      */
1684
-    public function the_progress_statement( $course_id = 0, $user_id = 0 ){
1685
-        if( empty( $course_id ) ){
1684
+    public function the_progress_statement($course_id = 0, $user_id = 0) {
1685
+        if (empty($course_id)) {
1686 1686
             global $post;
1687 1687
             $course_id = $post->ID;
1688 1688
         }
1689 1689
 
1690
-        if( empty( $user_id ) ){
1690
+        if (empty($user_id)) {
1691 1691
             $user_id = get_current_user_id();
1692 1692
         }
1693 1693
 
1694
-        echo '<span class="progress statement  course-completion-rate">' . $this->get_progress_statement( $course_id, $user_id  ) . '</span>';
1694
+        echo '<span class="progress statement  course-completion-rate">'.$this->get_progress_statement($course_id, $user_id).'</span>';
1695 1695
     }
1696 1696
 
1697 1697
     /**
@@ -1700,24 +1700,24 @@  discard block
 block discarded – undo
1700 1700
      * @param $course_id
1701 1701
      * @return void
1702 1702
      */
1703
-    public function the_progress_meter( $course_id = 0, $user_id = 0 ){
1703
+    public function the_progress_meter($course_id = 0, $user_id = 0) {
1704 1704
 
1705
-        if( empty( $course_id ) ){
1705
+        if (empty($course_id)) {
1706 1706
             global $post;
1707 1707
             $course_id = $post->ID;
1708 1708
         }
1709 1709
 
1710
-        if( empty( $user_id ) ){
1710
+        if (empty($user_id)) {
1711 1711
             $user_id = get_current_user_id();
1712 1712
         }
1713 1713
 
1714
-        if( 'course' != get_post_type( $course_id ) || ! get_userdata( $user_id )
1715
-            || ! Sensei_Utils::user_started_course( $course_id ,$user_id ) ){
1714
+        if ('course' != get_post_type($course_id) || ! get_userdata($user_id)
1715
+            || ! Sensei_Utils::user_started_course($course_id, $user_id)) {
1716 1716
             return;
1717 1717
         }
1718
-        $percentage_completed = $this->get_completion_percentage( $course_id, $user_id );
1718
+        $percentage_completed = $this->get_completion_percentage($course_id, $user_id);
1719 1719
 
1720
-        echo $this->get_progress_meter( $percentage_completed );
1720
+        echo $this->get_progress_meter($percentage_completed);
1721 1721
 
1722 1722
     }// end the_progress_meter
1723 1723
 
@@ -1730,20 +1730,20 @@  discard block
 block discarded – undo
1730 1730
      * @param int $user_id
1731 1731
      * @return array $completed_lesson_ids
1732 1732
      */
1733
-    public function get_completed_lesson_ids( $course_id, $user_id = 0 ){
1733
+    public function get_completed_lesson_ids($course_id, $user_id = 0) {
1734 1734
 
1735
-        if( !( intval( $user_id ) ) > 0 ){
1735
+        if ( ! (intval($user_id)) > 0) {
1736 1736
             $user_id = get_current_user_id();
1737 1737
         }
1738 1738
 
1739 1739
         $completed_lesson_ids = array();
1740 1740
 
1741
-        $course_lessons = $this->course_lessons( $course_id );
1741
+        $course_lessons = $this->course_lessons($course_id);
1742 1742
 
1743
-        foreach( $course_lessons as $lesson ){
1743
+        foreach ($course_lessons as $lesson) {
1744 1744
 
1745
-            $is_lesson_completed = Sensei_Utils::user_completed_lesson( $lesson->ID, $user_id );
1746
-            if( $is_lesson_completed ){
1745
+            $is_lesson_completed = Sensei_Utils::user_completed_lesson($lesson->ID, $user_id);
1746
+            if ($is_lesson_completed) {
1747 1747
                 $completed_lesson_ids[] = $lesson->ID;
1748 1748
             }
1749 1749
 
@@ -1762,19 +1762,19 @@  discard block
 block discarded – undo
1762 1762
      * @param int $user_id
1763 1763
      * @return int $percentage
1764 1764
      */
1765
-    public function get_completion_percentage( $course_id, $user_id = 0 ){
1765
+    public function get_completion_percentage($course_id, $user_id = 0) {
1766 1766
 
1767
-        if( !( intval( $user_id ) ) > 0 ){
1767
+        if ( ! (intval($user_id)) > 0) {
1768 1768
             $user_id = get_current_user_id();
1769 1769
         }
1770 1770
 
1771
-        $completed = count( $this->get_completed_lesson_ids( $course_id, $user_id ) );
1771
+        $completed = count($this->get_completed_lesson_ids($course_id, $user_id));
1772 1772
 
1773
-        if( ! (  $completed  > 0 ) ){
1773
+        if ( ! ($completed > 0)) {
1774 1774
             return 0;
1775 1775
         }
1776 1776
 
1777
-        $total_lessons = count( $this->course_lessons( $course_id ) );
1777
+        $total_lessons = count($this->course_lessons($course_id));
1778 1778
         $percentage = $completed / $total_lessons * 100;
1779 1779
 
1780 1780
         /**
@@ -1786,7 +1786,7 @@  discard block
 block discarded – undo
1786 1786
          * @param $user_id
1787 1787
          * @since 1.8.0
1788 1788
          */
1789
-        return apply_filters( 'sensei_course_completion_percentage', $percentage, $course_id, $user_id );
1789
+        return apply_filters('sensei_course_completion_percentage', $percentage, $course_id, $user_id);
1790 1790
 
1791 1791
     }// end get_completed_lesson_ids
1792 1792
 
@@ -1798,28 +1798,28 @@  discard block
 block discarded – undo
1798 1798
      * @param $should_send
1799 1799
      * @return bool
1800 1800
      */
1801
-    public function block_notification_emails( $should_send ){
1801
+    public function block_notification_emails($should_send) {
1802 1802
         global $sensei_email_data;
1803 1803
         $email = $sensei_email_data;
1804 1804
 
1805 1805
         $course_id = '';
1806 1806
 
1807
-        if( isset( $email['course_id'] ) ){
1807
+        if (isset($email['course_id'])) {
1808 1808
 
1809 1809
             $course_id = $email['course_id'];
1810 1810
 
1811
-        }elseif( isset( $email['lesson_id'] ) ){
1811
+        }elseif (isset($email['lesson_id'])) {
1812 1812
 
1813
-            $course_id = Sensei()->lesson->get_course_id( $email['lesson_id'] );
1813
+            $course_id = Sensei()->lesson->get_course_id($email['lesson_id']);
1814 1814
 
1815
-        }elseif( isset( $email['quiz_id'] ) ){
1815
+        }elseif (isset($email['quiz_id'])) {
1816 1816
 
1817
-            $lesson_id = Sensei()->quiz->get_lesson_id( $email['quiz_id'] );
1818
-            $course_id = Sensei()->lesson->get_course_id( $lesson_id );
1817
+            $lesson_id = Sensei()->quiz->get_lesson_id($email['quiz_id']);
1818
+            $course_id = Sensei()->lesson->get_course_id($lesson_id);
1819 1819
 
1820 1820
         }
1821 1821
 
1822
-        if( !empty( $course_id ) && 'course'== get_post_type( $course_id ) ) {
1822
+        if ( ! empty($course_id) && 'course' == get_post_type($course_id)) {
1823 1823
 
1824 1824
             $course_emails_disabled = get_post_meta($course_id, 'disable_notification', true);
1825 1825
 
@@ -1840,19 +1840,19 @@  discard block
 block discarded – undo
1840 1840
      * @since 1.8.0
1841 1841
      * @param $course
1842 1842
      */
1843
-    public function course_notification_meta_box_content( $course ){
1843
+    public function course_notification_meta_box_content($course) {
1844 1844
 
1845
-        $checked = get_post_meta( $course->ID , 'disable_notification', true );
1845
+        $checked = get_post_meta($course->ID, 'disable_notification', true);
1846 1846
 
1847 1847
         // generate checked html
1848 1848
         $checked_html = '';
1849
-        if( $checked ){
1849
+        if ($checked) {
1850 1850
             $checked_html = 'checked="checked"';
1851 1851
         }
1852
-        wp_nonce_field( 'update-course-notification-setting','_sensei_course_notification' );
1852
+        wp_nonce_field('update-course-notification-setting', '_sensei_course_notification');
1853 1853
 
1854
-        echo '<input id="disable_sensei_course_notification" '.$checked_html .' type="checkbox" name="disable_sensei_course_notification" >';
1855
-        echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei'). '</label>';
1854
+        echo '<input id="disable_sensei_course_notification" '.$checked_html.' type="checkbox" name="disable_sensei_course_notification" >';
1855
+        echo '<label for="disable_sensei_course_notification">'.__('Disable notifications on this course ?', 'woothemes-sensei').'</label>';
1856 1856
 
1857 1857
     }// end course_notification_meta_box_content
1858 1858
 
@@ -1864,20 +1864,20 @@  discard block
 block discarded – undo
1864 1864
      *
1865 1865
      * @param $course_id
1866 1866
      */
1867
-    public function save_course_notification_meta_box( $course_id ){
1867
+    public function save_course_notification_meta_box($course_id) {
1868 1868
 
1869
-        if( !isset( $_POST['_sensei_course_notification']  )
1870
-            || ! wp_verify_nonce( $_POST['_sensei_course_notification'], 'update-course-notification-setting' ) ){
1869
+        if ( ! isset($_POST['_sensei_course_notification'])
1870
+            || ! wp_verify_nonce($_POST['_sensei_course_notification'], 'update-course-notification-setting')) {
1871 1871
             return;
1872 1872
         }
1873 1873
 
1874
-        if( isset( $_POST['disable_sensei_course_notification'] ) && 'on'== $_POST['disable_sensei_course_notification']  ) {
1874
+        if (isset($_POST['disable_sensei_course_notification']) && 'on' == $_POST['disable_sensei_course_notification']) {
1875 1875
             $new_val = true;
1876
-        }else{
1876
+        } else {
1877 1877
             $new_val = false;
1878 1878
         }
1879 1879
 
1880
-       update_post_meta( $course_id , 'disable_notification', $new_val );
1880
+       update_post_meta($course_id, 'disable_notification', $new_val);
1881 1881
 
1882 1882
     }// end save notification meta box
1883 1883
 
@@ -1891,10 +1891,10 @@  discard block
 block discarded – undo
1891 1891
      *
1892 1892
      * @param WP_Post $post
1893 1893
      */
1894
-    public function content_before_backwards_compatibility_hooks( $post ){
1894
+    public function content_before_backwards_compatibility_hooks($post) {
1895 1895
 
1896
-        sensei_do_deprecated_action( 'sensei_course_image','1.9.0','sensei_course_content_inside_before' );
1897
-        sensei_do_deprecated_action( 'sensei_course_archive_course_title','1.9.0','sensei_course_content_inside_before' );
1896
+        sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_course_content_inside_before');
1897
+        sensei_do_deprecated_action('sensei_course_archive_course_title', '1.9.0', 'sensei_course_content_inside_before');
1898 1898
 
1899 1899
     }
1900 1900
 
@@ -1907,10 +1907,10 @@  discard block
 block discarded – undo
1907 1907
      *
1908 1908
      * @global WP_Post $post
1909 1909
      */
1910
-    public  function loop_before_backwards_compatibility_hooks( ){
1910
+    public  function loop_before_backwards_compatibility_hooks( ) {
1911 1911
 
1912 1912
         global $post;
1913
-        sensei_do_deprecated_action( 'sensei_course_archive_header','1.9.0','sensei_course_content_inside_before', $post->post_type  );
1913
+        sensei_do_deprecated_action('sensei_course_archive_header', '1.9.0', 'sensei_course_content_inside_before', $post->post_type);
1914 1914
 
1915 1915
     }
1916 1916
 
@@ -1923,19 +1923,19 @@  discard block
 block discarded – undo
1923 1923
      *
1924 1924
      * @param integer $course_id
1925 1925
      */
1926
-    public function the_course_free_lesson_preview( $course_id ){
1926
+    public function the_course_free_lesson_preview($course_id) {
1927 1927
         // Meta data
1928
-        $course = get_post( $course_id );
1929
-        $preview_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $course->ID ) );
1930
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course->ID, get_current_user_id() );
1928
+        $course = get_post($course_id);
1929
+        $preview_lesson_count = intval(Sensei()->course->course_lesson_preview_count($course->ID));
1930
+        $is_user_taking_course = Sensei_Utils::user_started_course($course->ID, get_current_user_id());
1931 1931
 
1932
-        if ( 0 < $preview_lesson_count && !$is_user_taking_course ) {
1932
+        if (0 < $preview_lesson_count && ! $is_user_taking_course) {
1933 1933
             ?>
1934 1934
             <p class="sensei-free-lessons">
1935 1935
                 <a href="<?php echo get_permalink(); ?>">
1936
-                    <?php _e( 'Preview this course', 'woothemes-sensei' ) ?>
1936
+                    <?php _e('Preview this course', 'woothemes-sensei') ?>
1937 1937
                 </a>
1938
-                - <?php echo sprintf( __( '(%d preview lessons)', 'woothemes-sensei' ), $preview_lesson_count ) ; ?>
1938
+                - <?php echo sprintf(__('(%d preview lessons)', 'woothemes-sensei'), $preview_lesson_count); ?>
1939 1939
             </p>
1940 1940
 
1941 1941
         <?php
@@ -1948,42 +1948,42 @@  discard block
 block discarded – undo
1948 1948
      * @since 1.9.0
1949 1949
      * @param integer $course_id
1950 1950
      */
1951
-    public function the_course_meta( $course_id ){
1951
+    public function the_course_meta($course_id) {
1952 1952
         echo '<p class="sensei-course-meta">';
1953 1953
 
1954
-        $course = get_post( $course_id );
1955
-        $category_output = get_the_term_list( $course->ID, 'course-category', '', ', ', '' );
1956
-        $author_display_name = get_the_author_meta( 'display_name', $course->post_author  );
1954
+        $course = get_post($course_id);
1955
+        $category_output = get_the_term_list($course->ID, 'course-category', '', ', ', '');
1956
+        $author_display_name = get_the_author_meta('display_name', $course->post_author);
1957 1957
 
1958
-        if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) {?>
1958
+        if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) {?>
1959 1959
 
1960
-            <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?>
1960
+            <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?>
1961 1961
 
1962
-                <a href="<?php esc_attr_e( get_author_posts_url( $course->post_author ) ); ?>" title="<?php esc_attr_e( $author_display_name ); ?>"><?php esc_attr_e( $author_display_name   ); ?></a>
1962
+                <a href="<?php esc_attr_e(get_author_posts_url($course->post_author)); ?>" title="<?php esc_attr_e($author_display_name); ?>"><?php esc_attr_e($author_display_name); ?></a>
1963 1963
 
1964 1964
             </span>
1965 1965
 
1966 1966
         <?php } // End If Statement ?>
1967 1967
 
1968
-        <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $course->ID ) . '&nbsp;' .  __( 'Lessons', 'woothemes-sensei' ); ?></span>
1968
+        <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($course->ID).'&nbsp;'.__('Lessons', 'woothemes-sensei'); ?></span>
1969 1969
 
1970
-       <?php if ( '' != $category_output ) { ?>
1970
+       <?php if ('' != $category_output) { ?>
1971 1971
 
1972
-            <span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span>
1972
+            <span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span>
1973 1973
 
1974 1974
         <?php } // End If Statement
1975 1975
 
1976 1976
         // number of completed lessons
1977
-        if( Sensei_Utils::user_started_course( $course->ID,  get_current_user_id() )
1978
-            || Sensei_Utils::user_completed_course( $course->ID,  get_current_user_id() )  ){
1977
+        if (Sensei_Utils::user_started_course($course->ID, get_current_user_id())
1978
+            || Sensei_Utils::user_completed_course($course->ID, get_current_user_id())) {
1979 1979
 
1980
-            $completed = count( $this->get_completed_lesson_ids( $course->ID, get_current_user_id() ) );
1981
-            $lesson_count = count( $this->course_lessons( $course->ID ) );
1982
-            echo '<span class="course-lesson-progress">' . sprintf( __( '%1$d of %2$d lessons completed', 'woothemes-sensei' ) , $completed, $lesson_count  ) . '</span>';
1980
+            $completed = count($this->get_completed_lesson_ids($course->ID, get_current_user_id()));
1981
+            $lesson_count = count($this->course_lessons($course->ID));
1982
+            echo '<span class="course-lesson-progress">'.sprintf(__('%1$d of %2$d lessons completed', 'woothemes-sensei'), $completed, $lesson_count).'</span>';
1983 1983
 
1984 1984
         }
1985 1985
 
1986
-        sensei_simple_course_price( $course->ID );
1986
+        sensei_simple_course_price($course->ID);
1987 1987
 
1988 1988
         echo '</p>';
1989 1989
     } // end the course meta
@@ -1998,15 +1998,15 @@  discard block
 block discarded – undo
1998 1998
      *
1999 1999
      * @return array $classes
2000 2000
      */
2001
-    public static function add_course_user_status_class( $classes, $class, $course_id ){
2001
+    public static function add_course_user_status_class($classes, $class, $course_id) {
2002 2002
 
2003
-        if( 'course' == get_post_type( $course_id )  &&  is_user_logged_in() ){
2003
+        if ('course' == get_post_type($course_id) && is_user_logged_in()) {
2004 2004
 
2005
-            if( Sensei_Utils::user_completed_course( $course_id, get_current_user_id() ) ){
2005
+            if (Sensei_Utils::user_completed_course($course_id, get_current_user_id())) {
2006 2006
 
2007 2007
                 $classes[] = 'user-status-completed';
2008 2008
 
2009
-            }else{
2009
+            } else {
2010 2010
 
2011 2011
                 $classes[] = 'user-status-active';
2012 2012
 
@@ -2026,56 +2026,56 @@  discard block
 block discarded – undo
2026 2026
      *
2027 2027
      * @param WP_Post $course
2028 2028
      */
2029
-    public static function the_course_action_buttons( $course ){
2029
+    public static function the_course_action_buttons($course) {
2030 2030
 
2031
-        if( is_user_logged_in() ) { ?>
2031
+        if (is_user_logged_in()) { ?>
2032 2032
 
2033 2033
             <section class="entry-actions">
2034
-                <form method="POST" action="<?php  echo esc_url( remove_query_arg( array( 'active_page', 'completed_page' ) ) ); ?>">
2034
+                <form method="POST" action="<?php  echo esc_url(remove_query_arg(array('active_page', 'completed_page'))); ?>">
2035 2035
 
2036 2036
                     <input type="hidden"
2037
-                           name="<?php esc_attr_e( 'woothemes_sensei_complete_course_noonce' ) ?>"
2038
-                           id="<?php  esc_attr_e( 'woothemes_sensei_complete_course_noonce' ); ?>"
2039
-                           value="<?php esc_attr_e( wp_create_nonce( 'woothemes_sensei_complete_course_noonce' ) ); ?>"
2037
+                           name="<?php esc_attr_e('woothemes_sensei_complete_course_noonce') ?>"
2038
+                           id="<?php  esc_attr_e('woothemes_sensei_complete_course_noonce'); ?>"
2039
+                           value="<?php esc_attr_e(wp_create_nonce('woothemes_sensei_complete_course_noonce')); ?>"
2040 2040
                         />
2041 2041
 
2042
-                    <input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php esc_attr_e( intval( $course->ID ) ); ?>" />
2042
+                    <input type="hidden" name="course_complete_id" id="course-complete-id" value="<?php esc_attr_e(intval($course->ID)); ?>" />
2043 2043
 
2044
-                    <?php if ( 0 < absint( count( Sensei()->course->course_lessons( $course->ID ) ) ) && Sensei()->settings->settings['course_completion'] == 'complete' ) { ?>
2044
+                    <?php if (0 < absint(count(Sensei()->course->course_lessons($course->ID))) && Sensei()->settings->settings['course_completion'] == 'complete') { ?>
2045 2045
 
2046
-                        <span><input name="course_complete" type="submit" class="course-complete" value="<?php  _e( 'Mark as Complete', 'woothemes-sensei' ); ?>" /></span>
2046
+                        <span><input name="course_complete" type="submit" class="course-complete" value="<?php  _e('Mark as Complete', 'woothemes-sensei'); ?>" /></span>
2047 2047
 
2048 2048
                    <?php  } // End If Statement
2049 2049
 
2050 2050
                     $course_purchased = false;
2051
-                    if ( Sensei_WC::is_woocommerce_active() ) {
2051
+                    if (Sensei_WC::is_woocommerce_active()) {
2052 2052
                         // Get the product ID
2053
-                        $wc_post_id = get_post_meta( intval( $course->ID ), '_course_woocommerce_product', true );
2054
-                        if ( 0 < $wc_post_id ) {
2053
+                        $wc_post_id = get_post_meta(intval($course->ID), '_course_woocommerce_product', true);
2054
+                        if (0 < $wc_post_id) {
2055 2055
 
2056 2056
                             $user = wp_get_current_user();
2057
-                            $course_purchased = Sensei_Utils::sensei_customer_bought_product( $user->user_email, $user->ID, $wc_post_id );
2057
+                            $course_purchased = Sensei_Utils::sensei_customer_bought_product($user->user_email, $user->ID, $wc_post_id);
2058 2058
 
2059 2059
                         } // End If Statement
2060 2060
                     } // End If Statement
2061 2061
 
2062
-                    if ( ! $course_purchased && ! Sensei_Utils::user_completed_course( $course->ID, get_current_user_id() ) ) {?>
2062
+                    if ( ! $course_purchased && ! Sensei_Utils::user_completed_course($course->ID, get_current_user_id())) {?>
2063 2063
 
2064
-                        <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __( 'Delete Course', 'woothemes-sensei' ); ?>"/></span>
2064
+                        <span><input name="course_complete" type="submit" class="course-delete" value="<?php echo __('Delete Course', 'woothemes-sensei'); ?>"/></span>
2065 2065
 
2066 2066
                     <?php } // End If Statement
2067 2067
 
2068
-                    $has_quizzes = Sensei()->course->course_quizzes( $course->ID, true );
2068
+                    $has_quizzes = Sensei()->course->course_quizzes($course->ID, true);
2069 2069
                     $results_link = '';
2070
-                    if( $has_quizzes ){
2071
-                        $results_link = '<a class="button view-results" href="' . Sensei()->course_results->get_permalink( $course->ID ) . '">' . __( 'View results', 'woothemes-sensei' ) . '</a>';
2070
+                    if ($has_quizzes) {
2071
+                        $results_link = '<a class="button view-results" href="'.Sensei()->course_results->get_permalink($course->ID).'">'.__('View results', 'woothemes-sensei').'</a>';
2072 2072
                     }
2073 2073
 
2074 2074
                     // Output only if there is content to display
2075
-                    if ( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?>
2075
+                    if (has_filter('sensei_results_links') || $has_quizzes) { ?>
2076 2076
 
2077 2077
                         <p class="sensei-results-links">
2078
-                            <?php echo apply_filters( 'sensei_results_links', $results_link ); ?>
2078
+                            <?php echo apply_filters('sensei_results_links', $results_link); ?>
2079 2079
                         </p>
2080 2080
 
2081 2081
                     <?php } // end if has filter  ?>
@@ -2100,17 +2100,17 @@  discard block
 block discarded – undo
2100 2100
      * @param WP_Query $query
2101 2101
      * @return WP_Query $query
2102 2102
      */
2103
-    public static function course_query_filter( $query ){
2103
+    public static function course_query_filter($query) {
2104 2104
 
2105 2105
         // exit early for no course queries and admin queries
2106
-        if( is_admin( ) || 'course' != $query->get( 'post_type' ) ){
2106
+        if (is_admin( ) || 'course' != $query->get('post_type')) {
2107 2107
             return $query;
2108 2108
         }
2109 2109
 
2110 2110
         global $post; // used to get the current page id for my courses
2111 2111
 
2112 2112
         // for the course archive page
2113
-        if( $query->is_main_query() && is_post_type_archive('course') )
2113
+        if ($query->is_main_query() && is_post_type_archive('course'))
2114 2114
         {
2115 2115
             /**
2116 2116
              * sensei_archive_courses_per_page
@@ -2121,11 +2121,11 @@  discard block
 block discarded – undo
2121 2121
              * @since 1.9.0
2122 2122
              * @param integer $posts_per_page default 10
2123 2123
              */
2124
-            $query->set( 'posts_per_page', apply_filters( 'sensei_archive_courses_per_page', 10 ) );
2124
+            $query->set('posts_per_page', apply_filters('sensei_archive_courses_per_page', 10));
2125 2125
 
2126 2126
         }
2127 2127
         // for the my courses page
2128
-        elseif( is_page() && Sensei()->settings->get( 'my_course_page' ) == $post->ID  )
2128
+        elseif (is_page() && Sensei()->settings->get('my_course_page') == $post->ID)
2129 2129
         {
2130 2130
             /**
2131 2131
              * sensei_my_courses_per_page
@@ -2136,7 +2136,7 @@  discard block
 block discarded – undo
2136 2136
              * @since 1.9.0
2137 2137
              * @param integer $posts_per_page default 10
2138 2138
              */
2139
-            $query->set( 'posts_per_page', apply_filters( 'sensei_my_courses_per_page', 10 ) );
2139
+            $query->set('posts_per_page', apply_filters('sensei_my_courses_per_page', 10));
2140 2140
 
2141 2141
         }
2142 2142
 
@@ -2152,21 +2152,21 @@  discard block
 block discarded – undo
2152 2152
      * @return array $extra_classes
2153 2153
      * @since 1.9.0
2154 2154
      */
2155
-    public static function get_course_loop_content_class ()
2155
+    public static function get_course_loop_content_class()
2156 2156
     {
2157 2157
 
2158 2158
         global $sensei_course_loop;
2159 2159
 
2160 2160
 
2161
-        if( !isset( $sensei_course_loop ) ){
2161
+        if ( ! isset($sensei_course_loop)) {
2162 2162
             $sensei_course_loop = array();
2163 2163
         }
2164 2164
 
2165
-        if (!isset($sensei_course_loop['counter'])) {
2165
+        if ( ! isset($sensei_course_loop['counter'])) {
2166 2166
             $sensei_course_loop['counter'] = 0;
2167 2167
         }
2168 2168
 
2169
-        if (!isset($sensei_course_loop['columns'])) {
2169
+        if ( ! isset($sensei_course_loop['columns'])) {
2170 2170
             $sensei_course_loop['columns'] = self::get_loop_number_of_columns();
2171 2171
         }
2172 2172
 
@@ -2174,16 +2174,16 @@  discard block
 block discarded – undo
2174 2174
         $sensei_course_loop['counter']++;
2175 2175
 
2176 2176
         $extra_classes = array();
2177
-        if( 0 == ( $sensei_course_loop['counter'] - 1 ) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns']  ){
2177
+        if (0 == ($sensei_course_loop['counter'] - 1) % $sensei_course_loop['columns'] || 1 == $sensei_course_loop['columns']) {
2178 2178
             $extra_classes[] = 'first';
2179 2179
         }
2180 2180
 
2181
-        if( 0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns']  ){
2181
+        if (0 == $sensei_course_loop['counter'] % $sensei_course_loop['columns']) {
2182 2182
             $extra_classes[] = 'last';
2183 2183
         }
2184 2184
 
2185 2185
         // add the item number to the classes as well.
2186
-        $extra_classes[] = 'loop-item-number-'. $sensei_course_loop['counter'];
2186
+        $extra_classes[] = 'loop-item-number-'.$sensei_course_loop['counter'];
2187 2187
 
2188 2188
         /**
2189 2189
          * Filter the course loop class the fires in the  in get_course_loop_content_class function
@@ -2194,7 +2194,7 @@  discard block
 block discarded – undo
2194 2194
          * @param array $extra_classes
2195 2195
          * @param WP_Post $loop_current_course
2196 2196
          */
2197
-        return apply_filters( 'sensei_course_loop_content_class', $extra_classes ,get_post() );
2197
+        return apply_filters('sensei_course_loop_content_class', $extra_classes, get_post());
2198 2198
 
2199 2199
     }// end get_course_loop_class
2200 2200
 
@@ -2204,7 +2204,7 @@  discard block
 block discarded – undo
2204 2204
      * @since 1.9.0
2205 2205
      * @return mixed|void
2206 2206
      */
2207
-    public static function get_loop_number_of_columns(){
2207
+    public static function get_loop_number_of_columns() {
2208 2208
 
2209 2209
         /**
2210 2210
          * Filter the number of columns on the course archive page.
@@ -2224,10 +2224,10 @@  discard block
 block discarded – undo
2224 2224
      * @since 1.9.0
2225 2225
      * @param
2226 2226
      */
2227
-    public static function course_archive_sorting( $query ){
2227
+    public static function course_archive_sorting($query) {
2228 2228
 
2229 2229
         // don't show on category pages and other pages
2230
-        if( ! is_archive(  'course ') || is_tax('course-category') ){
2230
+        if ( ! is_archive('course ') || is_tax('course-category')) {
2231 2231
             return;
2232 2232
         }
2233 2233
 
@@ -2240,27 +2240,27 @@  discard block
 block discarded – undo
2240 2240
          *  @type string $option_string
2241 2241
          * }
2242 2242
          */
2243
-        $course_order_by_options = apply_filters( 'sensei_archive_course_order_by_options', array(
2244
-            "newness"     => __( "Sort by newest first", "woothemes-sensei"),
2245
-            "title"       => __( "Sort by title A-Z", "woothemes-sensei" ),
2243
+        $course_order_by_options = apply_filters('sensei_archive_course_order_by_options', array(
2244
+            "newness"     => __("Sort by newest first", "woothemes-sensei"),
2245
+            "title"       => __("Sort by title A-Z", "woothemes-sensei"),
2246 2246
         ));
2247 2247
 
2248 2248
         // setup the currently selected item
2249 2249
         $selected = 'newness';
2250
-        if( isset( $_GET['orderby'] ) ){
2250
+        if (isset($_GET['orderby'])) {
2251 2251
 
2252
-            $selected =  $_GET[ 'orderby' ];
2252
+            $selected = $_GET['orderby'];
2253 2253
 
2254 2254
         }
2255 2255
 
2256 2256
         ?>
2257 2257
 
2258
-        <form class="sensei-ordering" name="sensei-course-order" action="<?php echo esc_attr( Sensei_Utils::get_current_url() ) ; ?>" method="POST">
2258
+        <form class="sensei-ordering" name="sensei-course-order" action="<?php echo esc_attr(Sensei_Utils::get_current_url()); ?>" method="POST">
2259 2259
             <select name="course-orderby" class="orderby">
2260 2260
                 <?php
2261
-                foreach( $course_order_by_options as $value => $text ){
2261
+                foreach ($course_order_by_options as $value => $text) {
2262 2262
 
2263
-                    echo '<option value="'. $value . ' "' . selected( $selected, $value, false ) . '>'. $text. '</option>';
2263
+                    echo '<option value="'.$value.' "'.selected($selected, $value, false).'>'.$text.'</option>';
2264 2264
 
2265 2265
                 }
2266 2266
                 ?>
@@ -2278,10 +2278,10 @@  discard block
 block discarded – undo
2278 2278
      * @since 1.9.0
2279 2279
      * @param
2280 2280
      */
2281
-    public static function course_archive_filters( $query ){
2281
+    public static function course_archive_filters($query) {
2282 2282
 
2283 2283
         // don't show on category pages
2284
-        if( is_tax('course-category') ){
2284
+        if (is_tax('course-category')) {
2285 2285
             return;
2286 2286
         }
2287 2287
 
@@ -2294,9 +2294,9 @@  discard block
 block discarded – undo
2294 2294
          * }
2295 2295
          *
2296 2296
          */
2297
-        $filters = apply_filters( 'sensei_archive_course_filter_by_options', array(
2298
-            array( 'id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __( 'All', 'woothemes-sensei' ) ),
2299
-            array( 'id' => 'featured', 'url' => add_query_arg( array( 'course_filter'=>'featured'), self::get_courses_page_url()  ), 'title'=> __( 'Featured', 'woothemes-sensei' ) ),
2297
+        $filters = apply_filters('sensei_archive_course_filter_by_options', array(
2298
+            array('id' => 'all', 'url' => self::get_courses_page_url(), 'title'=> __('All', 'woothemes-sensei')),
2299
+            array('id' => 'featured', 'url' => add_query_arg(array('course_filter'=>'featured'), self::get_courses_page_url()), 'title'=> __('Featured', 'woothemes-sensei')),
2300 2300
         ));
2301 2301
 
2302 2302
 
@@ -2307,11 +2307,11 @@  discard block
 block discarded – undo
2307 2307
             //determine the current active url
2308 2308
             $current_url = Sensei_Utils::get_current_url();
2309 2309
 
2310
-            foreach( $filters as $filter ) {
2310
+            foreach ($filters as $filter) {
2311 2311
 
2312
-                $active_class =  $current_url == $filter['url'] ? ' class="active" ' : '';
2312
+                $active_class = $current_url == $filter['url'] ? ' class="active" ' : '';
2313 2313
 
2314
-                echo '<li><a '. $active_class .' id="'. $filter['id'] .'" href="'. esc_url( $filter['url'] ).'" >'. $filter['title']  .'</a></li>';
2314
+                echo '<li><a '.$active_class.' id="'.$filter['id'].'" href="'.esc_url($filter['url']).'" >'.$filter['title'].'</a></li>';
2315 2315
 
2316 2316
             }
2317 2317
             ?>
@@ -2332,13 +2332,13 @@  discard block
 block discarded – undo
2332 2332
      * @param WP_Query $query
2333 2333
      * @return WP_Query $query
2334 2334
      */
2335
-    public static function course_archive_featured_filter( $query ){
2335
+    public static function course_archive_featured_filter($query) {
2336 2336
 
2337
-        if( isset ( $_GET[ 'course_filter' ] ) && 'featured'== $_GET['course_filter'] && $query->is_main_query()  ){
2337
+        if (isset ($_GET['course_filter']) && 'featured' == $_GET['course_filter'] && $query->is_main_query()) {
2338 2338
             //setup meta query for featured courses
2339
-            $query->set( 'meta_value', 'featured'  );
2340
-            $query->set( 'meta_key', '_course_featured'  );
2341
-            $query->set( 'meta_compare', '='  );
2339
+            $query->set('meta_value', 'featured');
2340
+            $query->set('meta_key', '_course_featured');
2341
+            $query->set('meta_compare', '=');
2342 2342
         }
2343 2343
 
2344 2344
         return $query;
@@ -2353,13 +2353,13 @@  discard block
 block discarded – undo
2353 2353
      * @param WP_Query $query
2354 2354
      * @return WP_Query $query
2355 2355
      */
2356
-    public static function course_archive_order_by_title( $query ){
2356
+    public static function course_archive_order_by_title($query) {
2357 2357
 
2358
-        if( isset ( $_POST[ 'course-orderby' ] ) && 'title '== $_POST['course-orderby']
2359
-            && 'course'== $query->get('post_type') && $query->is_main_query()  ){
2358
+        if (isset ($_POST['course-orderby']) && 'title ' == $_POST['course-orderby']
2359
+            && 'course' == $query->get('post_type') && $query->is_main_query()) {
2360 2360
             // setup the order by title for this query
2361
-            $query->set( 'orderby', 'title'  );
2362
-            $query->set( 'order', 'ASC'  );
2361
+            $query->set('orderby', 'title');
2362
+            $query->set('order', 'ASC');
2363 2363
         }
2364 2364
 
2365 2365
         return $query;
@@ -2373,10 +2373,10 @@  discard block
 block discarded – undo
2373 2373
      * @since 1.9.0
2374 2374
      * @return string $course_page_url
2375 2375
      */
2376
-    public static function get_courses_page_url(){
2376
+    public static function get_courses_page_url() {
2377 2377
 
2378
-        $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] );
2379
-        $course_page_url = empty( $course_page_id ) ? get_post_type_archive_link('course') : get_permalink( $course_page_id );
2378
+        $course_page_id = intval(Sensei()->settings->settings['course_page']);
2379
+        $course_page_url = empty($course_page_id) ? get_post_type_archive_link('course') : get_permalink($course_page_id);
2380 2380
 
2381 2381
         return $course_page_url;
2382 2382
 
@@ -2393,61 +2393,61 @@  discard block
 block discarded – undo
2393 2393
      * @param string $after_html
2394 2394
      * @return void
2395 2395
      */
2396
-    public static function archive_header( $query_type ='' , $before_html='', $after_html =''  ){
2396
+    public static function archive_header($query_type = '', $before_html = '', $after_html = '') {
2397 2397
 
2398
-        if( ! is_post_type_archive('course') ){
2398
+        if ( ! is_post_type_archive('course')) {
2399 2399
             return;
2400 2400
         }
2401 2401
 
2402 2402
         // deprecated since 1.9.0
2403
-        sensei_do_deprecated_action('sensei_archive_title','1.9.0','sensei_archive_before_course_loop');
2403
+        sensei_do_deprecated_action('sensei_archive_title', '1.9.0', 'sensei_archive_before_course_loop');
2404 2404
 
2405 2405
         $html = '';
2406 2406
 
2407
-        if( empty( $before_html ) ){
2407
+        if (empty($before_html)) {
2408 2408
 
2409 2409
             $before_html = '<header class="archive-header"><h1>';
2410 2410
 
2411 2411
         }
2412 2412
 
2413
-        if( empty( $after_html ) ){
2413
+        if (empty($after_html)) {
2414 2414
 
2415 2415
             $after_html = '</h1></header>';
2416 2416
 
2417 2417
         }
2418 2418
 
2419
-        if ( is_tax( 'course-category' ) ) {
2419
+        if (is_tax('course-category')) {
2420 2420
 
2421 2421
             global $wp_query;
2422 2422
 
2423 2423
             $taxonomy_obj = $wp_query->get_queried_object();
2424 2424
             $taxonomy_short_name = $taxonomy_obj->taxonomy;
2425
-            $taxonomy_raw_obj = get_taxonomy( $taxonomy_short_name );
2426
-            $title = sprintf( __( '%1$s Archives: %2$s', 'woothemes-sensei' ), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name );
2427
-            echo apply_filters( 'course_category_archive_title', $before_html . $title . $after_html );
2425
+            $taxonomy_raw_obj = get_taxonomy($taxonomy_short_name);
2426
+            $title = sprintf(__('%1$s Archives: %2$s', 'woothemes-sensei'), $taxonomy_raw_obj->labels->name, $taxonomy_obj->name);
2427
+            echo apply_filters('course_category_archive_title', $before_html.$title.$after_html);
2428 2428
             return;
2429 2429
 
2430 2430
         } // End If Statement
2431 2431
 
2432
-        switch ( $query_type ) {
2432
+        switch ($query_type) {
2433 2433
             case 'newcourses':
2434
-                $html .= $before_html . __( 'New Courses', 'woothemes-sensei' ) . $after_html;
2434
+                $html .= $before_html.__('New Courses', 'woothemes-sensei').$after_html;
2435 2435
                 break;
2436 2436
             case 'featuredcourses':
2437
-                $html .= $before_html .  __( 'Featured Courses', 'woothemes-sensei' ) . $after_html;
2437
+                $html .= $before_html.__('Featured Courses', 'woothemes-sensei').$after_html;
2438 2438
                 break;
2439 2439
             case 'freecourses':
2440
-                $html .= $before_html .  __( 'Free Courses', 'woothemes-sensei' ) . $after_html;
2440
+                $html .= $before_html.__('Free Courses', 'woothemes-sensei').$after_html;
2441 2441
                 break;
2442 2442
             case 'paidcourses':
2443
-                $html .= $before_html .  __( 'Paid Courses', 'woothemes-sensei' ) . $after_html;
2443
+                $html .= $before_html.__('Paid Courses', 'woothemes-sensei').$after_html;
2444 2444
                 break;
2445 2445
             default:
2446
-                $html .= $before_html . __( 'Courses', 'woothemes-sensei' ) . $after_html;
2446
+                $html .= $before_html.__('Courses', 'woothemes-sensei').$after_html;
2447 2447
                 break;
2448 2448
         } // End Switch Statement
2449 2449
 
2450
-        echo apply_filters( 'course_archive_title', $html );
2450
+        echo apply_filters('course_archive_title', $html);
2451 2451
 
2452 2452
     }//course_archive_header
2453 2453
 
@@ -2461,9 +2461,9 @@  discard block
 block discarded – undo
2461 2461
      * @param string $content
2462 2462
      * @return string $content or $excerpt
2463 2463
      */
2464
-    public static function single_course_content( $content ){
2464
+    public static function single_course_content($content) {
2465 2465
 
2466
-        if( ! is_singular('course') ){
2466
+        if ( ! is_singular('course')) {
2467 2467
 
2468 2468
             return $content;
2469 2469
 
@@ -2472,21 +2472,21 @@  discard block
 block discarded – undo
2472 2472
         // Content Access Permissions
2473 2473
         $access_permission = false;
2474 2474
 
2475
-        if ( ! Sensei()->settings->get('access_permission')  || sensei_all_access() ) {
2475
+        if ( ! Sensei()->settings->get('access_permission') || sensei_all_access()) {
2476 2476
 
2477 2477
             $access_permission = true;
2478 2478
 
2479 2479
         } // End If Statement
2480 2480
 
2481 2481
         // Check if the user is taking the course
2482
-        $is_user_taking_course = Sensei_Utils::user_started_course( get_the_ID(), get_current_user_id() );
2482
+        $is_user_taking_course = Sensei_Utils::user_started_course(get_the_ID(), get_current_user_id());
2483 2483
 
2484
-        if(Sensei_WC::is_woocommerce_active()) {
2484
+        if (Sensei_WC::is_woocommerce_active()) {
2485 2485
 
2486
-            $wc_post_id = get_post_meta( get_the_ID(), '_course_woocommerce_product', true );
2487
-            $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id );
2486
+            $wc_post_id = get_post_meta(get_the_ID(), '_course_woocommerce_product', true);
2487
+            $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id);
2488 2488
 
2489
-            $has_product_attached = isset ( $product ) && is_object ( $product );
2489
+            $has_product_attached = isset ($product) && is_object($product);
2490 2490
 
2491 2491
         } else {
2492 2492
 
@@ -2494,15 +2494,15 @@  discard block
 block discarded – undo
2494 2494
 
2495 2495
         }
2496 2496
 
2497
-        if ( ( is_user_logged_in() && $is_user_taking_course )
2498
-            || ( $access_permission && !$has_product_attached)
2499
-            || 'full' == Sensei()->settings->get( 'course_single_content_display' ) ) {
2497
+        if ((is_user_logged_in() && $is_user_taking_course)
2498
+            || ($access_permission && ! $has_product_attached)
2499
+            || 'full' == Sensei()->settings->get('course_single_content_display')) {
2500 2500
 
2501 2501
             return $content;
2502 2502
 
2503 2503
         } else {
2504 2504
 
2505
-            return '<p class="course-excerpt">' . get_post(  get_the_ID() )->post_excerpt . '</p>';
2505
+            return '<p class="course-excerpt">'.get_post(get_the_ID())->post_excerpt.'</p>';
2506 2506
 
2507 2507
         }
2508 2508
 
@@ -2513,14 +2513,14 @@  discard block
 block discarded – undo
2513 2513
      *
2514 2514
      * @since 1.9.0
2515 2515
      */
2516
-    public static function the_course_lessons_title(){
2516
+    public static function the_course_lessons_title() {
2517 2517
         global $post;
2518
-        $none_module_lessons = Sensei()->modules->get_none_module_lessons( $post->ID  );
2519
-        $course_lessons = Sensei()->course->course_lessons( $post->ID );
2518
+        $none_module_lessons = Sensei()->modules->get_none_module_lessons($post->ID);
2519
+        $course_lessons = Sensei()->course->course_lessons($post->ID);
2520 2520
 
2521 2521
         // title should be Other Lessons if there are lessons belonging to models.
2522 2522
         $title = __('Other Lessons', 'woothemes-sensei');
2523
-        if( count( $course_lessons ) == count( $none_module_lessons )  ){
2523
+        if (count($course_lessons) == count($none_module_lessons)) {
2524 2524
 
2525 2525
             $title = __('Lessons', 'woothemes-sensei');
2526 2526
 
@@ -2529,7 +2529,7 @@  discard block
 block discarded – undo
2529 2529
         /**
2530 2530
          * hook document in class-woothemes-sensei-message.php
2531 2531
          */
2532
-        $title = apply_filters( 'sensei_single_title', $title, $post->post_type );
2532
+        $title = apply_filters('sensei_single_title', $title, $post->post_type);
2533 2533
 
2534 2534
         ob_start(); // start capturing the following output.
2535 2535
 
@@ -2548,7 +2548,7 @@  discard block
 block discarded – undo
2548 2548
          * @since 1.9.0
2549 2549
          * @param string $lessons_title_html
2550 2550
          */
2551
-        echo apply_filters('the_course_lessons_title', ob_get_clean() ); // output and filter the captured output and stop capturing.
2551
+        echo apply_filters('the_course_lessons_title', ob_get_clean()); // output and filter the captured output and stop capturing.
2552 2552
 
2553 2553
     }// end the_course_lessons_title
2554 2554
 
@@ -2563,13 +2563,13 @@  discard block
 block discarded – undo
2563 2563
      * @since 1.9.0
2564 2564
      * @global $wp_query
2565 2565
      */
2566
-    public static function load_single_course_lessons_query(){
2566
+    public static function load_single_course_lessons_query() {
2567 2567
 
2568 2568
         global $post, $wp_query;
2569 2569
 
2570 2570
         $course_id = $post->ID;
2571 2571
 
2572
-        if( 'course' != get_post_type( $course_id ) ){
2572
+        if ('course' != get_post_type($course_id)) {
2573 2573
             return;
2574 2574
         }
2575 2575
 
@@ -2581,7 +2581,7 @@  discard block
 block discarded – undo
2581 2581
             'meta_query'        => array(
2582 2582
                 array(
2583 2583
                     'key' => '_lesson_course',
2584
-                    'value' => intval( $course_id ),
2584
+                    'value' => intval($course_id),
2585 2585
                 ),
2586 2586
             ),
2587 2587
             'post_status'       => 'public',
@@ -2589,17 +2589,17 @@  discard block
 block discarded – undo
2589 2589
         );
2590 2590
 
2591 2591
         // Exclude lessons belonging to modules as they are queried along with the modules.
2592
-        $modules = Sensei()->modules->get_course_modules( $course_id );
2593
-        if( !is_wp_error( $modules ) && ! empty( $modules ) && is_array( $modules ) ){
2592
+        $modules = Sensei()->modules->get_course_modules($course_id);
2593
+        if ( ! is_wp_error($modules) && ! empty($modules) && is_array($modules)) {
2594 2594
 
2595 2595
             $terms_ids = array();
2596
-            foreach( $modules as $term ){
2596
+            foreach ($modules as $term) {
2597 2597
 
2598 2598
                 $terms_ids[] = $term->term_id;
2599 2599
 
2600 2600
             }
2601 2601
 
2602
-            $course_lesson_query_args[ 'tax_query'] = array(
2602
+            $course_lesson_query_args['tax_query'] = array(
2603 2603
                 array(
2604 2604
                     'taxonomy' => 'module',
2605 2605
                     'field'    => 'id',
@@ -2609,7 +2609,7 @@  discard block
 block discarded – undo
2609 2609
             );
2610 2610
         }
2611 2611
 
2612
-        $wp_query = new WP_Query( $course_lesson_query_args );
2612
+        $wp_query = new WP_Query($course_lesson_query_args);
2613 2613
 
2614 2614
     }// load_single_course_lessons
2615 2615
 
@@ -2620,16 +2620,16 @@  discard block
 block discarded – undo
2620 2620
      *
2621 2621
      * @param $post_id
2622 2622
      */
2623
-    public static function flush_rewrite_rules( $post_id ){
2623
+    public static function flush_rewrite_rules($post_id) {
2624 2624
 
2625
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
2625
+        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
2626 2626
 
2627 2627
             return;
2628 2628
 
2629 2629
         }
2630 2630
 
2631 2631
 
2632
-        if( 'course' == get_post_type( $post_id )  ){
2632
+        if ('course' == get_post_type($post_id)) {
2633 2633
 
2634 2634
             Sensei()->initiate_rewrite_rules_flush();
2635 2635
 
@@ -2645,10 +2645,10 @@  discard block
 block discarded – undo
2645 2645
      * @param $excerpt
2646 2646
      * @return string
2647 2647
      */
2648
-    public static function full_content_excerpt_override( $excerpt ){
2648
+    public static function full_content_excerpt_override($excerpt) {
2649 2649
 
2650
-        if (   is_singular('course')  &&
2651
-                'full' == Sensei()->settings->get( 'course_single_content_display' ) ){
2650
+        if (is_singular('course') &&
2651
+                'full' == Sensei()->settings->get('course_single_content_display')) {
2652 2652
 
2653 2653
             return get_the_content();
2654 2654
 
@@ -2665,60 +2665,60 @@  discard block
 block discarded – undo
2665 2665
      *
2666 2666
      * @since 1.9.0
2667 2667
      */
2668
-    public static function the_course_enrolment_actions(){
2668
+    public static function the_course_enrolment_actions() {
2669 2669
         ?>
2670 2670
         <section class="course-meta course-enrolment">
2671 2671
         <?php
2672 2672
         global  $post, $current_user;
2673
-        $is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID );
2674
-        if ( is_user_logged_in() && ! $is_user_taking_course ) {
2673
+        $is_user_taking_course = Sensei_Utils::user_started_course($post->ID, $current_user->ID);
2674
+        if (is_user_logged_in() && ! $is_user_taking_course) {
2675 2675
 
2676 2676
             // Get the product ID
2677
-            $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
2677
+            $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true));
2678 2678
 
2679 2679
             // Check for woocommerce
2680
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) {
2680
+            if (Sensei_WC::is_woocommerce_active() && (0 < intval($wc_post_id))) {
2681 2681
                 sensei_wc_add_to_cart($post->ID);
2682 2682
             } else {
2683 2683
                 sensei_start_course_form($post->ID);
2684 2684
             } // End If Statement
2685 2685
 
2686
-        } elseif ( is_user_logged_in() ) {
2686
+        } elseif (is_user_logged_in()) {
2687 2687
 
2688 2688
             // Check if course is completed
2689
-            $user_course_status = Sensei_Utils::user_course_status( $post->ID, $current_user->ID );
2690
-            $completed_course = Sensei_Utils::user_completed_course( $user_course_status );
2689
+            $user_course_status = Sensei_Utils::user_course_status($post->ID, $current_user->ID);
2690
+            $completed_course = Sensei_Utils::user_completed_course($user_course_status);
2691 2691
             // Success message
2692
-            if ( $completed_course ) { ?>
2693
-                <div class="status completed"><?php  _e( 'Completed', 'woothemes-sensei' ); ?></div>
2692
+            if ($completed_course) { ?>
2693
+                <div class="status completed"><?php  _e('Completed', 'woothemes-sensei'); ?></div>
2694 2694
                 <?php
2695
-                $has_quizzes = Sensei()->course->course_quizzes( $post->ID, true );
2696
-                if( has_filter( 'sensei_results_links' ) || $has_quizzes ) { ?>
2695
+                $has_quizzes = Sensei()->course->course_quizzes($post->ID, true);
2696
+                if (has_filter('sensei_results_links') || $has_quizzes) { ?>
2697 2697
                     <p class="sensei-results-links">
2698 2698
                         <?php
2699 2699
                         $results_link = '';
2700
-                        if( $has_quizzes ) {
2701
-                            $results_link = '<a class="view-results" href="' . Sensei()->course_results->get_permalink( $post->ID ) . '">' .  __( 'View results', 'woothemes-sensei' ) . '</a>';
2700
+                        if ($has_quizzes) {
2701
+                            $results_link = '<a class="view-results" href="'.Sensei()->course_results->get_permalink($post->ID).'">'.__('View results', 'woothemes-sensei').'</a>';
2702 2702
                         }
2703
-                        $results_link = apply_filters( 'sensei_results_links', $results_link );
2703
+                        $results_link = apply_filters('sensei_results_links', $results_link);
2704 2704
                         echo $results_link;
2705 2705
                         ?></p>
2706 2706
                 <?php } ?>
2707 2707
             <?php } else { ?>
2708
-                <div class="status in-progress"><?php echo __( 'In Progress', 'woothemes-sensei' ); ?></div>
2708
+                <div class="status in-progress"><?php echo __('In Progress', 'woothemes-sensei'); ?></div>
2709 2709
             <?php }
2710 2710
 
2711 2711
         } else {
2712 2712
             // Get the product ID
2713
-            $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) );
2713
+            $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true));
2714 2714
             // Check for woocommerce
2715
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < intval( $wc_post_id ) ) ) {
2715
+            if (Sensei_WC::is_woocommerce_active() && (0 < intval($wc_post_id))) {
2716 2716
 
2717 2717
                 sensei_wc_add_to_cart($post->ID);
2718 2718
 
2719 2719
             } else {
2720 2720
 
2721
-                if( get_option( 'users_can_register') ) {
2721
+                if (get_option('users_can_register')) {
2722 2722
 
2723 2723
 
2724 2724
                     $my_courses_page_id = '';
@@ -2734,24 +2734,24 @@  discard block
 block discarded – undo
2734 2734
                     $wp_register_link = apply_filters('sensei_use_wp_register_link', false);
2735 2735
 
2736 2736
                     $settings = Sensei()->settings->get_settings();
2737
-                    if( isset( $settings[ 'my_course_page' ] )
2738
-                        && 0 < intval( $settings[ 'my_course_page' ] ) ){
2737
+                    if (isset($settings['my_course_page'])
2738
+                        && 0 < intval($settings['my_course_page'])) {
2739 2739
 
2740
-                        $my_courses_page_id = $settings[ 'my_course_page' ];
2740
+                        $my_courses_page_id = $settings['my_course_page'];
2741 2741
 
2742 2742
                     }
2743 2743
 
2744 2744
                     // If a My Courses page was set in Settings, and 'sensei_use_wp_register_link'
2745 2745
                     // is false, link to My Courses. If not, link to default WordPress registration page.
2746
-                    if( !empty( $my_courses_page_id ) && $my_courses_page_id && !$wp_register_link){
2746
+                    if ( ! empty($my_courses_page_id) && $my_courses_page_id && ! $wp_register_link) {
2747 2747
 
2748
-                        $my_courses_url = get_permalink( $my_courses_page_id  );
2749
-                        $register_link = '<a href="'.$my_courses_url. '">' . __('Register', 'woothemes-sensei') .'</a>';
2750
-                        echo '<div class="status register">' . $register_link . '</div>' ;
2748
+                        $my_courses_url = get_permalink($my_courses_page_id);
2749
+                        $register_link = '<a href="'.$my_courses_url.'">'.__('Register', 'woothemes-sensei').'</a>';
2750
+                        echo '<div class="status register">'.$register_link.'</div>';
2751 2751
 
2752
-                    } else{
2752
+                    } else {
2753 2753
 
2754
-                        wp_register( '<div class="status register">', '</div>' );
2754
+                        wp_register('<div class="status register">', '</div>');
2755 2755
 
2756 2756
                     }
2757 2757
 
@@ -2770,19 +2770,19 @@  discard block
 block discarded – undo
2770 2770
      *
2771 2771
      * @since 1.9.0
2772 2772
      */
2773
-    public static function the_course_video(){
2773
+    public static function the_course_video() {
2774 2774
 
2775 2775
         global $post;
2776 2776
         // Get the meta info
2777
-        $course_video_embed = get_post_meta( $post->ID, '_course_video_embed', true );
2777
+        $course_video_embed = get_post_meta($post->ID, '_course_video_embed', true);
2778 2778
 
2779
-        if ( 'http' == substr( $course_video_embed, 0, 4) ) {
2779
+        if ('http' == substr($course_video_embed, 0, 4)) {
2780 2780
 
2781
-            $course_video_embed = wp_oembed_get( esc_url( $course_video_embed ) );
2781
+            $course_video_embed = wp_oembed_get(esc_url($course_video_embed));
2782 2782
 
2783 2783
         } // End If Statement
2784 2784
 
2785
-        if ( '' != $course_video_embed ) { ?>
2785
+        if ('' != $course_video_embed) { ?>
2786 2786
 
2787 2787
             <div class="course-video">
2788 2788
                 <?php echo html_entity_decode($course_video_embed); ?>
@@ -2797,7 +2797,7 @@  discard block
 block discarded – undo
2797 2797
      * @global $post
2798 2798
      * @since 1.9.0
2799 2799
      */
2800
-    public static function the_title(){
2800
+    public static function the_title() {
2801 2801
 
2802 2802
         global $post;
2803 2803
 
@@ -2810,7 +2810,7 @@  discard block
 block discarded – undo
2810 2810
                 /**
2811 2811
                  * Filter documented in class-sensei-messages.php the_title
2812 2812
                  */
2813
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
2813
+                echo apply_filters('sensei_single_title', get_the_title($post), $post->post_type);
2814 2814
                 ?>
2815 2815
 
2816 2816
             </h1>
@@ -2826,30 +2826,30 @@  discard block
 block discarded – undo
2826 2826
      *
2827 2827
      * @since 1.9.0
2828 2828
      */
2829
-    public static function course_category_title(){
2829
+    public static function course_category_title() {
2830 2830
 
2831
-        if( ! is_tax( 'course-category' ) ){
2831
+        if ( ! is_tax('course-category')) {
2832 2832
             return;
2833 2833
         }
2834 2834
 
2835 2835
         $category_slug = get_query_var('course-category');
2836
-        $term  = get_term_by('slug',$category_slug,'course-category');
2836
+        $term = get_term_by('slug', $category_slug, 'course-category');
2837 2837
 
2838
-        if( ! empty($term) ){
2838
+        if ( ! empty($term)) {
2839 2839
 
2840 2840
             $title = $term->name;
2841 2841
 
2842
-        }else{
2842
+        } else {
2843 2843
 
2844 2844
             $title = 'Course Category';
2845 2845
 
2846 2846
         }
2847 2847
 
2848 2848
         $html = '<h2 class="sensei-category-title">';
2849
-        $html .= __('Category') . ' ' . $title;
2849
+        $html .= __('Category').' '.$title;
2850 2850
         $html .= '</h2>';
2851 2851
 
2852
-        echo apply_filters( 'course_category_title', $html , $term->term_id );
2852
+        echo apply_filters('course_category_title', $html, $term->term_id);
2853 2853
 
2854 2854
     }// course_category_title
2855 2855
 
@@ -2862,16 +2862,16 @@  discard block
 block discarded – undo
2862 2862
      * @param WP_Query $query
2863 2863
      * @return WP_Query
2864 2864
      */
2865
-    public static function alter_course_category_order( $query ){
2865
+    public static function alter_course_category_order($query) {
2866 2866
 
2867
-        if( ! is_tax( 'course-category' ) || ! $query->is_main_query() ){
2867
+        if ( ! is_tax('course-category') || ! $query->is_main_query()) {
2868 2868
             return $query;
2869 2869
         }
2870 2870
 
2871
-        $order = get_option( 'sensei_course_order', '' );
2872
-        if( !empty( $order )  ){
2873
-            $query->set('orderby', 'menu_order' );
2874
-            $query->set('order', 'ASC' );
2871
+        $order = get_option('sensei_course_order', '');
2872
+        if ( ! empty($order)) {
2873
+            $query->set('orderby', 'menu_order');
2874
+            $query->set('order', 'ASC');
2875 2875
         }
2876 2876
 
2877 2877
         return $query;
@@ -2892,7 +2892,7 @@  discard block
 block discarded – undo
2892 2892
      *
2893 2893
      * @return array
2894 2894
      */
2895
-    public static function get_default_query_args(){
2895
+    public static function get_default_query_args() {
2896 2896
         return array(
2897 2897
             'post_type' 		=> 'course',
2898 2898
             'posts_per_page' 		=> 1000,
@@ -2910,14 +2910,14 @@  discard block
 block discarded – undo
2910 2910
      * @param $course_id
2911 2911
      * @return bool
2912 2912
      */
2913
-    public static function is_prerequisite_complete( $course_id ){
2913
+    public static function is_prerequisite_complete($course_id) {
2914 2914
 
2915
-        $course_prerequisite_id = get_post_meta( $course_id, '_course_prerequisite', true );
2915
+        $course_prerequisite_id = get_post_meta($course_id, '_course_prerequisite', true);
2916 2916
 
2917 2917
         // if it has a pre requisite course check it
2918
-        if( ! empty(  $course_prerequisite_id ) ){
2918
+        if ( ! empty($course_prerequisite_id)) {
2919 2919
 
2920
-            return Sensei_Utils::user_completed_course( $course_prerequisite_id, get_current_user_id() );
2920
+            return Sensei_Utils::user_completed_course($course_prerequisite_id, get_current_user_id());
2921 2921
 
2922 2922
         }
2923 2923
 
@@ -2933,4 +2933,4 @@  discard block
 block discarded – undo
2933 2933
  * for backward compatibility
2934 2934
  * @since 1.9.0
2935 2935
  */
2936
-class WooThemes_Sensei_Course extends Sensei_Course{}
2936
+class WooThemes_Sensei_Course extends Sensei_Course {}
Please login to merge, or discard this patch.
includes/class-sensei-templates.php 3 patches
Braces   +21 added lines, -9 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// security check, don't load file outside WP
3 6
 /**
4 7
  * Sensei Template Class
5 8
  *
@@ -69,8 +72,9 @@  discard block
 block discarded – undo
69 72
      */
70 73
     public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
71 74
 
72
-        if ( $args && is_array($args) )
73
-            extract( $args );
75
+        if ( $args && is_array($args) ) {
76
+                    extract( $args );
77
+        }
74 78
 
75 79
         $located = self::locate_template( $template_name, $template_path, $default_path );
76 80
 
@@ -99,8 +103,12 @@  discard block
 block discarded – undo
99 103
      */
100 104
     public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
101 105
 
102
-        if ( ! $template_path ) $template_path = Sensei()->template_url;
103
-        if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
106
+        if ( ! $template_path ) {
107
+        	$template_path = Sensei()->template_url;
108
+        }
109
+        if ( ! $default_path ) {
110
+        	$default_path = Sensei()->plugin_path() . '/templates/';
111
+        }
104 112
 
105 113
         // Look within passed path within the theme - this is priority
106 114
         $template = locate_template(
@@ -261,7 +269,7 @@  discard block
 block discarded – undo
261 269
             $find[] = $file;
262 270
             $find[] = Sensei()->template_url . $file;
263 271
 
264
-        }elseif( is_author()
272
+        } elseif( is_author()
265 273
                  && Sensei_Teacher::is_a_teacher( get_query_var('author') )
266 274
                  && ! user_can( get_query_var('author'), 'manage_options' ) ){
267 275
 
@@ -274,7 +282,9 @@  discard block
 block discarded – undo
274 282
         if ( $file ) {
275 283
 
276 284
             $template = locate_template( $find );
277
-            if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
285
+            if ( ! $template ) {
286
+            	$template = Sensei()->plugin_path() . '/templates/' . $file;
287
+            }
278 288
 
279 289
         } // End If Statement
280 290
 
@@ -305,7 +315,9 @@  discard block
 block discarded – undo
305 315
         $find[] = Sensei()->template_url . $file;
306 316
 
307 317
         $template = locate_template( $find );
308
-        if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
318
+        if ( ! $template ) {
319
+        	$template = Sensei()->plugin_path() . '/templates/' . $file;
320
+        }
309 321
 
310 322
         return $template;
311 323
 
@@ -335,7 +347,7 @@  discard block
 block discarded – undo
335 347
                 include( $found_template );
336 348
                 get_sensei_footer();
337 349
 
338
-            }else{
350
+            } else{
339 351
 
340 352
                 include( $found_template );
341 353
 
Please login to merge, or discard this patch.
Indentation   +514 added lines, -514 removed lines patch added patch discarded remove patch
@@ -11,681 +11,681 @@
 block discarded – undo
11 11
  */
12 12
 class Sensei_Templates {
13 13
 
14
-    /**
15
-     *  Load the template files from within sensei/templates/ or the the theme if overrided within the theme.
16
-     *
17
-     * @since 1.9.0
18
-     * @param string $slug
19
-     * @param string $name default: ''
20
-     *
21
-     * @return void
22
-     */
23
-    public static function get_part(  $slug, $name = ''  ){
14
+	/**
15
+	 *  Load the template files from within sensei/templates/ or the the theme if overrided within the theme.
16
+	 *
17
+	 * @since 1.9.0
18
+	 * @param string $slug
19
+	 * @param string $name default: ''
20
+	 *
21
+	 * @return void
22
+	 */
23
+	public static function get_part(  $slug, $name = ''  ){
24 24
 
25
-        $template = '';
26
-        $plugin_template_url = Sensei()->template_url;
27
-        $plugin_template_path = Sensei()->plugin_path() . "/templates/";
25
+		$template = '';
26
+		$plugin_template_url = Sensei()->template_url;
27
+		$plugin_template_path = Sensei()->plugin_path() . "/templates/";
28 28
 
29
-        // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php
30
-        if ( $name ){
29
+		// Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php
30
+		if ( $name ){
31 31
 
32
-            $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) );
32
+			$template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) );
33 33
 
34
-        }
34
+		}
35 35
 
36
-        // Get default slug-name.php
37
-        if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){
36
+		// Get default slug-name.php
37
+		if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){
38 38
 
39
-            $template = $plugin_template_path . "{$slug}-{$name}.php";
39
+			$template = $plugin_template_path . "{$slug}-{$name}.php";
40 40
 
41
-        }
41
+		}
42 42
 
43 43
 
44
-        // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php
45
-        if ( !$template ){
44
+		// If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php
45
+		if ( !$template ){
46 46
 
47
-            $template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) );
47
+			$template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) );
48 48
 
49
-        }
49
+		}
50 50
 
51 51
 
52
-        if ( $template ){
52
+		if ( $template ){
53 53
 
54
-            load_template( $template, false );
54
+			load_template( $template, false );
55 55
 
56
-        }
56
+		}
57 57
 
58
-    } // end get part
58
+	} // end get part
59 59
 
60
-    /**
61
-     * Get the template.
62
-     *
63
-     * @since 1.9.0
64
-     *
65
-     * @param $template_name
66
-     * @param array $args
67
-     * @param string $template_path
68
-     * @param string $default_path
69
-     */
70
-    public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
60
+	/**
61
+	 * Get the template.
62
+	 *
63
+	 * @since 1.9.0
64
+	 *
65
+	 * @param $template_name
66
+	 * @param array $args
67
+	 * @param string $template_path
68
+	 * @param string $default_path
69
+	 */
70
+	public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
71 71
 
72
-        if ( $args && is_array($args) )
73
-            extract( $args );
72
+		if ( $args && is_array($args) )
73
+			extract( $args );
74 74
 
75
-        $located = self::locate_template( $template_name, $template_path, $default_path );
75
+		$located = self::locate_template( $template_name, $template_path, $default_path );
76 76
 
77
-        if( ! empty( $located ) ){
77
+		if( ! empty( $located ) ){
78 78
 
79
-            do_action( 'sensei_before_template_part', $template_name, $template_path, $located );
79
+			do_action( 'sensei_before_template_part', $template_name, $template_path, $located );
80 80
 
81
-            include( $located );
81
+			include( $located );
82 82
 
83
-            do_action( 'sensei_after_template_part', $template_name, $template_path, $located );
83
+			do_action( 'sensei_after_template_part', $template_name, $template_path, $located );
84 84
 
85
-        }
85
+		}
86 86
 
87
-    } // end get template
87
+	} // end get template
88 88
 
89
-    /**
90
-     * Check if the template file exists. A wrapper for WP locate_template.
91
-     *
92
-     * @since 1.9.0
93
-     *
94
-     * @param $template_name
95
-     * @param string $template_path
96
-     * @param string $default_path
97
-     *
98
-     * @return mixed|void
99
-     */
100
-    public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
89
+	/**
90
+	 * Check if the template file exists. A wrapper for WP locate_template.
91
+	 *
92
+	 * @since 1.9.0
93
+	 *
94
+	 * @param $template_name
95
+	 * @param string $template_path
96
+	 * @param string $default_path
97
+	 *
98
+	 * @return mixed|void
99
+	 */
100
+	public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
101 101
 
102
-        if ( ! $template_path ) $template_path = Sensei()->template_url;
103
-        if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
102
+		if ( ! $template_path ) $template_path = Sensei()->template_url;
103
+		if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
104 104
 
105
-        // Look within passed path within the theme - this is priority
106
-        $template = locate_template(
107
-            array(
108
-                $template_path . $template_name,
109
-                $template_name
110
-            )
111
-        );
105
+		// Look within passed path within the theme - this is priority
106
+		$template = locate_template(
107
+			array(
108
+				$template_path . $template_name,
109
+				$template_name
110
+			)
111
+		);
112 112
 
113
-        // Get default template
114
-        if ( ! $template ){
113
+		// Get default template
114
+		if ( ! $template ){
115 115
 
116
-            $template = $default_path . $template_name;
116
+			$template = $default_path . $template_name;
117 117
 
118
-        }
119
-        // return nothing for file that do not exist
120
-        if( !file_exists( $template ) ){
121
-            $template = '';
122
-        }
118
+		}
119
+		// return nothing for file that do not exist
120
+		if( !file_exists( $template ) ){
121
+			$template = '';
122
+		}
123 123
 
124
-        // Return what we found
125
-        return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path );
124
+		// Return what we found
125
+		return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path );
126 126
 
127
-    } // end locate
127
+	} // end locate
128 128
 
129
-    /**
130
-     * Determine which Sensei template to load based on the
131
-     * current page context.
132
-     *
133
-     * @since 1.0
134
-     *
135
-     * @param string $template
136
-     * @return string $template
137
-     */
138
-    public static function template_loader ( $template = '' ) {
129
+	/**
130
+	 * Determine which Sensei template to load based on the
131
+	 * current page context.
132
+	 *
133
+	 * @since 1.0
134
+	 *
135
+	 * @param string $template
136
+	 * @return string $template
137
+	 */
138
+	public static function template_loader ( $template = '' ) {
139 139
 
140
-        global $wp_query, $email_template;
140
+		global $wp_query, $email_template;
141 141
 
142
-        $find = array( 'woothemes-sensei.php' );
143
-        $file = '';
142
+		$find = array( 'woothemes-sensei.php' );
143
+		$file = '';
144 144
 
145
-        if ( isset( $email_template ) && $email_template ) {
145
+		if ( isset( $email_template ) && $email_template ) {
146 146
 
147
-            $file 	= 'emails/' . $email_template;
148
-            $find[] = $file;
149
-            $find[] = Sensei()->template_url . $file;
147
+			$file 	= 'emails/' . $email_template;
148
+			$find[] = $file;
149
+			$find[] = Sensei()->template_url . $file;
150 150
 
151
-        } elseif ( is_single() && get_post_type() == 'course' ) {
151
+		} elseif ( is_single() && get_post_type() == 'course' ) {
152 152
 
153
-            if ( Sensei()->check_user_permissions( 'course-single' ) ) {
153
+			if ( Sensei()->check_user_permissions( 'course-single' ) ) {
154 154
 
155
-                // possible backward compatible template include if theme overrides content-single-course.php
156
-                // this template was removed in 1.9.0 and code all moved into the main single-course.php file
157
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true );
155
+				// possible backward compatible template include if theme overrides content-single-course.php
156
+				// this template was removed in 1.9.0 and code all moved into the main single-course.php file
157
+				self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true );
158 158
 
159
-                $file 	= 'single-course.php';
160
-                $find[] = $file;
161
-                $find[] = Sensei()->template_url . $file;
159
+				$file 	= 'single-course.php';
160
+				$find[] = $file;
161
+				$find[] = Sensei()->template_url . $file;
162 162
 
163
-            } else {
163
+			} else {
164 164
 
165
-                // No Permissions Page
166
-                return self::get_no_permission_template();
165
+				// No Permissions Page
166
+				return self::get_no_permission_template();
167 167
 
168
-            } // End If Statement
168
+			} // End If Statement
169 169
 
170
-        } elseif ( is_single() && get_post_type() == 'lesson' ) {
170
+		} elseif ( is_single() && get_post_type() == 'lesson' ) {
171 171
 
172
-            if ( Sensei()->check_user_permissions( 'lesson-single' ) ) {
172
+			if ( Sensei()->check_user_permissions( 'lesson-single' ) ) {
173 173
 
174
-                // possible backward compatible template include if theme overrides content-single-lesson.php
175
-                // this template was removed in 1.9.0 and code all moved into the main single-lesson.php file
176
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true );
174
+				// possible backward compatible template include if theme overrides content-single-lesson.php
175
+				// this template was removed in 1.9.0 and code all moved into the main single-lesson.php file
176
+				self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true );
177 177
 
178
-                $file 	= 'single-lesson.php';
179
-                $find[] = $file;
180
-                $find[] = Sensei()->template_url . $file;
178
+				$file 	= 'single-lesson.php';
179
+				$find[] = $file;
180
+				$find[] = Sensei()->template_url . $file;
181 181
 
182
-            } else {
182
+			} else {
183 183
 
184
-                // No Permissions Page
185
-                return self::get_no_permission_template();
184
+				// No Permissions Page
185
+				return self::get_no_permission_template();
186 186
 
187
-            } // End If Statement
187
+			} // End If Statement
188 188
 
189
-        } elseif ( is_single() && get_post_type() == 'quiz' ) {
189
+		} elseif ( is_single() && get_post_type() == 'quiz' ) {
190 190
 
191
-            if ( Sensei()->check_user_permissions( 'quiz-single' ) ) {
191
+			if ( Sensei()->check_user_permissions( 'quiz-single' ) ) {
192 192
 
193
-                // possible backward compatible template include if theme overrides content-single-quiz.php
194
-                // this template was removed in 1.9.0 and code all moved into the main single-quiz.php file
195
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true);
193
+				// possible backward compatible template include if theme overrides content-single-quiz.php
194
+				// this template was removed in 1.9.0 and code all moved into the main single-quiz.php file
195
+				self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true);
196 196
 
197
-                $file 	= 'single-quiz.php';
198
-                $find[] = $file;
199
-                $find[] = Sensei()->template_url . $file;
197
+				$file 	= 'single-quiz.php';
198
+				$find[] = $file;
199
+				$find[] = Sensei()->template_url . $file;
200 200
 
201
-            } else {
201
+			} else {
202 202
 
203
-                // No Permissions Page
204
-                return self::get_no_permission_template();
203
+				// No Permissions Page
204
+				return self::get_no_permission_template();
205 205
 
206
-            } // End If Statement
206
+			} // End If Statement
207 207
 
208
-        } elseif ( is_single() && get_post_type() == 'sensei_message' ) {
208
+		} elseif ( is_single() && get_post_type() == 'sensei_message' ) {
209 209
 
210
-            // possible backward compatible template include if theme overrides content-single-message.php
211
-            // this template was removed in 1.9.0 and code all moved into the main single-message.php file
212
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true );
210
+			// possible backward compatible template include if theme overrides content-single-message.php
211
+			// this template was removed in 1.9.0 and code all moved into the main single-message.php file
212
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true );
213 213
 
214
-            $file 	= 'single-message.php';
215
-            $find[] = $file;
216
-            $find[] = Sensei()->template_url . $file;
214
+			$file 	= 'single-message.php';
215
+			$find[] = $file;
216
+			$find[] = Sensei()->template_url . $file;
217 217
 
218
-        } elseif ( is_post_type_archive( 'course' )
219
-                    || is_page( Sensei()->get_page_id( 'courses' ) )
220
-                    || is_tax( 'course-category' )) {
218
+		} elseif ( is_post_type_archive( 'course' )
219
+					|| is_page( Sensei()->get_page_id( 'courses' ) )
220
+					|| is_tax( 'course-category' )) {
221 221
 
222
-            // possible backward compatible template include if theme overrides 'taxonomy-course-category'
223
-            // this template was removed in 1.9.0 and replaced by archive-course.php
224
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php');
222
+			// possible backward compatible template include if theme overrides 'taxonomy-course-category'
223
+			// this template was removed in 1.9.0 and replaced by archive-course.php
224
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php');
225 225
 
226
-            $file 	= 'archive-course.php';
227
-            $find[] = $file;
228
-            $find[] = Sensei()->template_url . $file;
226
+			$file 	= 'archive-course.php';
227
+			$find[] = $file;
228
+			$find[] = Sensei()->template_url . $file;
229 229
 
230
-        } elseif ( is_post_type_archive( 'sensei_message' ) ) {
230
+		} elseif ( is_post_type_archive( 'sensei_message' ) ) {
231 231
 
232
-            $file 	= 'archive-message.php';
233
-            $find[] = $file;
234
-            $find[] = Sensei()->template_url . $file;
232
+			$file 	= 'archive-message.php';
233
+			$find[] = $file;
234
+			$find[] = Sensei()->template_url . $file;
235 235
 
236
-        } elseif( is_tax( 'lesson-tag' ) ) {
236
+		} elseif( is_tax( 'lesson-tag' ) ) {
237 237
 
238
-            // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php'
239
-            // this template was removed in 1.9.0 and replaced by archive-lesson.php
240
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' );
238
+			// possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php'
239
+			// this template was removed in 1.9.0 and replaced by archive-lesson.php
240
+			self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' );
241 241
 
242
-            $file 	= 'archive-lesson.php';
243
-            $find[] = $file;
244
-            $find[] = Sensei()->template_url . $file;
242
+			$file 	= 'archive-lesson.php';
243
+			$find[] = $file;
244
+			$find[] = Sensei()->template_url . $file;
245 245
 
246
-        } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) {
246
+		} elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) {
247 247
 
248
-            // Override for sites with static home page
249
-            $wp_query->is_home = false;
248
+			// Override for sites with static home page
249
+			$wp_query->is_home = false;
250 250
 
251
-            $file 	= 'learner-profile.php';
252
-            $find[] = $file;
253
-            $find[] = Sensei()->template_url . $file;
251
+			$file 	= 'learner-profile.php';
252
+			$find[] = $file;
253
+			$find[] = Sensei()->template_url . $file;
254 254
 
255
-        } elseif ( isset( $wp_query->query_vars['course_results'] ) ) {
255
+		} elseif ( isset( $wp_query->query_vars['course_results'] ) ) {
256 256
 
257
-            // Override for sites with static home page
258
-            $wp_query->is_home = false;
257
+			// Override for sites with static home page
258
+			$wp_query->is_home = false;
259 259
 
260
-            $file = 'course-results.php';
261
-            $find[] = $file;
262
-            $find[] = Sensei()->template_url . $file;
260
+			$file = 'course-results.php';
261
+			$find[] = $file;
262
+			$find[] = Sensei()->template_url . $file;
263 263
 
264
-        }elseif( is_author()
265
-                 && Sensei_Teacher::is_a_teacher( get_query_var('author') )
266
-                 && ! user_can( get_query_var('author'), 'manage_options' ) ){
264
+		}elseif( is_author()
265
+				 && Sensei_Teacher::is_a_teacher( get_query_var('author') )
266
+				 && ! user_can( get_query_var('author'), 'manage_options' ) ){
267 267
 
268
-            $file = 'teacher-archive.php';
269
-            $find[] = $file;
270
-            $find[] = Sensei()->template_url . $file;
268
+			$file = 'teacher-archive.php';
269
+			$find[] = $file;
270
+			$find[] = Sensei()->template_url . $file;
271 271
 
272
-        } // Load the template file
272
+		} // Load the template file
273 273
 
274
-        if ( $file ) {
274
+		if ( $file ) {
275 275
 
276
-            $template = locate_template( $find );
277
-            if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
276
+			$template = locate_template( $find );
277
+			if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
278 278
 
279
-        } // End If Statement
279
+		} // End If Statement
280 280
 
281
-        return $template;
281
+		return $template;
282 282
 
283
-    } // End template_loader()
283
+	} // End template_loader()
284 284
 
285
-    /**
286
-     * This function loads the no-permissions template for users with no access
287
-     * if a Sensei template was loaded.
288
-     *
289
-     * This function doesn't determine the permissions. Permissions must be determined
290
-     * before loading this function as it only gets the template.
291
-     *
292
-     * This function also checks the user theme for overrides to ensure the right template
293
-     * file is returned.
294
-     *
295
-     * @since 1.9.0
296
-     */
297
-    public static function get_no_permission_template( ){
285
+	/**
286
+	 * This function loads the no-permissions template for users with no access
287
+	 * if a Sensei template was loaded.
288
+	 *
289
+	 * This function doesn't determine the permissions. Permissions must be determined
290
+	 * before loading this function as it only gets the template.
291
+	 *
292
+	 * This function also checks the user theme for overrides to ensure the right template
293
+	 * file is returned.
294
+	 *
295
+	 * @since 1.9.0
296
+	 */
297
+	public static function get_no_permission_template( ){
298 298
 
299
-        // possible backward compatible template loading
300
-        // this template was removed in 1.9.0 and code all moved into the no-permissions.php file
301
-        self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true );
299
+		// possible backward compatible template loading
300
+		// this template was removed in 1.9.0 and code all moved into the no-permissions.php file
301
+		self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true );
302 302
 
303
-        $file 	= 'no-permissions.php';
304
-        $find[] = $file;
305
-        $find[] = Sensei()->template_url . $file;
303
+		$file 	= 'no-permissions.php';
304
+		$find[] = $file;
305
+		$find[] = Sensei()->template_url . $file;
306 306
 
307
-        $template = locate_template( $find );
308
-        if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
307
+		$template = locate_template( $find );
308
+		if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
309 309
 
310
-        return $template;
310
+		return $template;
311 311
 
312
-    }
312
+	}
313 313
 
314
-    /**
315
-     * This function is specifically created for loading template files from the theme.
316
-     *
317
-     * This function checks if the user has overwritten the templates like in their theme. If they have it in their theme it will load the header and the footer
318
-     * around the singular content file from their theme and exit.
319
-     *
320
-     * If none is found this function will do nothing. If a template is found this funciton
321
-     * will exit execution of the script an not continue.
322
-     *
323
-     * @since 1.9.0
324
-     * @param string $template
325
-     * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true
326
-     */
327
-    public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){
314
+	/**
315
+	 * This function is specifically created for loading template files from the theme.
316
+	 *
317
+	 * This function checks if the user has overwritten the templates like in their theme. If they have it in their theme it will load the header and the footer
318
+	 * around the singular content file from their theme and exit.
319
+	 *
320
+	 * If none is found this function will do nothing. If a template is found this funciton
321
+	 * will exit execution of the script an not continue.
322
+	 *
323
+	 * @since 1.9.0
324
+	 * @param string $template
325
+	 * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true
326
+	 */
327
+	public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){
328 328
 
329
-        $found_template = locate_template( array( $template ) );
330
-        if( $found_template ){
329
+		$found_template = locate_template( array( $template ) );
330
+		if( $found_template ){
331 331
 
332
-            if( $load_header_footer ){
332
+			if( $load_header_footer ){
333 333
 
334
-                get_sensei_header();
335
-                include( $found_template );
336
-                get_sensei_footer();
337
-
338
-            }else{
339
-
340
-                include( $found_template );
341
-
342
-            }
343
-
344
-            exit;
334
+				get_sensei_header();
335
+				include( $found_template );
336
+				get_sensei_footer();
337
+
338
+			}else{
339
+
340
+				include( $found_template );
341
+
342
+			}
343
+
344
+			exit;
345 345
 
346
-        }
346
+		}
347 347
 
348
-    }
348
+	}
349 349
 
350 350
 
351
-    /**
352
-     * Hooks the deprecated archive content hook into the hook again just in
353
-     * case other developers have used it.
354
-     *
355
-     * @deprecated since 1.9.0
356
-     */
357
-    public static function deprecated_archive_course_content_hook(){
358
-
359
-        sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' );
360
-
361
-    }// end deprecated_archive_hook
351
+	/**
352
+	 * Hooks the deprecated archive content hook into the hook again just in
353
+	 * case other developers have used it.
354
+	 *
355
+	 * @deprecated since 1.9.0
356
+	 */
357
+	public static function deprecated_archive_course_content_hook(){
358
+
359
+		sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' );
360
+
361
+	}// end deprecated_archive_hook
362 362
 
363
-    /**
364
-     * A generic function for echoing the post title
365
-     *
366
-     * @since 1.9.0
367
-     * @param  WP_Post $post
368
-     */
369
-    public static function the_title( $post ){
370
-
371
-        // ID passed in
372
-        if( is_numeric( $post ) ){
373
-            $post = get_post( $post );
374
-        }
375
-
376
-        /**
377
-         * Filter the template html tag for the title
378
-         *
379
-         * @since 1.9.0
380
-         *
381
-         * @param $title_html_tag default is 'h3'
382
-         */
383
-        $title_html_tag = apply_filters('sensei_the_title_html_tag','h3');
384
-
385
-        /**
386
-         * Filter the title classes
387
-         *
388
-         * @since 1.9.0
389
-         * @param string $title_classes defaults to $post_type-title
390
-         */
391
-        $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' );
392
-
393
-        $html= '';
394
-        $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >';
395
-        $html .= '<a href="' . get_permalink( $post->ID ) . '" >';
396
-        $html .= $post->post_title ;
397
-        $html .= '</a>';
398
-        $html .= '</'. $title_html_tag. '>';
399
-        echo $html;
400
-
401
-    }// end the title
402
-
403
-    /**
404
-     * This function adds the hooks inside and above the single course content for
405
-     * backwards compatibility sake.
406
-     *
407
-     * @since 1.9.0
408
-     * @deprecated 1.9.0
409
-     */
410
-    public static function deprecated_single_course_inside_before_hooks(){
411
-
412
-        sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
413
-        sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' );
414
-        sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' );
415
-
416
-    }// end deprecated_single_course_inside_before_hooks
417
-
418
-    /**
419
-     * This function adds the hooks to sensei_course_single_lessons for
420
-     * backwards compatibility sake.  and provides developers with an alternative.
421
-     *
422
-     * @since 1.9.0
423
-     * @deprecated 1.9.0
424
-     */
425
-    public static function deprecate_sensei_course_single_lessons_hook(){
363
+	/**
364
+	 * A generic function for echoing the post title
365
+	 *
366
+	 * @since 1.9.0
367
+	 * @param  WP_Post $post
368
+	 */
369
+	public static function the_title( $post ){
370
+
371
+		// ID passed in
372
+		if( is_numeric( $post ) ){
373
+			$post = get_post( $post );
374
+		}
375
+
376
+		/**
377
+		 * Filter the template html tag for the title
378
+		 *
379
+		 * @since 1.9.0
380
+		 *
381
+		 * @param $title_html_tag default is 'h3'
382
+		 */
383
+		$title_html_tag = apply_filters('sensei_the_title_html_tag','h3');
384
+
385
+		/**
386
+		 * Filter the title classes
387
+		 *
388
+		 * @since 1.9.0
389
+		 * @param string $title_classes defaults to $post_type-title
390
+		 */
391
+		$title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' );
392
+
393
+		$html= '';
394
+		$html .= '<'. $title_html_tag .' class="'. $title_classes .'" >';
395
+		$html .= '<a href="' . get_permalink( $post->ID ) . '" >';
396
+		$html .= $post->post_title ;
397
+		$html .= '</a>';
398
+		$html .= '</'. $title_html_tag. '>';
399
+		echo $html;
400
+
401
+	}// end the title
402
+
403
+	/**
404
+	 * This function adds the hooks inside and above the single course content for
405
+	 * backwards compatibility sake.
406
+	 *
407
+	 * @since 1.9.0
408
+	 * @deprecated 1.9.0
409
+	 */
410
+	public static function deprecated_single_course_inside_before_hooks(){
411
+
412
+		sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
413
+		sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' );
414
+		sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' );
415
+
416
+	}// end deprecated_single_course_inside_before_hooks
417
+
418
+	/**
419
+	 * This function adds the hooks to sensei_course_single_lessons for
420
+	 * backwards compatibility sake.  and provides developers with an alternative.
421
+	 *
422
+	 * @since 1.9.0
423
+	 * @deprecated 1.9.0
424
+	 */
425
+	public static function deprecate_sensei_course_single_lessons_hook(){
426 426
 
427
-        sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after');
427
+		sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after');
428 428
 
429
-    }// deprecate_sensei_course_single_lessons_hook
429
+	}// deprecate_sensei_course_single_lessons_hook
430 430
 
431
-    /**
432
-     * Deprecated all deprecated_single_main_content_hook hooked actions.
433
-     *
434
-     * The content must be dealt with inside the respective templates.
435
-     *
436
-     * @since 1.9.0
437
-     * @deprecated 1.9.0
438
-     */
439
-    public static function deprecated_single_main_content_hook(){
431
+	/**
432
+	 * Deprecated all deprecated_single_main_content_hook hooked actions.
433
+	 *
434
+	 * The content must be dealt with inside the respective templates.
435
+	 *
436
+	 * @since 1.9.0
437
+	 * @deprecated 1.9.0
438
+	 */
439
+	public static function deprecated_single_main_content_hook(){
440 440
 
441
-            if( is_singular( 'course' ) ) {
441
+			if( is_singular( 'course' ) ) {
442 442
 
443
-                sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after');
444
-
445
-            } elseif( is_singular( 'message' ) ){
446
-
447
-                sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after');
448
-            }
449
-
450
-    }// end deprecated_single_course_single_main_content_hook
451
-
452
-    /**
453
-     * Deprecate the  old sensei modules
454
-     * @since 1.9.0
455
-     * @deprecated since 1.9.0
456
-     */
457
-    public static function deprecate_module_before_hook(){
443
+				sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after');
444
+
445
+			} elseif( is_singular( 'message' ) ){
446
+
447
+				sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after');
448
+			}
449
+
450
+	}// end deprecated_single_course_single_main_content_hook
451
+
452
+	/**
453
+	 * Deprecate the  old sensei modules
454
+	 * @since 1.9.0
455
+	 * @deprecated since 1.9.0
456
+	 */
457
+	public static function deprecate_module_before_hook(){
458 458
 
459
-        sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' );
459
+		sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' );
460 460
 
461
-    }
462
-
463
-    /**
464
-     * Deprecate the  old sensei modules after hooks
465
-     * @since 1.9.0
466
-     * @deprecated since 1.9.0
467
-     */
468
-    public static function deprecate_module_after_hook(){
461
+	}
462
+
463
+	/**
464
+	 * Deprecate the  old sensei modules after hooks
465
+	 * @since 1.9.0
466
+	 * @deprecated since 1.9.0
467
+	 */
468
+	public static function deprecate_module_after_hook(){
469 469
 
470
-        sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' );
470
+		sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' );
471 471
 
472
-    }
472
+	}
473 473
 
474
-    /**
475
-     * Deprecate the single message hooks for post types.
476
-     *
477
-     * @since 1.9.0
478
-     * @deprecated since 1.9.0
479
-     */
480
-    public static function deprecate_all_post_type_single_title_hooks(){
474
+	/**
475
+	 * Deprecate the single message hooks for post types.
476
+	 *
477
+	 * @since 1.9.0
478
+	 * @deprecated since 1.9.0
479
+	 */
480
+	public static function deprecate_all_post_type_single_title_hooks(){
481 481
 
482
-        if( is_singular( 'sensei_message' ) ){
482
+		if( is_singular( 'sensei_message' ) ){
483 483
 
484
-            sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' );
484
+			sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' );
485 485
 
486
-        }
486
+		}
487 487
 
488
-    }
488
+	}
489 489
 
490
-    /**
491
-     * course_single_meta function.
492
-     *
493
-     * @access public
494
-     * @return void
495
-     * @deprecated since 1.9.0
496
-     */
497
-    public static function deprecate_course_single_meta_hooks() {
490
+	/**
491
+	 * course_single_meta function.
492
+	 *
493
+	 * @access public
494
+	 * @return void
495
+	 * @deprecated since 1.9.0
496
+	 */
497
+	public static function deprecate_course_single_meta_hooks() {
498 498
 
499
-        // deprecate all these hooks
500
-        sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' );
501
-        sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' );
502
-        sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' );
503
-        sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' );
499
+		// deprecate all these hooks
500
+		sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' );
501
+		sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' );
502
+		sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' );
503
+		sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' );
504 504
 
505
-    } // End deprecate_course_single_meta_hooks
505
+	} // End deprecate_course_single_meta_hooks
506 506
 
507
-    /**
508
-     * Run the deprecated hooks on the single lesson page
509
-     * @deprecated since 1.9.0
510
-     */
511
-    public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() {
507
+	/**
508
+	 * Run the deprecated hooks on the single lesson page
509
+	 * @deprecated since 1.9.0
510
+	 */
511
+	public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() {
512 512
 
513
-        if( is_singular( 'lesson' ) ){
513
+		if( is_singular( 'lesson' ) ){
514 514
 
515
-            sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content',  get_the_ID() );
516
-            sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content',  get_the_ID() );
515
+			sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content',  get_the_ID() );
516
+			sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content',  get_the_ID() );
517 517
 
518
-        }
518
+		}
519 519
 
520
-    }// end sensei_deprecate_single_lesson_breadcrumbs_and_comments_hooks
520
+	}// end sensei_deprecate_single_lesson_breadcrumbs_and_comments_hooks
521 521
 
522
-    /**
523
-     * Deprecate the hook sensei_lesson_course_signup.
524
-     *
525
-     * The hook content will be linked directly on the recommended
526
-     * sensei_single_lesson_content_inside_after
527
-     *
528
-     * @deprecated since 1.9.0
529
-     */
530
-    public static function deprecate_sensei_lesson_course_signup_hook(){
522
+	/**
523
+	 * Deprecate the hook sensei_lesson_course_signup.
524
+	 *
525
+	 * The hook content will be linked directly on the recommended
526
+	 * sensei_single_lesson_content_inside_after
527
+	 *
528
+	 * @deprecated since 1.9.0
529
+	 */
530
+	public static function deprecate_sensei_lesson_course_signup_hook(){
531 531
 
532
-        $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true );
533
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
532
+		$lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true );
533
+		$user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
534 534
 
535
-        if(  !$user_taking_course ) {
535
+		if(  !$user_taking_course ) {
536 536
 
537
-            sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id );
537
+			sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id );
538 538
 
539
-        }
540
-    }// end deprecate_sensei_lesson_course_signup_hook
539
+		}
540
+	}// end deprecate_sensei_lesson_course_signup_hook
541 541
 
542
-    /**
543
-     * Running the deprecated hook: sensei_lesson_single_meta
544
-     *
545
-     * @since 1.9.0
546
-     * @deprecated since 1.9.0
547
-     */
548
-    public static function deprecate_sensei_lesson_single_meta_hook(){
542
+	/**
543
+	 * Running the deprecated hook: sensei_lesson_single_meta
544
+	 *
545
+	 * @since 1.9.0
546
+	 * @deprecated since 1.9.0
547
+	 */
548
+	public static function deprecate_sensei_lesson_single_meta_hook(){
549 549
 
550
-        if ( sensei_can_user_view_lesson()  ) {
550
+		if ( sensei_can_user_view_lesson()  ) {
551 551
 
552
-            sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' );
552
+			sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' );
553 553
 
554 554
 
555
-        }
555
+		}
556 556
 
557
-    }// end deprecate_sensei_lesson_single_meta_hook
557
+	}// end deprecate_sensei_lesson_single_meta_hook
558 558
 
559
-    /**
560
-     * Deprecate the sensei lesson single title hook
561
-     * @deprecated since 1.9.0
562
-     */
563
-    public static function deprecate_sensei_lesson_single_title(){
559
+	/**
560
+	 * Deprecate the sensei lesson single title hook
561
+	 * @deprecated since 1.9.0
562
+	 */
563
+	public static function deprecate_sensei_lesson_single_title(){
564 564
 
565
-        sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
565
+		sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
566 566
 
567
-    }// end deprecate_sensei_lesson_single_title
567
+	}// end deprecate_sensei_lesson_single_title
568 568
 
569
-    /**
570
-     * hook in the deperecated single main content to the lesson
571
-     * @deprecated since 1.9.0
572
-     */
573
-    public  static function deprecate_lesson_single_main_content_hook(){
569
+	/**
570
+	 * hook in the deperecated single main content to the lesson
571
+	 * @deprecated since 1.9.0
572
+	 */
573
+	public  static function deprecate_lesson_single_main_content_hook(){
574 574
 
575
-        sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' );
575
+		sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' );
576 576
 
577
-    }// end sensei_deprecate_lesson_single_main_content_hook
577
+	}// end sensei_deprecate_lesson_single_main_content_hook
578 578
 
579
-    /**
580
-     * hook in the deperecated single main content to the lesson
581
-     * @deprecated since 1.9.0
582
-     */
583
-    public  static function deprecate_lesson_image_hook(){
579
+	/**
580
+	 * hook in the deperecated single main content to the lesson
581
+	 * @deprecated since 1.9.0
582
+	 */
583
+	public  static function deprecate_lesson_image_hook(){
584 584
 
585
-        sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
585
+		sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
586 586
 
587
-    }// end sensei_deprecate_lesson_single_main_content_hook
587
+	}// end sensei_deprecate_lesson_single_main_content_hook
588 588
 
589
-    /**
590
-     * hook in the deprecated sensei_login_form hook for backwards
591
-     * compatibility
592
-     *
593
-     * @since 1.9.0
594
-     * @deprecated since 1.9.0
595
-     */
596
-    public static function deprecate_sensei_login_form_hook(){
589
+	/**
590
+	 * hook in the deprecated sensei_login_form hook for backwards
591
+	 * compatibility
592
+	 *
593
+	 * @since 1.9.0
594
+	 * @deprecated since 1.9.0
595
+	 */
596
+	public static function deprecate_sensei_login_form_hook(){
597 597
 
598
-        sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' );
598
+		sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' );
599 599
 
600
-    } // end deprecate_sensei_login_form_hook
600
+	} // end deprecate_sensei_login_form_hook
601 601
 
602
-    /**
603
-     * Fire the sensei_complete_course action.
604
-     *
605
-     * This is just a backwards compatible function to add the action
606
-     * to a template. This should not be used as the function from this
607
-     * hook will be added directly to my-courses page via one of the hooks there.
608
-     *
609
-     * @since 1.9.0
610
-     */
611
-    public static function  fire_sensei_complete_course_hook(){
602
+	/**
603
+	 * Fire the sensei_complete_course action.
604
+	 *
605
+	 * This is just a backwards compatible function to add the action
606
+	 * to a template. This should not be used as the function from this
607
+	 * hook will be added directly to my-courses page via one of the hooks there.
608
+	 *
609
+	 * @since 1.9.0
610
+	 */
611
+	public static function  fire_sensei_complete_course_hook(){
612 612
 
613
-        do_action( 'sensei_complete_course' );
613
+		do_action( 'sensei_complete_course' );
614 614
 
615
-    } //fire_sensei_complete_course_hook
615
+	} //fire_sensei_complete_course_hook
616 616
 
617
-    /**
618
-     * Fire the frontend message hook
619
-     *
620
-     * @since 1.9.0
621
-     */
622
-    public static function  fire_frontend_messages_hook(){
617
+	/**
618
+	 * Fire the frontend message hook
619
+	 *
620
+	 * @since 1.9.0
621
+	 */
622
+	public static function  fire_frontend_messages_hook(){
623 623
 
624
-        do_action( 'sensei_frontend_messages' );
624
+		do_action( 'sensei_frontend_messages' );
625 625
 
626
-    }// end sensei_complete_course_action
626
+	}// end sensei_complete_course_action
627 627
 
628
-    /**
629
-     * deprecate the sensei_before_user_course_content hook in favor
630
-     * of sensei_my_courses_content_inside_before.
631
-     *
632
-     * @deprected since 1.9.0
633
-     */
634
-    public static function  deprecate_sensei_before_user_course_content_hook(){
628
+	/**
629
+	 * deprecate the sensei_before_user_course_content hook in favor
630
+	 * of sensei_my_courses_content_inside_before.
631
+	 *
632
+	 * @deprected since 1.9.0
633
+	 */
634
+	public static function  deprecate_sensei_before_user_course_content_hook(){
635 635
 
636
-        sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() );
636
+		sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() );
637 637
 
638
-    }// deprecate_sensei_before_user_course_content_hook
638
+	}// deprecate_sensei_before_user_course_content_hook
639 639
 
640
-    /**
641
-     * deprecate the sensei_before_user_course_content hook in favor
642
-     * of sensei_my_courses_content_inside_after hook.
643
-     *
644
-     * @deprected since 1.9.0
645
-     */
646
-    public static function  deprecate_sensei_after_user_course_content_hook(){
640
+	/**
641
+	 * deprecate the sensei_before_user_course_content hook in favor
642
+	 * of sensei_my_courses_content_inside_after hook.
643
+	 *
644
+	 * @deprected since 1.9.0
645
+	 */
646
+	public static function  deprecate_sensei_after_user_course_content_hook(){
647 647
 
648
-        sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() );
648
+		sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() );
649 649
 
650
-    }// deprecate_sensei_after_user_course_content_hook
650
+	}// deprecate_sensei_after_user_course_content_hook
651 651
 
652
-    /**
653
-     * Deprecate the 2 main hooks on the archive message template
654
-     *
655
-     * @deprecated since 1.9.0
656
-     * @since 1.9.0
657
-     */
658
-    public static function deprecated_archive_message_hooks (){
659
-
660
-        sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' );
661
-        sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' );
652
+	/**
653
+	 * Deprecate the 2 main hooks on the archive message template
654
+	 *
655
+	 * @deprecated since 1.9.0
656
+	 * @since 1.9.0
657
+	 */
658
+	public static function deprecated_archive_message_hooks (){
659
+
660
+		sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' );
661
+		sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' );
662 662
 
663
-    }
663
+	}
664 664
 
665
-    /**
666
-     * Run the sensei_complete_quiz for those still hooking
667
-     * into but deprecated it.
668
-     *
669
-     * @deprecated since 1.9.0
670
-     */
671
-    public static function deprecate_sensei_complete_quiz_action(){
665
+	/**
666
+	 * Run the sensei_complete_quiz for those still hooking
667
+	 * into but deprecated it.
668
+	 *
669
+	 * @deprecated since 1.9.0
670
+	 */
671
+	public static function deprecate_sensei_complete_quiz_action(){
672 672
 
673
-        sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' );
673
+		sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' );
674 674
 
675
-    }
675
+	}
676 676
 
677
-    /**
678
-     * Run the sensei_quiz_question_type action for those still hooing into it, but depreate
679
-     * it to provide user with a better alternative.
680
-     *
681
-     * @deprecated since 1.9.0
682
-     */
683
-    public static function deprecate_sensei_quiz_question_type_action(){
677
+	/**
678
+	 * Run the sensei_quiz_question_type action for those still hooing into it, but depreate
679
+	 * it to provide user with a better alternative.
680
+	 *
681
+	 * @deprecated since 1.9.0
682
+	 */
683
+	public static function deprecate_sensei_quiz_question_type_action(){
684 684
 
685
-        // Question Type
686
-        global $sensei_question_loop;
687
-        $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID);
688
-        sensei_do_deprecated_action('sensei_quiz_question_type', '1.9.0', 'sensei_quiz_question_inside_after', $question_type);
689
-
690
-    }
685
+		// Question Type
686
+		global $sensei_question_loop;
687
+		$question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID);
688
+		sensei_do_deprecated_action('sensei_quiz_question_type', '1.9.0', 'sensei_quiz_question_inside_after', $question_type);
689
+
690
+	}
691 691
 }//end class
Please login to merge, or discard this patch.
Spacing   +154 added lines, -154 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // security check, don't load file outside WP
2
+if ( ! defined('ABSPATH')) exit; // security check, don't load file outside WP
3 3
 /**
4 4
  * Sensei Template Class
5 5
  *
@@ -20,38 +20,38 @@  discard block
 block discarded – undo
20 20
      *
21 21
      * @return void
22 22
      */
23
-    public static function get_part(  $slug, $name = ''  ){
23
+    public static function get_part($slug, $name = '') {
24 24
 
25 25
         $template = '';
26 26
         $plugin_template_url = Sensei()->template_url;
27
-        $plugin_template_path = Sensei()->plugin_path() . "/templates/";
27
+        $plugin_template_path = Sensei()->plugin_path()."/templates/";
28 28
 
29 29
         // Look in yourtheme/slug-name.php and yourtheme/sensei/slug-name.php
30
-        if ( $name ){
30
+        if ($name) {
31 31
 
32
-            $template = locate_template( array ( "{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php" ) );
32
+            $template = locate_template(array("{$slug}-{$name}.php", "{$plugin_template_url}{$slug}-{$name}.php"));
33 33
 
34 34
         }
35 35
 
36 36
         // Get default slug-name.php
37
-        if ( ! $template && $name && file_exists( $plugin_template_path . "{$slug}-{$name}.php" ) ){
37
+        if ( ! $template && $name && file_exists($plugin_template_path."{$slug}-{$name}.php")) {
38 38
 
39
-            $template = $plugin_template_path . "{$slug}-{$name}.php";
39
+            $template = $plugin_template_path."{$slug}-{$name}.php";
40 40
 
41 41
         }
42 42
 
43 43
 
44 44
         // If template file doesn't exist, look in yourtheme/slug.php and yourtheme/sensei/slug.php
45
-        if ( !$template ){
45
+        if ( ! $template) {
46 46
 
47
-            $template = locate_template( array ( "{$slug}.php", "{$plugin_template_url}{$slug}.php" ) );
47
+            $template = locate_template(array("{$slug}.php", "{$plugin_template_url}{$slug}.php"));
48 48
 
49 49
         }
50 50
 
51 51
 
52
-        if ( $template ){
52
+        if ($template) {
53 53
 
54
-            load_template( $template, false );
54
+            load_template($template, false);
55 55
 
56 56
         }
57 57
 
@@ -67,20 +67,20 @@  discard block
 block discarded – undo
67 67
      * @param string $template_path
68 68
      * @param string $default_path
69 69
      */
70
-    public static function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
70
+    public static function get_template($template_name, $args = array(), $template_path = '', $default_path = '') {
71 71
 
72
-        if ( $args && is_array($args) )
73
-            extract( $args );
72
+        if ($args && is_array($args))
73
+            extract($args);
74 74
 
75
-        $located = self::locate_template( $template_name, $template_path, $default_path );
75
+        $located = self::locate_template($template_name, $template_path, $default_path);
76 76
 
77
-        if( ! empty( $located ) ){
77
+        if ( ! empty($located)) {
78 78
 
79
-            do_action( 'sensei_before_template_part', $template_name, $template_path, $located );
79
+            do_action('sensei_before_template_part', $template_name, $template_path, $located);
80 80
 
81
-            include( $located );
81
+            include($located);
82 82
 
83
-            do_action( 'sensei_after_template_part', $template_name, $template_path, $located );
83
+            do_action('sensei_after_template_part', $template_name, $template_path, $located);
84 84
 
85 85
         }
86 86
 
@@ -97,32 +97,32 @@  discard block
 block discarded – undo
97 97
      *
98 98
      * @return mixed|void
99 99
      */
100
-    public static function locate_template( $template_name, $template_path = '', $default_path = '' ) {
100
+    public static function locate_template($template_name, $template_path = '', $default_path = '') {
101 101
 
102
-        if ( ! $template_path ) $template_path = Sensei()->template_url;
103
-        if ( ! $default_path ) $default_path = Sensei()->plugin_path() . '/templates/';
102
+        if ( ! $template_path) $template_path = Sensei()->template_url;
103
+        if ( ! $default_path) $default_path = Sensei()->plugin_path().'/templates/';
104 104
 
105 105
         // Look within passed path within the theme - this is priority
106 106
         $template = locate_template(
107 107
             array(
108
-                $template_path . $template_name,
108
+                $template_path.$template_name,
109 109
                 $template_name
110 110
             )
111 111
         );
112 112
 
113 113
         // Get default template
114
-        if ( ! $template ){
114
+        if ( ! $template) {
115 115
 
116
-            $template = $default_path . $template_name;
116
+            $template = $default_path.$template_name;
117 117
 
118 118
         }
119 119
         // return nothing for file that do not exist
120
-        if( !file_exists( $template ) ){
120
+        if ( ! file_exists($template)) {
121 121
             $template = '';
122 122
         }
123 123
 
124 124
         // Return what we found
125
-        return apply_filters( 'sensei_locate_template', $template, $template_name, $template_path );
125
+        return apply_filters('sensei_locate_template', $template, $template_name, $template_path);
126 126
 
127 127
     } // end locate
128 128
 
@@ -135,30 +135,30 @@  discard block
 block discarded – undo
135 135
      * @param string $template
136 136
      * @return string $template
137 137
      */
138
-    public static function template_loader ( $template = '' ) {
138
+    public static function template_loader($template = '') {
139 139
 
140 140
         global $wp_query, $email_template;
141 141
 
142
-        $find = array( 'woothemes-sensei.php' );
142
+        $find = array('woothemes-sensei.php');
143 143
         $file = '';
144 144
 
145
-        if ( isset( $email_template ) && $email_template ) {
145
+        if (isset($email_template) && $email_template) {
146 146
 
147
-            $file 	= 'emails/' . $email_template;
147
+            $file = 'emails/'.$email_template;
148 148
             $find[] = $file;
149
-            $find[] = Sensei()->template_url . $file;
149
+            $find[] = Sensei()->template_url.$file;
150 150
 
151
-        } elseif ( is_single() && get_post_type() == 'course' ) {
151
+        } elseif (is_single() && get_post_type() == 'course') {
152 152
 
153
-            if ( Sensei()->check_user_permissions( 'course-single' ) ) {
153
+            if (Sensei()->check_user_permissions('course-single')) {
154 154
 
155 155
                 // possible backward compatible template include if theme overrides content-single-course.php
156 156
                 // this template was removed in 1.9.0 and code all moved into the main single-course.php file
157
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-course.php', true );
157
+                self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-course.php', true);
158 158
 
159
-                $file 	= 'single-course.php';
159
+                $file = 'single-course.php';
160 160
                 $find[] = $file;
161
-                $find[] = Sensei()->template_url . $file;
161
+                $find[] = Sensei()->template_url.$file;
162 162
 
163 163
             } else {
164 164
 
@@ -167,17 +167,17 @@  discard block
 block discarded – undo
167 167
 
168 168
             } // End If Statement
169 169
 
170
-        } elseif ( is_single() && get_post_type() == 'lesson' ) {
170
+        } elseif (is_single() && get_post_type() == 'lesson') {
171 171
 
172
-            if ( Sensei()->check_user_permissions( 'lesson-single' ) ) {
172
+            if (Sensei()->check_user_permissions('lesson-single')) {
173 173
 
174 174
                 // possible backward compatible template include if theme overrides content-single-lesson.php
175 175
                 // this template was removed in 1.9.0 and code all moved into the main single-lesson.php file
176
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-lesson.php', true );
176
+                self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-lesson.php', true);
177 177
 
178
-                $file 	= 'single-lesson.php';
178
+                $file = 'single-lesson.php';
179 179
                 $find[] = $file;
180
-                $find[] = Sensei()->template_url . $file;
180
+                $find[] = Sensei()->template_url.$file;
181 181
 
182 182
             } else {
183 183
 
@@ -186,17 +186,17 @@  discard block
 block discarded – undo
186 186
 
187 187
             } // End If Statement
188 188
 
189
-        } elseif ( is_single() && get_post_type() == 'quiz' ) {
189
+        } elseif (is_single() && get_post_type() == 'quiz') {
190 190
 
191
-            if ( Sensei()->check_user_permissions( 'quiz-single' ) ) {
191
+            if (Sensei()->check_user_permissions('quiz-single')) {
192 192
 
193 193
                 // possible backward compatible template include if theme overrides content-single-quiz.php
194 194
                 // this template was removed in 1.9.0 and code all moved into the main single-quiz.php file
195
-                self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-quiz.php' , true);
195
+                self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-quiz.php', true);
196 196
 
197
-                $file 	= 'single-quiz.php';
197
+                $file = 'single-quiz.php';
198 198
                 $find[] = $file;
199
-                $find[] = Sensei()->template_url . $file;
199
+                $find[] = Sensei()->template_url.$file;
200 200
 
201 201
             } else {
202 202
 
@@ -205,76 +205,76 @@  discard block
 block discarded – undo
205 205
 
206 206
             } // End If Statement
207 207
 
208
-        } elseif ( is_single() && get_post_type() == 'sensei_message' ) {
208
+        } elseif (is_single() && get_post_type() == 'sensei_message') {
209 209
 
210 210
             // possible backward compatible template include if theme overrides content-single-message.php
211 211
             // this template was removed in 1.9.0 and code all moved into the main single-message.php file
212
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'content-single-message.php', true );
212
+            self::locate_and_load_template_overrides(Sensei()->template_url.'content-single-message.php', true);
213 213
 
214
-            $file 	= 'single-message.php';
214
+            $file = 'single-message.php';
215 215
             $find[] = $file;
216
-            $find[] = Sensei()->template_url . $file;
216
+            $find[] = Sensei()->template_url.$file;
217 217
 
218
-        } elseif ( is_post_type_archive( 'course' )
219
-                    || is_page( Sensei()->get_page_id( 'courses' ) )
220
-                    || is_tax( 'course-category' )) {
218
+        } elseif (is_post_type_archive('course')
219
+                    || is_page(Sensei()->get_page_id('courses'))
220
+                    || is_tax('course-category')) {
221 221
 
222 222
             // possible backward compatible template include if theme overrides 'taxonomy-course-category'
223 223
             // this template was removed in 1.9.0 and replaced by archive-course.php
224
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-course-category.php');
224
+            self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-course-category.php');
225 225
 
226
-            $file 	= 'archive-course.php';
226
+            $file = 'archive-course.php';
227 227
             $find[] = $file;
228
-            $find[] = Sensei()->template_url . $file;
228
+            $find[] = Sensei()->template_url.$file;
229 229
 
230
-        } elseif ( is_post_type_archive( 'sensei_message' ) ) {
230
+        } elseif (is_post_type_archive('sensei_message')) {
231 231
 
232
-            $file 	= 'archive-message.php';
232
+            $file = 'archive-message.php';
233 233
             $find[] = $file;
234
-            $find[] = Sensei()->template_url . $file;
234
+            $find[] = Sensei()->template_url.$file;
235 235
 
236
-        } elseif( is_tax( 'lesson-tag' ) ) {
236
+        } elseif (is_tax('lesson-tag')) {
237 237
 
238 238
             // possible backward compatible template include if theme overrides 'taxonomy-lesson-tag.php'
239 239
             // this template was removed in 1.9.0 and replaced by archive-lesson.php
240
-            self::locate_and_load_template_overrides( Sensei()->template_url . 'taxonomy-lesson-tag.php' );
240
+            self::locate_and_load_template_overrides(Sensei()->template_url.'taxonomy-lesson-tag.php');
241 241
 
242
-            $file 	= 'archive-lesson.php';
242
+            $file = 'archive-lesson.php';
243 243
             $find[] = $file;
244
-            $find[] = Sensei()->template_url . $file;
244
+            $find[] = Sensei()->template_url.$file;
245 245
 
246
-        } elseif ( isset( $wp_query->query_vars['learner_profile'] ) ) {
246
+        } elseif (isset($wp_query->query_vars['learner_profile'])) {
247 247
 
248 248
             // Override for sites with static home page
249 249
             $wp_query->is_home = false;
250 250
 
251
-            $file 	= 'learner-profile.php';
251
+            $file = 'learner-profile.php';
252 252
             $find[] = $file;
253
-            $find[] = Sensei()->template_url . $file;
253
+            $find[] = Sensei()->template_url.$file;
254 254
 
255
-        } elseif ( isset( $wp_query->query_vars['course_results'] ) ) {
255
+        } elseif (isset($wp_query->query_vars['course_results'])) {
256 256
 
257 257
             // Override for sites with static home page
258 258
             $wp_query->is_home = false;
259 259
 
260 260
             $file = 'course-results.php';
261 261
             $find[] = $file;
262
-            $find[] = Sensei()->template_url . $file;
262
+            $find[] = Sensei()->template_url.$file;
263 263
 
264
-        }elseif( is_author()
265
-                 && Sensei_Teacher::is_a_teacher( get_query_var('author') )
266
-                 && ! user_can( get_query_var('author'), 'manage_options' ) ){
264
+        }elseif (is_author()
265
+                 && Sensei_Teacher::is_a_teacher(get_query_var('author'))
266
+                 && ! user_can(get_query_var('author'), 'manage_options')) {
267 267
 
268 268
             $file = 'teacher-archive.php';
269 269
             $find[] = $file;
270
-            $find[] = Sensei()->template_url . $file;
270
+            $find[] = Sensei()->template_url.$file;
271 271
 
272 272
         } // Load the template file
273 273
 
274
-        if ( $file ) {
274
+        if ($file) {
275 275
 
276
-            $template = locate_template( $find );
277
-            if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
276
+            $template = locate_template($find);
277
+            if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file;
278 278
 
279 279
         } // End If Statement
280 280
 
@@ -294,18 +294,18 @@  discard block
 block discarded – undo
294 294
      *
295 295
      * @since 1.9.0
296 296
      */
297
-    public static function get_no_permission_template( ){
297
+    public static function get_no_permission_template( ) {
298 298
 
299 299
         // possible backward compatible template loading
300 300
         // this template was removed in 1.9.0 and code all moved into the no-permissions.php file
301
-        self::locate_and_load_template_overrides( Sensei()->template_url . 'content-no-permissions.php', true );
301
+        self::locate_and_load_template_overrides(Sensei()->template_url.'content-no-permissions.php', true);
302 302
 
303
-        $file 	= 'no-permissions.php';
303
+        $file = 'no-permissions.php';
304 304
         $find[] = $file;
305
-        $find[] = Sensei()->template_url . $file;
305
+        $find[] = Sensei()->template_url.$file;
306 306
 
307
-        $template = locate_template( $find );
308
-        if ( ! $template ) $template = Sensei()->plugin_path() . '/templates/' . $file;
307
+        $template = locate_template($find);
308
+        if ( ! $template) $template = Sensei()->plugin_path().'/templates/'.$file;
309 309
 
310 310
         return $template;
311 311
 
@@ -324,20 +324,20 @@  discard block
 block discarded – undo
324 324
      * @param string $template
325 325
      * @param bool $load_header_footer should the file be wrapped in between header and footer? Default: true
326 326
      */
327
-    public static function locate_and_load_template_overrides( $template = '', $load_header_footer = false ){
327
+    public static function locate_and_load_template_overrides($template = '', $load_header_footer = false) {
328 328
 
329
-        $found_template = locate_template( array( $template ) );
330
-        if( $found_template ){
329
+        $found_template = locate_template(array($template));
330
+        if ($found_template) {
331 331
 
332
-            if( $load_header_footer ){
332
+            if ($load_header_footer) {
333 333
 
334 334
                 get_sensei_header();
335
-                include( $found_template );
335
+                include($found_template);
336 336
                 get_sensei_footer();
337 337
 
338
-            }else{
338
+            } else {
339 339
 
340
-                include( $found_template );
340
+                include($found_template);
341 341
 
342 342
             }
343 343
 
@@ -354,9 +354,9 @@  discard block
 block discarded – undo
354 354
      *
355 355
      * @deprecated since 1.9.0
356 356
      */
357
-    public static function deprecated_archive_course_content_hook(){
357
+    public static function deprecated_archive_course_content_hook() {
358 358
 
359
-        sensei_do_deprecated_action( 'sensei_course_archive_main_content','1.9.0', 'sensei_loop_course_before' );
359
+        sensei_do_deprecated_action('sensei_course_archive_main_content', '1.9.0', 'sensei_loop_course_before');
360 360
 
361 361
     }// end deprecated_archive_hook
362 362
 
@@ -366,11 +366,11 @@  discard block
 block discarded – undo
366 366
      * @since 1.9.0
367 367
      * @param  WP_Post $post
368 368
      */
369
-    public static function the_title( $post ){
369
+    public static function the_title($post) {
370 370
 
371 371
         // ID passed in
372
-        if( is_numeric( $post ) ){
373
-            $post = get_post( $post );
372
+        if (is_numeric($post)) {
373
+            $post = get_post($post);
374 374
         }
375 375
 
376 376
         /**
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
          *
381 381
          * @param $title_html_tag default is 'h3'
382 382
          */
383
-        $title_html_tag = apply_filters('sensei_the_title_html_tag','h3');
383
+        $title_html_tag = apply_filters('sensei_the_title_html_tag', 'h3');
384 384
 
385 385
         /**
386 386
          * Filter the title classes
@@ -388,14 +388,14 @@  discard block
 block discarded – undo
388 388
          * @since 1.9.0
389 389
          * @param string $title_classes defaults to $post_type-title
390 390
          */
391
-        $title_classes = apply_filters('sensei_the_title_classes', $post->post_type . '-title' );
391
+        $title_classes = apply_filters('sensei_the_title_classes', $post->post_type.'-title');
392 392
 
393
-        $html= '';
394
-        $html .= '<'. $title_html_tag .' class="'. $title_classes .'" >';
395
-        $html .= '<a href="' . get_permalink( $post->ID ) . '" >';
396
-        $html .= $post->post_title ;
393
+        $html = '';
394
+        $html .= '<'.$title_html_tag.' class="'.$title_classes.'" >';
395
+        $html .= '<a href="'.get_permalink($post->ID).'" >';
396
+        $html .= $post->post_title;
397 397
         $html .= '</a>';
398
-        $html .= '</'. $title_html_tag. '>';
398
+        $html .= '</'.$title_html_tag.'>';
399 399
         echo $html;
400 400
 
401 401
     }// end the title
@@ -407,11 +407,11 @@  discard block
 block discarded – undo
407 407
      * @since 1.9.0
408 408
      * @deprecated 1.9.0
409 409
      */
410
-    public static function deprecated_single_course_inside_before_hooks(){
410
+    public static function deprecated_single_course_inside_before_hooks() {
411 411
 
412
-        sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', array( get_the_ID()) );
413
-        sensei_do_deprecated_action('sensei_course_single_title','1.9.0', 'sensei_single_course_content_inside_before' );
414
-        sensei_do_deprecated_action('sensei_course_single_meta','1.9.0', 'sensei_single_course_content_inside_before' );
412
+        sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', array(get_the_ID()));
413
+        sensei_do_deprecated_action('sensei_course_single_title', '1.9.0', 'sensei_single_course_content_inside_before');
414
+        sensei_do_deprecated_action('sensei_course_single_meta', '1.9.0', 'sensei_single_course_content_inside_before');
415 415
 
416 416
     }// end deprecated_single_course_inside_before_hooks
417 417
 
@@ -422,9 +422,9 @@  discard block
 block discarded – undo
422 422
      * @since 1.9.0
423 423
      * @deprecated 1.9.0
424 424
      */
425
-    public static function deprecate_sensei_course_single_lessons_hook(){
425
+    public static function deprecate_sensei_course_single_lessons_hook() {
426 426
 
427
-        sensei_do_deprecated_action('sensei_course_single_lessons','1.9.0', 'sensei_single_course_content_inside_after');
427
+        sensei_do_deprecated_action('sensei_course_single_lessons', '1.9.0', 'sensei_single_course_content_inside_after');
428 428
 
429 429
     }// deprecate_sensei_course_single_lessons_hook
430 430
 
@@ -436,13 +436,13 @@  discard block
 block discarded – undo
436 436
      * @since 1.9.0
437 437
      * @deprecated 1.9.0
438 438
      */
439
-    public static function deprecated_single_main_content_hook(){
439
+    public static function deprecated_single_main_content_hook() {
440 440
 
441
-            if( is_singular( 'course' ) ) {
441
+            if (is_singular('course')) {
442 442
 
443 443
                 sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_course_content_inside_before or sensei_single_course_content_inside_after');
444 444
 
445
-            } elseif( is_singular( 'message' ) ){
445
+            } elseif (is_singular('message')) {
446 446
 
447 447
                 sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_message_content_inside_before or sensei_single_message_content_inside_after');
448 448
             }
@@ -454,9 +454,9 @@  discard block
 block discarded – undo
454 454
      * @since 1.9.0
455 455
      * @deprecated since 1.9.0
456 456
      */
457
-    public static function deprecate_module_before_hook(){
457
+    public static function deprecate_module_before_hook() {
458 458
 
459
-        sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0','sensei_single_course_modules_after' );
459
+        sensei_do_deprecated_action('sensei_modules_page_before', '1.9.0', 'sensei_single_course_modules_after');
460 460
 
461 461
     }
462 462
 
@@ -465,9 +465,9 @@  discard block
 block discarded – undo
465 465
      * @since 1.9.0
466 466
      * @deprecated since 1.9.0
467 467
      */
468
-    public static function deprecate_module_after_hook(){
468
+    public static function deprecate_module_after_hook() {
469 469
 
470
-        sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0','sensei_single_course_modules_after' );
470
+        sensei_do_deprecated_action('sensei_modules_page_after', '1.9.0', 'sensei_single_course_modules_after');
471 471
 
472 472
     }
473 473
 
@@ -477,11 +477,11 @@  discard block
 block discarded – undo
477 477
      * @since 1.9.0
478 478
      * @deprecated since 1.9.0
479 479
      */
480
-    public static function deprecate_all_post_type_single_title_hooks(){
480
+    public static function deprecate_all_post_type_single_title_hooks() {
481 481
 
482
-        if( is_singular( 'sensei_message' ) ){
482
+        if (is_singular('sensei_message')) {
483 483
 
484
-            sensei_do_deprecated_action( 'sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before' );
484
+            sensei_do_deprecated_action('sensei_message_single_title', '1.9.0', 'sensei_single_message_content_inside_before');
485 485
 
486 486
         }
487 487
 
@@ -497,10 +497,10 @@  discard block
 block discarded – undo
497 497
     public static function deprecate_course_single_meta_hooks() {
498 498
 
499 499
         // deprecate all these hooks
500
-        sensei_do_deprecated_action('sensei_course_start','1.9.0', 'sensei_single_course_content_inside_before' );
501
-        sensei_do_deprecated_action('sensei_woocommerce_in_cart_message','1.9.0', 'sensei_single_course_content_inside_before' );
502
-        sensei_do_deprecated_action('sensei_course_meta','1.9.0', 'sensei_single_course_content_inside_before' );
503
-        sensei_do_deprecated_action('sensei_course_meta_video','1.9.0', 'sensei_single_course_content_inside_before' );
500
+        sensei_do_deprecated_action('sensei_course_start', '1.9.0', 'sensei_single_course_content_inside_before');
501
+        sensei_do_deprecated_action('sensei_woocommerce_in_cart_message', '1.9.0', 'sensei_single_course_content_inside_before');
502
+        sensei_do_deprecated_action('sensei_course_meta', '1.9.0', 'sensei_single_course_content_inside_before');
503
+        sensei_do_deprecated_action('sensei_course_meta_video', '1.9.0', 'sensei_single_course_content_inside_before');
504 504
 
505 505
     } // End deprecate_course_single_meta_hooks
506 506
 
@@ -510,10 +510,10 @@  discard block
 block discarded – undo
510 510
      */
511 511
     public static function deprecate_single_lesson_breadcrumbs_and_comments_hooks() {
512 512
 
513
-        if( is_singular( 'lesson' ) ){
513
+        if (is_singular('lesson')) {
514 514
 
515
-            sensei_do_deprecated_action( 'sensei_breadcrumb','1.9.0','sensei_after_main_content',  get_the_ID() );
516
-            sensei_do_deprecated_action( 'sensei_comments','1.9.0','sensei_after_main_content',  get_the_ID() );
515
+            sensei_do_deprecated_action('sensei_breadcrumb', '1.9.0', 'sensei_after_main_content', get_the_ID());
516
+            sensei_do_deprecated_action('sensei_comments', '1.9.0', 'sensei_after_main_content', get_the_ID());
517 517
 
518 518
         }
519 519
 
@@ -527,14 +527,14 @@  discard block
 block discarded – undo
527 527
      *
528 528
      * @deprecated since 1.9.0
529 529
      */
530
-    public static function deprecate_sensei_lesson_course_signup_hook(){
530
+    public static function deprecate_sensei_lesson_course_signup_hook() {
531 531
 
532
-        $lesson_course_id = get_post_meta( get_the_ID(), '_lesson_course', true );
533
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
532
+        $lesson_course_id = get_post_meta(get_the_ID(), '_lesson_course', true);
533
+        $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id());
534 534
 
535
-        if(  !$user_taking_course ) {
535
+        if ( ! $user_taking_course) {
536 536
 
537
-            sensei_do_deprecated_action( 'sensei_lesson_course_signup','1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id );
537
+            sensei_do_deprecated_action('sensei_lesson_course_signup', '1.9.0', 'sensei_single_lesson_content_inside_after', $lesson_course_id);
538 538
 
539 539
         }
540 540
     }// end deprecate_sensei_lesson_course_signup_hook
@@ -545,11 +545,11 @@  discard block
 block discarded – undo
545 545
      * @since 1.9.0
546 546
      * @deprecated since 1.9.0
547 547
      */
548
-    public static function deprecate_sensei_lesson_single_meta_hook(){
548
+    public static function deprecate_sensei_lesson_single_meta_hook() {
549 549
 
550
-        if ( sensei_can_user_view_lesson()  ) {
550
+        if (sensei_can_user_view_lesson()) {
551 551
 
552
-            sensei_do_deprecated_action( 'sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after' );
552
+            sensei_do_deprecated_action('sensei_lesson_single_meta', '1.9.0', 'sensei_single_lesson_content_inside_after');
553 553
 
554 554
 
555 555
         }
@@ -560,9 +560,9 @@  discard block
 block discarded – undo
560 560
      * Deprecate the sensei lesson single title hook
561 561
      * @deprecated since 1.9.0
562 562
      */
563
-    public static function deprecate_sensei_lesson_single_title(){
563
+    public static function deprecate_sensei_lesson_single_title() {
564 564
 
565
-        sensei_do_deprecated_action( 'sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
565
+        sensei_do_deprecated_action('sensei_lesson_single_title', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID());
566 566
 
567 567
     }// end deprecate_sensei_lesson_single_title
568 568
 
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
      * hook in the deperecated single main content to the lesson
571 571
      * @deprecated since 1.9.0
572 572
      */
573
-    public  static function deprecate_lesson_single_main_content_hook(){
573
+    public  static function deprecate_lesson_single_main_content_hook() {
574 574
 
575
-        sensei_do_deprecated_action( 'sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before' );
575
+        sensei_do_deprecated_action('sensei_single_main_content', '1.9.0', 'sensei_single_lesson_content_inside_before');
576 576
 
577 577
     }// end sensei_deprecate_lesson_single_main_content_hook
578 578
 
@@ -580,9 +580,9 @@  discard block
 block discarded – undo
580 580
      * hook in the deperecated single main content to the lesson
581 581
      * @deprecated since 1.9.0
582 582
      */
583
-    public  static function deprecate_lesson_image_hook(){
583
+    public  static function deprecate_lesson_image_hook() {
584 584
 
585
-        sensei_do_deprecated_action( 'sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID() );
585
+        sensei_do_deprecated_action('sensei_lesson_image', '1.9.0', 'sensei_single_lesson_content_inside_before', get_the_ID());
586 586
 
587 587
     }// end sensei_deprecate_lesson_single_main_content_hook
588 588
 
@@ -593,9 +593,9 @@  discard block
 block discarded – undo
593 593
      * @since 1.9.0
594 594
      * @deprecated since 1.9.0
595 595
      */
596
-    public static function deprecate_sensei_login_form_hook(){
596
+    public static function deprecate_sensei_login_form_hook() {
597 597
 
598
-        sensei_do_deprecated_action( 'sensei_login_form', '1.9.0', 'sensei_login_form_before' );
598
+        sensei_do_deprecated_action('sensei_login_form', '1.9.0', 'sensei_login_form_before');
599 599
 
600 600
     } // end deprecate_sensei_login_form_hook
601 601
 
@@ -608,9 +608,9 @@  discard block
 block discarded – undo
608 608
      *
609 609
      * @since 1.9.0
610 610
      */
611
-    public static function  fire_sensei_complete_course_hook(){
611
+    public static function  fire_sensei_complete_course_hook() {
612 612
 
613
-        do_action( 'sensei_complete_course' );
613
+        do_action('sensei_complete_course');
614 614
 
615 615
     } //fire_sensei_complete_course_hook
616 616
 
@@ -619,9 +619,9 @@  discard block
 block discarded – undo
619 619
      *
620 620
      * @since 1.9.0
621 621
      */
622
-    public static function  fire_frontend_messages_hook(){
622
+    public static function  fire_frontend_messages_hook() {
623 623
 
624
-        do_action( 'sensei_frontend_messages' );
624
+        do_action('sensei_frontend_messages');
625 625
 
626 626
     }// end sensei_complete_course_action
627 627
 
@@ -631,9 +631,9 @@  discard block
 block discarded – undo
631 631
      *
632 632
      * @deprected since 1.9.0
633 633
      */
634
-    public static function  deprecate_sensei_before_user_course_content_hook(){
634
+    public static function  deprecate_sensei_before_user_course_content_hook() {
635 635
 
636
-        sensei_do_deprecated_action( 'sensei_before_user_course_content','1.9.0', 'sensei_my_courses_content_inside_before' , wp_get_current_user() );
636
+        sensei_do_deprecated_action('sensei_before_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_before', wp_get_current_user());
637 637
 
638 638
     }// deprecate_sensei_before_user_course_content_hook
639 639
 
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
      *
644 644
      * @deprected since 1.9.0
645 645
      */
646
-    public static function  deprecate_sensei_after_user_course_content_hook(){
646
+    public static function  deprecate_sensei_after_user_course_content_hook() {
647 647
 
648
-        sensei_do_deprecated_action( 'sensei_after_user_course_content','1.9.0', 'sensei_my_courses_content_inside_after' , wp_get_current_user() );
648
+        sensei_do_deprecated_action('sensei_after_user_course_content', '1.9.0', 'sensei_my_courses_content_inside_after', wp_get_current_user());
649 649
 
650 650
     }// deprecate_sensei_after_user_course_content_hook
651 651
 
@@ -655,10 +655,10 @@  discard block
 block discarded – undo
655 655
      * @deprecated since 1.9.0
656 656
      * @since 1.9.0
657 657
      */
658
-    public static function deprecated_archive_message_hooks (){
658
+    public static function deprecated_archive_message_hooks() {
659 659
 
660
-        sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop' );
661
-        sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop' );
660
+        sensei_do_deprecated_action('sensei_message_archive_main_content', '1.9.0', 'sensei_archive_before_message_loop OR sensei_archive_after_message_loop');
661
+        sensei_do_deprecated_action('sensei_message_archive_header', '1.9.0', 'sensei_archive_before_message_loop');
662 662
 
663 663
     }
664 664
 
@@ -668,9 +668,9 @@  discard block
 block discarded – undo
668 668
      *
669 669
      * @deprecated since 1.9.0
670 670
      */
671
-    public static function deprecate_sensei_complete_quiz_action(){
671
+    public static function deprecate_sensei_complete_quiz_action() {
672 672
 
673
-        sensei_do_deprecated_action( 'sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before' );
673
+        sensei_do_deprecated_action('sensei_complete_quiz', '1.9.0', 'sensei_single_quiz_content_inside_before');
674 674
 
675 675
     }
676 676
 
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
      *
681 681
      * @deprecated since 1.9.0
682 682
      */
683
-    public static function deprecate_sensei_quiz_question_type_action(){
683
+    public static function deprecate_sensei_quiz_question_type_action() {
684 684
 
685 685
         // Question Type
686 686
         global $sensei_question_loop;
Please login to merge, or discard this patch.
includes/class-sensei-learners-main.php 3 patches
Braces   +6 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Learners Overview List Table Class
@@ -409,8 +412,7 @@  discard block
 block discarded – undo
409 412
 		if( $this->lesson_id ) {
410 413
 			$post_id = intval( $this->lesson_id );
411 414
 			$activity = 'sensei_lesson_status';
412
-		}
413
-		elseif( $this->course_id ) {
415
+		} elseif( $this->course_id ) {
414 416
 			$post_id = intval( $this->course_id );
415 417
 			$activity = 'sensei_course_status';
416 418
 		}
@@ -601,8 +603,7 @@  discard block
 block discarded – undo
601 603
 			$post_type = __( 'Course', 'woothemes-sensei' );
602 604
 			$form_post_type = 'course';
603 605
 			$form_course_id = $this->course_id;
604
-		}
605
-		elseif( $this->course_id && $this->lesson_id ) {
606
+		} elseif( $this->course_id && $this->lesson_id ) {
606 607
 			$post_title = get_the_title( $this->lesson_id );
607 608
 			$post_type = __( 'Lesson', 'woothemes-sensei' );
608 609
 			$form_post_type = 'lesson';
Please login to merge, or discard this patch.
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -205,13 +205,13 @@  discard block
 block discarded – undo
205 205
 
206 206
 	/**
207 207
 	 * Generates content for a single row of the table in the user management
208
-     * screen.
209
-     *
208
+	 * screen.
209
+	 *
210 210
 	 * @since  1.7.0
211
-     *
211
+	 *
212 212
 	 * @param object $item The current item
213
-     *
214
-     * @return void
213
+	 *
214
+	 * @return void
215 215
 	 */
216 216
 	protected function get_row_data( $item ) {
217 217
 		global $wp_version;
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 		switch ( $this->view ) {
220 220
 			case 'learners' :
221 221
 
222
-                // in this case the item passed in is actually the users activity on course of lesson
223
-                $user_activity = $item;
222
+				// in this case the item passed in is actually the users activity on course of lesson
223
+				$user_activity = $item;
224 224
 				$post_id = false;
225 225
 
226 226
 				if( $this->lesson_id ) {
@@ -239,30 +239,30 @@  discard block
 block discarded – undo
239 239
 
240 240
 				if( 'complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved ) {
241 241
 
242
-                    $status_html = '<span class="graded">' .__( 'Completed', 'woothemes-sensei' ) . '</span>';
242
+					$status_html = '<span class="graded">' .__( 'Completed', 'woothemes-sensei' ) . '</span>';
243 243
 
244 244
 				} else {
245 245
 
246
-                    $status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>';
246
+					$status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>';
247 247
 
248 248
 				}
249 249
 
250
-                $title = Sensei_Learner::get_full_name( $user_activity->user_id );
250
+				$title = Sensei_Learner::get_full_name( $user_activity->user_id );
251 251
 				$a_title = sprintf( __( 'Edit &#8220;%s&#8221;' ), $title );
252 252
 
253
-                /**
254
-                 * sensei_learners_main_column_data filter
255
-                 *
256
-                 * This filter runs on the learner management screen for a specific course.
257
-                 * It provides the learner row column details.
258
-                 *
259
-                 * @param array $columns{
260
-                 *   type string $title
261
-                 *   type string $date_started
262
-                 *   type string $course_status (completed, started etc)
263
-                 *   type html $action_buttons
264
-                 * }
265
-                 */
253
+				/**
254
+				 * sensei_learners_main_column_data filter
255
+				 *
256
+				 * This filter runs on the learner management screen for a specific course.
257
+				 * It provides the learner row column details.
258
+				 *
259
+				 * @param array $columns{
260
+				 *   type string $title
261
+				 *   type string $date_started
262
+				 *   type string $course_status (completed, started etc)
263
+				 *   type html $action_buttons
264
+				 * }
265
+				 */
266 266
 				$column_data = apply_filters( 'sensei_learners_main_column_data', array(
267 267
 						'title' => '<strong><a class="row-title" href="' . admin_url( 'user-edit.php?user_id=' . $user_activity->user_id ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>',
268 268
 						'date_started' => get_comment_meta( $user_activity->comment_ID, 'start', true),
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
 			case 'courses' :
294 294
 			default:
295
-                $course_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_course_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any' ) ) );
295
+				$course_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_course_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any' ) ) );
296 296
 				$title = get_the_title( $item );
297 297
 				$a_title = sprintf( __( 'Edit &#8220;%s&#8221;' ), $title );
298 298
 
Please login to merge, or discard this patch.
Spacing   +174 added lines, -174 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Learners Overview List Table Class
@@ -22,28 +22,28 @@  discard block
 block discarded – undo
22 22
 	 * Constructor
23 23
 	 * @since  1.6.0
24 24
 	 */
25
-	public function __construct ( $course_id = 0, $lesson_id = 0 ) {
26
-		$this->course_id = intval( $course_id );
27
-		$this->lesson_id = intval( $lesson_id );
25
+	public function __construct($course_id = 0, $lesson_id = 0) {
26
+		$this->course_id = intval($course_id);
27
+		$this->lesson_id = intval($lesson_id);
28 28
 
29
-		if( isset( $_GET['view'] ) && in_array( $_GET['view'], array( 'courses', 'lessons', 'learners' ) ) ) {
29
+		if (isset($_GET['view']) && in_array($_GET['view'], array('courses', 'lessons', 'learners'))) {
30 30
 			$this->view = $_GET['view'];
31 31
 		}
32 32
 
33 33
 		// Viewing a single lesson always sets the view to Learners
34
-		if( $this->lesson_id ) {
34
+		if ($this->lesson_id) {
35 35
 			$this->view = 'learners';
36 36
 		}
37 37
 
38 38
 		// Load Parent token into constructor
39
-		parent::__construct( 'learners_main' );
39
+		parent::__construct('learners_main');
40 40
 
41 41
 		// Actions
42
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
43
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
44
-		add_action( 'sensei_learners_extra', array( $this, 'add_learners_box' ) );
42
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
43
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
44
+		add_action('sensei_learners_extra', array($this, 'add_learners_box'));
45 45
 
46
-		add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) );
46
+		add_filter('sensei_list_table_search_button_text', array($this, 'search_button'));
47 47
 	} // End __construct()
48 48
 
49 49
 	/**
@@ -53,38 +53,38 @@  discard block
 block discarded – undo
53 53
 	 */
54 54
 	function get_columns() {
55 55
 		$columns = array();
56
-		switch( $this->view ) {
56
+		switch ($this->view) {
57 57
 			case 'learners':
58 58
 				$columns = array(
59
-					'title' => __( 'Learner', 'woothemes-sensei' ),
60
-					'date_started' => __( 'Date Started', 'woothemes-sensei' ),
61
-					'user_status' => __( 'Status', 'woothemes-sensei' ),
59
+					'title' => __('Learner', 'woothemes-sensei'),
60
+					'date_started' => __('Date Started', 'woothemes-sensei'),
61
+					'user_status' => __('Status', 'woothemes-sensei'),
62 62
 				);
63 63
 				break;
64 64
 
65 65
 			case 'lessons':
66 66
 				$columns = array(
67
-					'title' => __( 'Lesson', 'woothemes-sensei' ),
68
-					'num_learners' => __( '# Learners', 'woothemes-sensei' ),
69
-					'updated' => __( 'Last Updated', 'woothemes-sensei' ),
67
+					'title' => __('Lesson', 'woothemes-sensei'),
68
+					'num_learners' => __('# Learners', 'woothemes-sensei'),
69
+					'updated' => __('Last Updated', 'woothemes-sensei'),
70 70
 				);
71 71
 				break;
72 72
 
73 73
 			case 'courses':
74 74
 			default:
75 75
 				$columns = array(
76
-					'title' => __( 'Course', 'woothemes-sensei' ),
77
-					'num_learners' => __( '# Learners', 'woothemes-sensei' ),
78
-					'updated' => __( 'Last Updated', 'woothemes-sensei' ),
76
+					'title' => __('Course', 'woothemes-sensei'),
77
+					'num_learners' => __('# Learners', 'woothemes-sensei'),
78
+					'updated' => __('Last Updated', 'woothemes-sensei'),
79 79
 				);
80 80
 				break;
81 81
 		}
82 82
 		$columns['actions'] = '';
83 83
 		// Backwards compatible
84
-		if ( 'learners' == $this->view ) {
85
-			$columns = apply_filters( 'sensei_learners_learners_columns', $columns, $this );
84
+		if ('learners' == $this->view) {
85
+			$columns = apply_filters('sensei_learners_learners_columns', $columns, $this);
86 86
 		}
87
-		$columns = apply_filters( 'sensei_learners_default_columns', $columns, $this );
87
+		$columns = apply_filters('sensei_learners_default_columns', $columns, $this);
88 88
 		return $columns;
89 89
 	}
90 90
 
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
 	 */
96 96
 	function get_sortable_columns() {
97 97
 		$columns = array();
98
-		switch( $this->view ) {
98
+		switch ($this->view) {
99 99
 			case 'learners':
100 100
 				$columns = array(
101
-					'title' => array( 'title', false ),
101
+					'title' => array('title', false),
102 102
 				);
103 103
 				break;
104 104
 
105 105
 			case 'lessons':
106 106
 				$columns = array(
107
-					'title' => array( 'title', false ),
108
-					'updated' => array( 'post_modified', false ),
107
+					'title' => array('title', false),
108
+					'updated' => array('post_modified', false),
109 109
 				);
110 110
 				break;
111 111
 
112 112
 			default:
113 113
 				$columns = array(
114
-					'title' => array( 'title', false ),
115
-					'updated' => array( 'post_modified', false ),
114
+					'title' => array('title', false),
115
+					'updated' => array('post_modified', false),
116 116
 				);
117 117
 				break;
118 118
 		}
119 119
 		// Backwards compatible
120
-		if ( 'learners' == $this->view ) {
121
-			$columns = apply_filters( 'sensei_learners_learners_columns_sortable', $columns, $this );
120
+		if ('learners' == $this->view) {
121
+			$columns = apply_filters('sensei_learners_learners_columns_sortable', $columns, $this);
122 122
 		}
123
-		$columns = apply_filters( 'sensei_learners_default_columns_sortable', $columns, $this );
123
+		$columns = apply_filters('sensei_learners_default_columns_sortable', $columns, $this);
124 124
 		return $columns;
125 125
 	}
126 126
 
@@ -134,72 +134,72 @@  discard block
 block discarded – undo
134 134
 
135 135
 		// Handle orderby
136 136
 		$orderby = '';
137
-		if ( !empty( $_GET['orderby'] ) ) {
138
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
139
-				$orderby = esc_html( $_GET['orderby'] );
137
+		if ( ! empty($_GET['orderby'])) {
138
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
139
+				$orderby = esc_html($_GET['orderby']);
140 140
 			} // End If Statement
141 141
 		}
142 142
 
143 143
 		// Handle order
144 144
 		$order = 'DESC';
145
-		if ( !empty( $_GET['order'] ) ) {
146
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
145
+		if ( ! empty($_GET['order'])) {
146
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
147 147
 		}
148 148
 
149 149
 		// Handle category selection
150 150
 		$category = false;
151
-		if ( !empty( $_GET['course_cat'] ) ) {
152
-			$category = intval( $_GET['course_cat'] );
151
+		if ( ! empty($_GET['course_cat'])) {
152
+			$category = intval($_GET['course_cat']);
153 153
 		} // End If Statement
154 154
 
155 155
 		// Handle search
156 156
 		$search = false;
157
-		if ( !empty( $_GET['s'] ) ) {
158
-			$search = esc_html( $_GET['s'] );
157
+		if ( ! empty($_GET['s'])) {
158
+			$search = esc_html($_GET['s']);
159 159
 		} // End If Statement
160 160
 
161
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
162
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
161
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
162
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
163 163
 
164 164
 		$paged = $this->get_pagenum();
165 165
 		$offset = 0;
166
-		if ( !empty($paged) ) {
167
-			$offset = $per_page * ( $paged - 1 );
166
+		if ( ! empty($paged)) {
167
+			$offset = $per_page * ($paged - 1);
168 168
 		} // End If Statement
169 169
 
170
-		switch( $this->view ) {
170
+		switch ($this->view) {
171 171
 			case 'learners':
172
-				if ( empty($orderby) ) {
172
+				if (empty($orderby)) {
173 173
 					$orderby = '';
174 174
 				}
175
-				$this->items = $this->get_learners( compact( 'per_page', 'offset', 'orderby', 'order', 'search' ) );
175
+				$this->items = $this->get_learners(compact('per_page', 'offset', 'orderby', 'order', 'search'));
176 176
 
177 177
 			break;
178 178
 
179 179
 			case 'lessons':
180
-				if ( empty($orderby) ) {
180
+				if (empty($orderby)) {
181 181
 					$orderby = 'post_modified';
182 182
 				}
183
-				$this->items = $this->get_lessons( compact( 'per_page', 'offset', 'orderby', 'order', 'search' ) );
183
+				$this->items = $this->get_lessons(compact('per_page', 'offset', 'orderby', 'order', 'search'));
184 184
 
185 185
 			break;
186 186
 
187 187
 			default:
188
-				if ( empty($orderby) ) {
188
+				if (empty($orderby)) {
189 189
 					$orderby = 'post_modified';
190 190
 				}
191
-				$this->items = $this->get_courses( compact( 'per_page', 'offset', 'orderby', 'order', 'category', 'search' ) );
191
+				$this->items = $this->get_courses(compact('per_page', 'offset', 'orderby', 'order', 'category', 'search'));
192 192
 
193 193
 			break;
194 194
 		}
195 195
 
196 196
 		$total_items = $this->total_items;
197
-		$total_pages = ceil( $total_items / $per_page );
198
-		$this->set_pagination_args( array(
197
+		$total_pages = ceil($total_items / $per_page);
198
+		$this->set_pagination_args(array(
199 199
 			'total_items' => $total_items,
200 200
 			'total_pages' => $total_pages,
201 201
 			'per_page' => $per_page
202
-		) );
202
+		));
203 203
 
204 204
 	} // End prepare_items()
205 205
 
@@ -213,42 +213,42 @@  discard block
 block discarded – undo
213 213
      *
214 214
      * @return void
215 215
 	 */
216
-	protected function get_row_data( $item ) {
216
+	protected function get_row_data($item) {
217 217
 		global $wp_version;
218 218
 
219
-		switch ( $this->view ) {
219
+		switch ($this->view) {
220 220
 			case 'learners' :
221 221
 
222 222
                 // in this case the item passed in is actually the users activity on course of lesson
223 223
                 $user_activity = $item;
224 224
 				$post_id = false;
225 225
 
226
-				if( $this->lesson_id ) {
226
+				if ($this->lesson_id) {
227 227
 
228
-					$post_id = intval( $this->lesson_id );
229
-					$object_type = __( 'lesson', 'woothemes-sensei' );
228
+					$post_id = intval($this->lesson_id);
229
+					$object_type = __('lesson', 'woothemes-sensei');
230 230
 					$post_type = 'lesson';
231 231
 
232
-				} elseif( $this->course_id ) {
232
+				} elseif ($this->course_id) {
233 233
 
234
-					$post_id = intval( $this->course_id );
235
-					$object_type = __( 'course', 'woothemes-sensei' );
234
+					$post_id = intval($this->course_id);
235
+					$object_type = __('course', 'woothemes-sensei');
236 236
 					$post_type = 'course';
237 237
 
238 238
 				}
239 239
 
240
-				if( 'complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved ) {
240
+				if ('complete' == $user_activity->comment_approved || 'graded' == $user_activity->comment_approved || 'passed' == $user_activity->comment_approved) {
241 241
 
242
-                    $status_html = '<span class="graded">' .__( 'Completed', 'woothemes-sensei' ) . '</span>';
242
+                    $status_html = '<span class="graded">'.__('Completed', 'woothemes-sensei').'</span>';
243 243
 
244 244
 				} else {
245 245
 
246
-                    $status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>';
246
+                    $status_html = '<span class="in-progress">'.__('In Progress', 'woothemes-sensei').'</span>';
247 247
 
248 248
 				}
249 249
 
250
-                $title = Sensei_Learner::get_full_name( $user_activity->user_id );
251
-				$a_title = sprintf( __( 'Edit &#8220;%s&#8221;' ), $title );
250
+                $title = Sensei_Learner::get_full_name($user_activity->user_id);
251
+				$a_title = sprintf(__('Edit &#8220;%s&#8221;'), $title);
252 252
 
253 253
                 /**
254 254
                  * sensei_learners_main_column_data filter
@@ -263,50 +263,50 @@  discard block
 block discarded – undo
263 263
                  *   type html $action_buttons
264 264
                  * }
265 265
                  */
266
-				$column_data = apply_filters( 'sensei_learners_main_column_data', array(
267
-						'title' => '<strong><a class="row-title" href="' . admin_url( 'user-edit.php?user_id=' . $user_activity->user_id ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>',
268
-						'date_started' => get_comment_meta( $user_activity->comment_ID, 'start', true),
266
+				$column_data = apply_filters('sensei_learners_main_column_data', array(
267
+						'title' => '<strong><a class="row-title" href="'.admin_url('user-edit.php?user_id='.$user_activity->user_id).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>',
268
+						'date_started' => get_comment_meta($user_activity->comment_ID, 'start', true),
269 269
 						'user_status' => $status_html,
270
-						'actions' => '<a class="remove-learner button" data-user_id="' . $user_activity->user_id . '" data-post_id="' . $post_id . '" data-post_type="' . $post_type . '">' . sprintf( __( 'Remove from %1$s', 'woothemes-sensei' ), $object_type ) . '</a>',
271
-					), $item, $post_id, $post_type );
270
+						'actions' => '<a class="remove-learner button" data-user_id="'.$user_activity->user_id.'" data-post_id="'.$post_id.'" data-post_type="'.$post_type.'">'.sprintf(__('Remove from %1$s', 'woothemes-sensei'), $object_type).'</a>',
271
+					), $item, $post_id, $post_type);
272 272
 
273 273
 				break;
274 274
 
275 275
 			case 'lessons' :
276
-				$lesson_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_lesson_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_lesson_status', 'status' => 'any' ) ) );
277
-				$title = get_the_title( $item );
278
-				$a_title = sprintf( __( 'Edit &#8220;%s&#8221;' ), $title );
276
+				$lesson_learners = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_lesson_learners', array('post_id' => $item->ID, 'type' => 'sensei_lesson_status', 'status' => 'any')));
277
+				$title = get_the_title($item);
278
+				$a_title = sprintf(__('Edit &#8220;%s&#8221;'), $title);
279 279
 
280 280
 				$grading_action = '';
281
-				if ( get_post_meta( $item->ID, '_quiz_has_questions', true ) ) {
282
-					$grading_action = ' <a class="button" href="' . esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'lesson_id' => $item->ID, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Grading', 'woothemes-sensei' ) . '</a>';
281
+				if (get_post_meta($item->ID, '_quiz_has_questions', true)) {
282
+					$grading_action = ' <a class="button" href="'.esc_url(add_query_arg(array('page' => 'sensei_grading', 'lesson_id' => $item->ID, 'course_id' => $this->course_id), admin_url('admin.php'))).'">'.__('Grading', 'woothemes-sensei').'</a>';
283 283
 				}
284 284
 
285
-				$column_data = apply_filters( 'sensei_learners_main_column_data', array(
286
-						'title' => '<strong><a class="row-title" href="' . admin_url( 'post.php?action=edit&post=' . $item->ID ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>',
285
+				$column_data = apply_filters('sensei_learners_main_column_data', array(
286
+						'title' => '<strong><a class="row-title" href="'.admin_url('post.php?action=edit&post='.$item->ID).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>',
287 287
 						'num_learners' => $lesson_learners,
288 288
 						'updated' => $item->post_modified,
289
-						'actions' => '<a class="button" href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID, 'course_id' => $this->course_id, 'view' => 'learners' ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Manage learners', 'woothemes-sensei' ) . '</a> ' . $grading_action,
290
-					), $item, $this->course_id );
289
+						'actions' => '<a class="button" href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID, 'course_id' => $this->course_id, 'view' => 'learners'), admin_url('admin.php'))).'">'.__('Manage learners', 'woothemes-sensei').'</a> '.$grading_action,
290
+					), $item, $this->course_id);
291 291
 				break;
292 292
 
293 293
 			case 'courses' :
294 294
 			default:
295
-                $course_learners = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_learners_course_learners', array( 'post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any' ) ) );
296
-				$title = get_the_title( $item );
297
-				$a_title = sprintf( __( 'Edit &#8220;%s&#8221;' ), $title );
295
+                $course_learners = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_learners_course_learners', array('post_id' => $item->ID, 'type' => 'sensei_course_status', 'status' => 'any')));
296
+				$title = get_the_title($item);
297
+				$a_title = sprintf(__('Edit &#8220;%s&#8221;'), $title);
298 298
 
299 299
 				$grading_action = '';
300
-				if ( version_compare($wp_version, '4.1', '>=') ) {
301
-					$grading_action = ' <a class="button" href="' . esc_url( add_query_arg( array( 'page' => 'sensei_grading', 'course_id' => $item->ID ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Grading', 'woothemes-sensei' ) . '</a>';
300
+				if (version_compare($wp_version, '4.1', '>=')) {
301
+					$grading_action = ' <a class="button" href="'.esc_url(add_query_arg(array('page' => 'sensei_grading', 'course_id' => $item->ID), admin_url('admin.php'))).'">'.__('Grading', 'woothemes-sensei').'</a>';
302 302
 				}
303 303
 
304
-				$column_data = apply_filters( 'sensei_learners_main_column_data', array(
305
-						'title' => '<strong><a class="row-title" href="' . admin_url( 'post.php?action=edit&post=' . $item->ID ) . '" title="' . esc_attr( $a_title ) . '">' . $title . '</a></strong>',
304
+				$column_data = apply_filters('sensei_learners_main_column_data', array(
305
+						'title' => '<strong><a class="row-title" href="'.admin_url('post.php?action=edit&post='.$item->ID).'" title="'.esc_attr($a_title).'">'.$title.'</a></strong>',
306 306
 						'num_learners' => $course_learners,
307 307
 						'updated' => $item->post_modified,
308
-						'actions' => '<a class="button" href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $item->ID, 'view' => 'learners' ), admin_url( 'admin.php' ) ) ) . '">' . __( 'Manage learners', 'woothemes-sensei' ) . '</a> ' . $grading_action,
309
-					), $item );
308
+						'actions' => '<a class="button" href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'course_id' => $item->ID, 'view' => 'learners'), admin_url('admin.php'))).'">'.__('Manage learners', 'woothemes-sensei').'</a> '.$grading_action,
309
+					), $item);
310 310
 
311 311
 				break;
312 312
 		} // switch
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @since  1.7.0
320 320
 	 * @return array courses
321 321
 	 */
322
-	private function get_courses( $args ) {
322
+	private function get_courses($args) {
323 323
 		$course_args = array(
324 324
 			'post_type' => 'course',
325 325
 			'post_status' => 'publish',
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 			'order' => $args['order'],
330 330
 		);
331 331
 
332
-		if( $args['category'] ) {
332
+		if ($args['category']) {
333 333
 			$course_args['tax_query'][] = array(
334 334
 				'taxonomy' => 'course-category',
335 335
 				'field' => 'id',
@@ -337,11 +337,11 @@  discard block
 block discarded – undo
337 337
 			);
338 338
 		}
339 339
 
340
-		if( $args['search'] ) {
340
+		if ($args['search']) {
341 341
 			$course_args['s'] = $args['search'];
342 342
 		}
343 343
 
344
-		$courses_query = new WP_Query( apply_filters( 'sensei_learners_filter_courses', $course_args ) );
344
+		$courses_query = new WP_Query(apply_filters('sensei_learners_filter_courses', $course_args));
345 345
 
346 346
 		$this->total_items = $courses_query->found_posts;
347 347
 		return $courses_query->posts;
@@ -352,7 +352,7 @@  discard block
 block discarded – undo
352 352
 	 * @since  1.7.0
353 353
 	 * @return array lessons
354 354
 	 */
355
-	private function get_lessons( $args ) {
355
+	private function get_lessons($args) {
356 356
 		$lesson_args = array(
357 357
 			'post_type' => 'lesson',
358 358
 			'post_status' => 'publish',
@@ -362,18 +362,18 @@  discard block
 block discarded – undo
362 362
 			'order' => $args['order'],
363 363
 		);
364 364
 
365
-		if( $this->course_id ) {
365
+		if ($this->course_id) {
366 366
 			$lesson_args['meta_query'][] = array(
367 367
 				'key' => '_lesson_course',
368 368
 				'value' => $this->course_id,
369 369
 			);
370 370
 		}
371 371
 
372
-		if( $args['search'] ) {
372
+		if ($args['search']) {
373 373
 			$lesson_args['s'] = $args['search'];
374 374
 		}
375 375
 
376
-		$lessons_query = new WP_Query( apply_filters( 'sensei_learners_filter_lessons', $lesson_args ) );
376
+		$lessons_query = new WP_Query(apply_filters('sensei_learners_filter_lessons', $lesson_args));
377 377
 
378 378
 		$this->total_items = $lessons_query->found_posts;
379 379
 		return $lessons_query->posts;
@@ -384,22 +384,22 @@  discard block
 block discarded – undo
384 384
 	 * @since  1.7.0
385 385
 	 * @return array learners
386 386
 	 */
387
-	private function get_learners( $args ) {
387
+	private function get_learners($args) {
388 388
 
389 389
 		$user_ids = false;
390 390
 		$post_id = 0;
391 391
 		$activity = '';
392 392
 
393
-		if( $this->lesson_id ) {
394
-			$post_id = intval( $this->lesson_id );
393
+		if ($this->lesson_id) {
394
+			$post_id = intval($this->lesson_id);
395 395
 			$activity = 'sensei_lesson_status';
396 396
 		}
397
-		elseif( $this->course_id ) {
398
-			$post_id = intval( $this->course_id );
397
+		elseif ($this->course_id) {
398
+			$post_id = intval($this->course_id);
399 399
 			$activity = 'sensei_course_status';
400 400
 		}
401 401
 
402
-		if( ! $post_id || ! $activity ) {
402
+		if ( ! $post_id || ! $activity) {
403 403
 			$this->total_items = 0;
404 404
 			return array();
405 405
 		}
@@ -415,32 +415,32 @@  discard block
 block discarded – undo
415 415
 			);
416 416
 
417 417
 		// Searching users on statuses requires sub-selecting the statuses by user_ids
418
-		if ( $args['search'] ) {
418
+		if ($args['search']) {
419 419
 			$user_args = array(
420
-				'search' => '*' . $args['search'] . '*',
420
+				'search' => '*'.$args['search'].'*',
421 421
 				'fields' => 'ID'
422 422
 			);
423 423
 			// Filter for extending
424
-			$user_args = apply_filters( 'sensei_learners_search_users', $user_args );
425
-			if ( !empty( $user_args ) ) {
426
-				$learners_search = new WP_User_Query( $user_args );
424
+			$user_args = apply_filters('sensei_learners_search_users', $user_args);
425
+			if ( ! empty($user_args)) {
426
+				$learners_search = new WP_User_Query($user_args);
427 427
 				$activity_args['user_id'] = $learners_search->get_results();
428 428
 			}
429 429
 		}
430 430
 
431
-		$activity_args = apply_filters( 'sensei_learners_filter_users', $activity_args );
431
+		$activity_args = apply_filters('sensei_learners_filter_users', $activity_args);
432 432
 
433 433
 		// WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice
434
-		$total_learners = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
434
+		$total_learners = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0)));
435 435
 		// Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views?
436
-		if ( $total_learners < $activity_args['offset'] ) {
437
-			$new_paged = floor( $total_learners / $activity_args['number'] );
436
+		if ($total_learners < $activity_args['offset']) {
437
+			$new_paged = floor($total_learners / $activity_args['number']);
438 438
 			$activity_args['offset'] = $new_paged * $activity_args['number'];
439 439
 		}
440
-		$learners = Sensei_Utils::sensei_check_for_activity( $activity_args, true );
440
+		$learners = Sensei_Utils::sensei_check_for_activity($activity_args, true);
441 441
 		// Need to always return an array, even with only 1 item
442
-		if ( !is_array($learners) ) {
443
-			$learners = array( $learners );
442
+		if ( ! is_array($learners)) {
443
+			$learners = array($learners);
444 444
 		}
445 445
 		$this->total_items = $total_learners;
446 446
 		return $learners;
@@ -453,22 +453,22 @@  discard block
 block discarded – undo
453 453
 	 * @return void
454 454
 	 */
455 455
 	public function no_items() {
456
-		switch( $this->view ) {
456
+		switch ($this->view) {
457 457
 			case 'learners' :
458
-				$text = __( 'No learners found.', 'woothemes-sensei' );
458
+				$text = __('No learners found.', 'woothemes-sensei');
459 459
 				break;
460 460
 
461 461
 			case 'lessons' :
462
-				$text = __( 'No lessons found.', 'woothemes-sensei' );
462
+				$text = __('No lessons found.', 'woothemes-sensei');
463 463
 				break;
464 464
 
465 465
 			case 'courses':
466 466
 			case 'default':
467 467
 			default:
468
-				$text = __( 'No courses found.', 'woothemes-sensei' );
468
+				$text = __('No courses found.', 'woothemes-sensei');
469 469
 				break;
470 470
 		}
471
-		echo apply_filters( 'sensei_learners_no_items_text', $text );
471
+		echo apply_filters('sensei_learners_no_items_text', $text);
472 472
 	} // End no_items()
473 473
 
474 474
 	/**
@@ -479,40 +479,40 @@  discard block
 block discarded – undo
479 479
 	public function data_table_header() {
480 480
 
481 481
 		echo '<div class="learners-selects">';
482
-		do_action( 'sensei_learners_before_dropdown_filters' );
482
+		do_action('sensei_learners_before_dropdown_filters');
483 483
 
484 484
 		// Display Course Categories only on default view
485
-		if( 'courses' == $this->view ) {
485
+		if ('courses' == $this->view) {
486 486
 
487 487
 			$selected_cat = 0;
488
-			if ( isset( $_GET['course_cat'] ) && '' != esc_html( $_GET['course_cat'] ) ) {
489
-				$selected_cat = intval( $_GET['course_cat'] );
488
+			if (isset($_GET['course_cat']) && '' != esc_html($_GET['course_cat'])) {
489
+				$selected_cat = intval($_GET['course_cat']);
490 490
 			}
491 491
 
492
-			$cats = get_terms( 'course-category', array( 'hide_empty' => false ) );
492
+			$cats = get_terms('course-category', array('hide_empty' => false));
493 493
 
494
-			echo '<div class="select-box">' . "\n";
494
+			echo '<div class="select-box">'."\n";
495 495
 
496
-				echo '<select id="course-category-options" data-placeholder="' . __( 'Course Category', 'woothemes-sensei' ) . '" name="learners_course_cat" class="chosen_select widefat">' . "\n";
496
+				echo '<select id="course-category-options" data-placeholder="'.__('Course Category', 'woothemes-sensei').'" name="learners_course_cat" class="chosen_select widefat">'."\n";
497 497
 
498
-					echo '<option value="0">' . __( 'All Course Categories', 'woothemes-sensei' ) . '</option>' . "\n";
498
+					echo '<option value="0">'.__('All Course Categories', 'woothemes-sensei').'</option>'."\n";
499 499
 
500
-					foreach( $cats as $cat ) {
501
-						echo '<option value="' . $cat->term_id . '"' . selected( $cat->term_id, $selected_cat, false ) . '>' . $cat->name . '</option>' . "\n";
500
+					foreach ($cats as $cat) {
501
+						echo '<option value="'.$cat->term_id.'"'.selected($cat->term_id, $selected_cat, false).'>'.$cat->name.'</option>'."\n";
502 502
 					}
503 503
 
504
-				echo '</select>' . "\n";
504
+				echo '</select>'."\n";
505 505
 
506
-			echo '</div>' . "\n";
506
+			echo '</div>'."\n";
507 507
 		}
508 508
 		echo '</div><!-- /.learners-selects -->';
509 509
 
510 510
 		$menu = array();
511 511
 		// Have Course no Lesson
512
-		if( $this->course_id && ! $this->lesson_id ) {
512
+		if ($this->course_id && ! $this->lesson_id) {
513 513
 
514 514
 			$learners_class = $lessons_class = '';
515
-			switch( $this->view ) {
515
+			switch ($this->view) {
516 516
 				case 'learners':
517 517
 					$learners_class = 'current';
518 518
 				break;
@@ -531,12 +531,12 @@  discard block
 block discarded – undo
531 531
 			$learner_args['view'] = 'learners';
532 532
 			$lesson_args['view'] = 'lessons';
533 533
 
534
-			$menu['learners'] = '<a class="' . $learners_class . '" href="' . esc_url( add_query_arg( $learner_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Learners', 'woothemes-sensei' ) . '</a>';
535
-			$menu['lessons'] = '<a class="' . $lessons_class . '" href="' . esc_url( add_query_arg( $lesson_args, admin_url( 'admin.php' ) ) ) . '">' . __( 'Lessons', 'woothemes-sensei' ) . '</a>';
534
+			$menu['learners'] = '<a class="'.$learners_class.'" href="'.esc_url(add_query_arg($learner_args, admin_url('admin.php'))).'">'.__('Learners', 'woothemes-sensei').'</a>';
535
+			$menu['lessons'] = '<a class="'.$lessons_class.'" href="'.esc_url(add_query_arg($lesson_args, admin_url('admin.php'))).'">'.__('Lessons', 'woothemes-sensei').'</a>';
536 536
 
537 537
 		} 
538 538
 		// Have Course and Lesson
539
-		elseif( $this->course_id && $this->lesson_id ) {
539
+		elseif ($this->course_id && $this->lesson_id) {
540 540
 
541 541
 			$query_args = array(
542 542
 				'page' => $this->page_slug,
@@ -544,18 +544,18 @@  discard block
 block discarded – undo
544 544
 				'view' => 'lessons'
545 545
 			);
546 546
 
547
-			$course = get_the_title( $this->course_id );
547
+			$course = get_the_title($this->course_id);
548 548
 
549
-			$menu['back'] = '<a href="' . esc_url( add_query_arg( $query_args, admin_url( 'admin.php' ) ) ) . '">' . sprintf( __( '%1$sBack to %2$s%3$s', 'woothemes-sensei' ), '<em>&larr; ', $course, '</em>' ) . '</a>';
549
+			$menu['back'] = '<a href="'.esc_url(add_query_arg($query_args, admin_url('admin.php'))).'">'.sprintf(__('%1$sBack to %2$s%3$s', 'woothemes-sensei'), '<em>&larr; ', $course, '</em>').'</a>';
550 550
 		}
551
-		$menu = apply_filters( 'sensei_learners_sub_menu', $menu );
552
-		if ( !empty($menu) ) {
553
-			echo '<ul class="subsubsub">' . "\n";
554
-			foreach ( $menu as $class => $item ) {
555
-				$menu[ $class ] = "\t<li class='$class'>$item";
551
+		$menu = apply_filters('sensei_learners_sub_menu', $menu);
552
+		if ( ! empty($menu)) {
553
+			echo '<ul class="subsubsub">'."\n";
554
+			foreach ($menu as $class => $item) {
555
+				$menu[$class] = "\t<li class='$class'>$item";
556 556
 			}
557
-			echo implode( " |</li>\n", $menu ) . "</li>\n";
558
-			echo '</ul>' . "\n";
557
+			echo implode(" |</li>\n", $menu)."</li>\n";
558
+			echo '</ul>'."\n";
559 559
 		}
560 560
 
561 561
 	} // End data_table_header()
@@ -580,50 +580,50 @@  discard block
 block discarded – undo
580 580
 		$form_post_type = '';
581 581
 		$form_course_id = 0;
582 582
 		$form_lesson_id = 0;
583
-		if( $this->course_id && ! $this->lesson_id ) {
584
-			$post_title = get_the_title( $this->course_id );
585
-			$post_type = __( 'Course', 'woothemes-sensei' );
583
+		if ($this->course_id && ! $this->lesson_id) {
584
+			$post_title = get_the_title($this->course_id);
585
+			$post_type = __('Course', 'woothemes-sensei');
586 586
 			$form_post_type = 'course';
587 587
 			$form_course_id = $this->course_id;
588 588
 		}
589
-		elseif( $this->course_id && $this->lesson_id ) {
590
-			$post_title = get_the_title( $this->lesson_id );
591
-			$post_type = __( 'Lesson', 'woothemes-sensei' );
589
+		elseif ($this->course_id && $this->lesson_id) {
590
+			$post_title = get_the_title($this->lesson_id);
591
+			$post_type = __('Lesson', 'woothemes-sensei');
592 592
 			$form_post_type = 'lesson';
593 593
 			$form_course_id = $this->course_id;
594 594
 			$form_lesson_id = $this->lesson_id;
595
-			$course_title = get_the_title( $this->course_id );
595
+			$course_title = get_the_title($this->course_id);
596 596
 		}
597
-		if ( empty($form_post_type) ) {
597
+		if (empty($form_post_type)) {
598 598
 			return;
599 599
 		}
600 600
 		?>
601 601
 		<div class="postbox">
602
-			<h3><span><?php printf( __( 'Add Learner to %1$s', 'woothemes-sensei' ), $post_type ); ?></span></h3>
602
+			<h3><span><?php printf(__('Add Learner to %1$s', 'woothemes-sensei'), $post_type); ?></span></h3>
603 603
 			<div class="inside">
604 604
 				<form name="add_learner" action="" method="post">
605 605
 					<p>
606
-						<input name="add_user_id" placeholder="<?php _e( 'Find learner', 'woothemes-sensei' ) ;?>" id="add_learner_search" style="min-width:300px;" />
607
-						<?php if( 'lesson' == $form_post_type ) { ?>
608
-							<label for="add_complete_lesson"><input type="checkbox" id="add_complete_lesson" name="add_complete_lesson"  value="yes" /> <?php _e( 'Complete lesson for learner', 'woothemes-sensei' ); ?></label>
609
-						<?php } elseif( 'course' == $form_post_type ) { ?>
610
-							<label for="add_complete_course"><input type="checkbox" id="add_complete_course" name="add_complete_course"  value="yes" /> <?php _e( 'Complete course for learner', 'woothemes-sensei' ); ?></label>
606
+						<input name="add_user_id" placeholder="<?php _e('Find learner', 'woothemes-sensei'); ?>" id="add_learner_search" style="min-width:300px;" />
607
+						<?php if ('lesson' == $form_post_type) { ?>
608
+							<label for="add_complete_lesson"><input type="checkbox" id="add_complete_lesson" name="add_complete_lesson"  value="yes" /> <?php _e('Complete lesson for learner', 'woothemes-sensei'); ?></label>
609
+						<?php } elseif ('course' == $form_post_type) { ?>
610
+							<label for="add_complete_course"><input type="checkbox" id="add_complete_course" name="add_complete_course"  value="yes" /> <?php _e('Complete course for learner', 'woothemes-sensei'); ?></label>
611 611
 						<?php } ?>
612 612
 						<br/>
613
-						<span class="description"><?php _e( 'Search for a user by typing their name or username.', 'woothemes-sensei' ); ?></span>
613
+						<span class="description"><?php _e('Search for a user by typing their name or username.', 'woothemes-sensei'); ?></span>
614 614
 					</p>
615
-					<p><?php submit_button( sprintf( __( 'Add to \'%1$s\'', 'woothemes-sensei' ), $post_title ), 'primary', 'add_learner_submit', false, array() ); ?></p>
616
-					<?php if( 'lesson' == $form_post_type ) { ?>
617
-						<p><span class="description"><?php printf( __( 'Learner will also be added to the course \'%1$s\' if they are not already taking it.', 'woothemes-sensei' ), $course_title ); ?></span></p>
615
+					<p><?php submit_button(sprintf(__('Add to \'%1$s\'', 'woothemes-sensei'), $post_title), 'primary', 'add_learner_submit', false, array()); ?></p>
616
+					<?php if ('lesson' == $form_post_type) { ?>
617
+						<p><span class="description"><?php printf(__('Learner will also be added to the course \'%1$s\' if they are not already taking it.', 'woothemes-sensei'), $course_title); ?></span></p>
618 618
 					<?php } ?>
619 619
 
620 620
 					<input type="hidden" name="add_post_type" value="<?php echo $form_post_type; ?>" />
621 621
 					<input type="hidden" name="add_course_id" value="<?php echo $form_course_id; ?>" />
622 622
 					<input type="hidden" name="add_lesson_id" value="<?php echo $form_lesson_id; ?>" />
623 623
 					<?php
624
-						do_action( 'sensei_learners_add_learner_form' );
624
+						do_action('sensei_learners_add_learner_form');
625 625
 					?>
626
-					<?php wp_nonce_field( 'add_learner_to_sensei', 'add_learner_nonce' ); ?>
626
+					<?php wp_nonce_field('add_learner_to_sensei', 'add_learner_nonce'); ?>
627 627
 				</form>
628 628
 			</div>
629 629
 		</div>
@@ -635,19 +635,19 @@  discard block
 block discarded – undo
635 635
 	 * @since  1.7.0
636 636
 	 * @return string $text
637 637
 	 */
638
-	public function search_button( $text = '' ) {
638
+	public function search_button($text = '') {
639 639
 
640
-		switch( $this->view ) {
640
+		switch ($this->view) {
641 641
 			case 'learners':
642
-				$text = __( 'Search Learners', 'woothemes-sensei' );
642
+				$text = __('Search Learners', 'woothemes-sensei');
643 643
 			break;
644 644
 
645 645
 			case 'lessons':
646
-				$text = __( 'Search Lessons', 'woothemes-sensei' );
646
+				$text = __('Search Lessons', 'woothemes-sensei');
647 647
 			break;
648 648
 
649 649
 			default:
650
-				$text = __( 'Search Courses', 'woothemes-sensei' );
650
+				$text = __('Search Courses', 'woothemes-sensei');
651 651
 			break;
652 652
 		}
653 653
 
Please login to merge, or discard this patch.
includes/class-sensei-analysis-course-list-table.php 3 patches
Braces   +12 added lines, -17 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis Course List Table Class
@@ -359,31 +362,26 @@  discard block
 block discarded – undo
359 362
 							$status_class = 'graded';
360 363
 
361 364
 							$grade = __( 'No Grade', 'woothemes-sensei' );
362
-						}
363
-						elseif( 'graded' == $lesson_status->comment_approved ) {
365
+						} elseif( 'graded' == $lesson_status->comment_approved ) {
364 366
 							$status =  __( 'Graded', 'woothemes-sensei' );
365 367
 							$status_class = 'graded';
366 368
 
367 369
 							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
368
-						}
369
-						elseif( 'passed' == $lesson_status->comment_approved ) {
370
+						} elseif( 'passed' == $lesson_status->comment_approved ) {
370 371
 							$status =  __( 'Passed', 'woothemes-sensei' );
371 372
 							$status_class = 'graded';
372 373
 
373 374
 							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
374
-						}
375
-						elseif( 'failed' == $lesson_status->comment_approved ) {
375
+						} elseif( 'failed' == $lesson_status->comment_approved ) {
376 376
 							$status =  __( 'Failed', 'woothemes-sensei' );
377 377
 							$status_class = 'failed';
378 378
 
379 379
 							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
380
-						}
381
-						elseif( 'ungraded' == $lesson_status->comment_approved ) {
380
+						} elseif( 'ungraded' == $lesson_status->comment_approved ) {
382 381
 							$status =  __( 'Ungraded', 'woothemes-sensei' );
383 382
 							$status_class = 'ungraded';
384 383
 
385
-						}
386
-						elseif( 'in-progress' == $lesson_status->comment_approved ) {
384
+						} elseif( 'in-progress' == $lesson_status->comment_approved ) {
387 385
 							$status =  __( 'In Progress', 'woothemes-sensei' );
388 386
 							$user_end_date = '';
389 387
 						}
@@ -392,8 +390,7 @@  discard block
 block discarded – undo
392 390
 					// Output users data
393 391
 					if ( $this->csv_output ) {
394 392
 						$lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID );
395
-					}
396
-					else {
393
+					} else {
397 394
 						$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) );
398 395
 						$lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>';
399 396
 
@@ -448,8 +445,7 @@  discard block
 block discarded – undo
448 445
 					// Output lesson data
449 446
 					if ( $this->csv_output ) {
450 447
 						$lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID );
451
-					}
452
-					else {
448
+					} else {
453 449
 						$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) );
454 450
 						$lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>';
455 451
 
@@ -582,8 +578,7 @@  discard block
 block discarded – undo
582 578
 	public function data_table_header() {
583 579
 		if ( $this->user_id ) {
584 580
 			$learners_text = __( 'Other Learners taking this Course', 'woothemes-sensei' );
585
-		}
586
-		else {
581
+		} else {
587 582
 			$learners_text = __( 'Learners taking this Course', 'woothemes-sensei' );
588 583
 		}
589 584
 		$lessons_text = __( 'Lessons in this Course', 'woothemes-sensei' );
Please login to merge, or discard this patch.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -627,7 +627,7 @@
 block discarded – undo
627 627
 		$course = get_post( $this->course_id );
628 628
 		$report = sanitize_title( $course->post_title ) . '-' . $this->view . 's-overview';
629 629
 		if ( $this->user_id ) {
630
-            $user_name = Sensei_Learner::get_full_name( $this->user_id );
630
+			$user_name = Sensei_Learner::get_full_name( $this->user_id );
631 631
 			$report = sanitize_title( $user_name  ) . '-' . $report;
632 632
 		}
633 633
 
Please login to merge, or discard this patch.
Spacing   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Admin Analysis Course Data Table in Sensei.
@@ -20,27 +20,27 @@  discard block
 block discarded – undo
20 20
 	 * Constructor
21 21
 	 * @since  1.2.0
22 22
 	 */
23
-	public function __construct ( $course_id = 0, $user_id = 0 ) {
24
-		$this->course_id = intval( $course_id );
25
-		$this->user_id = intval( $user_id );
23
+	public function __construct($course_id = 0, $user_id = 0) {
24
+		$this->course_id = intval($course_id);
25
+		$this->user_id = intval($user_id);
26 26
 
27
-		if( isset( $_GET['view'] ) && in_array( $_GET['view'], array( 'user', 'lesson' ) ) ) {
27
+		if (isset($_GET['view']) && in_array($_GET['view'], array('user', 'lesson'))) {
28 28
 			$this->view = $_GET['view'];
29 29
 		}
30 30
 
31 31
 		// Viewing a single Learner always sets the view to Lessons
32
-		if( $this->user_id ) {
32
+		if ($this->user_id) {
33 33
 			$this->view = 'lesson';
34 34
 		}
35 35
 
36 36
 		// Load Parent token into constructor
37
-		parent::__construct( 'analysis_course' );
37
+		parent::__construct('analysis_course');
38 38
 
39 39
 		// Actions
40
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
41
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
40
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
41
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
42 42
 
43
-		add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) );
43
+		add_filter('sensei_list_table_search_button_text', array($this, 'search_button'));
44 44
 
45 45
 	} // End __construct()
46 46
 
@@ -51,45 +51,45 @@  discard block
 block discarded – undo
51 51
 	 */
52 52
 	function get_columns() {
53 53
 
54
-		switch( $this->view ) {
54
+		switch ($this->view) {
55 55
 			case 'user' :
56 56
 				$columns = array(
57
-					'title' => __( 'Learner', 'woothemes-sensei' ),
58
-					'started' => __( 'Date Started', 'woothemes-sensei' ),
59
-					'completed' => __( 'Date Completed', 'woothemes-sensei' ),
60
-					'user_status' => __( 'Status', 'woothemes-sensei' ),
61
-					'percent' => __( 'Percent Complete', 'woothemes-sensei' ),
57
+					'title' => __('Learner', 'woothemes-sensei'),
58
+					'started' => __('Date Started', 'woothemes-sensei'),
59
+					'completed' => __('Date Completed', 'woothemes-sensei'),
60
+					'user_status' => __('Status', 'woothemes-sensei'),
61
+					'percent' => __('Percent Complete', 'woothemes-sensei'),
62 62
 				);
63 63
 				break;
64 64
 
65 65
 			case 'lesson' :
66 66
 			default:
67
-				if ( $this->user_id ) {
67
+				if ($this->user_id) {
68 68
 
69 69
 					$columns = array(
70
-						'title' => __( 'Lesson', 'woothemes-sensei' ),
71
-						'started' => __( 'Date Started', 'woothemes-sensei' ),
72
-						'completed' => __( 'Date Completed', 'woothemes-sensei' ),
73
-						'user_status' => __( 'Status', 'woothemes-sensei' ),
74
-						'grade' => __( 'Grade', 'woothemes-sensei' ),
70
+						'title' => __('Lesson', 'woothemes-sensei'),
71
+						'started' => __('Date Started', 'woothemes-sensei'),
72
+						'completed' => __('Date Completed', 'woothemes-sensei'),
73
+						'user_status' => __('Status', 'woothemes-sensei'),
74
+						'grade' => __('Grade', 'woothemes-sensei'),
75 75
 					);
76 76
 
77 77
 				} else {
78 78
 
79 79
 					$columns = array(
80
-						'title' => __( 'Lesson', 'woothemes-sensei' ),
81
-						'num_learners' => __( 'Learners', 'woothemes-sensei' ),
82
-						'completions' => __( 'Completed', 'woothemes-sensei' ),
83
-						'average_grade' => __( 'Average Grade', 'woothemes-sensei' ),
80
+						'title' => __('Lesson', 'woothemes-sensei'),
81
+						'num_learners' => __('Learners', 'woothemes-sensei'),
82
+						'completions' => __('Completed', 'woothemes-sensei'),
83
+						'average_grade' => __('Average Grade', 'woothemes-sensei'),
84 84
 					);
85 85
 
86 86
 				}
87 87
 				break;
88 88
 		}
89 89
 		// Backwards compatible
90
-		$columns = apply_filters( 'sensei_analysis_course_' . $this->view . '_columns', $columns, $this );
90
+		$columns = apply_filters('sensei_analysis_course_'.$this->view.'_columns', $columns, $this);
91 91
 		// Moving forward, single filter with args
92
-		$columns = apply_filters( 'sensei_analysis_course_columns', $columns, $this );
92
+		$columns = apply_filters('sensei_analysis_course_columns', $columns, $this);
93 93
 		return $columns;
94 94
 	}
95 95
 
@@ -100,46 +100,46 @@  discard block
 block discarded – undo
100 100
 	 */
101 101
 	function get_sortable_columns() {
102 102
 
103
-		switch( $this->view ) {
103
+		switch ($this->view) {
104 104
 			case 'user' :
105 105
 				$columns = array(
106
-					'title' => array( 'title', false ),
107
-					'started' => array( 'started', false ),
108
-					'completed' => array( 'completed', false ),
109
-					'user_status' => array( 'user_status', false ),
106
+					'title' => array('title', false),
107
+					'started' => array('started', false),
108
+					'completed' => array('completed', false),
109
+					'user_status' => array('user_status', false),
110 110
 //					'grade' => array( 'grade', false ),
111
-					'percent' => array( 'percent', false )
111
+					'percent' => array('percent', false)
112 112
 				);
113 113
 				break;
114 114
 
115 115
 			case 'lesson' :
116 116
 			default:
117
-				if ( $this->user_id ) {
117
+				if ($this->user_id) {
118 118
 
119 119
 					$columns = array(
120
-						'title' => array( 'title', false ),
121
-						'started' => array( 'started', false ),
122
-						'completed' => array( 'completed', false ),
123
-						'user_status' => array( 'user_status', false ),
124
-						'grade' => array( 'grade', false ),
120
+						'title' => array('title', false),
121
+						'started' => array('started', false),
122
+						'completed' => array('completed', false),
123
+						'user_status' => array('user_status', false),
124
+						'grade' => array('grade', false),
125 125
 					);
126 126
 
127 127
 				} else {
128 128
 
129 129
 					$columns = array(
130
-						'title' => array( 'title', false ),
131
-						'num_learners' => array( 'num_learners', false ),
132
-						'completions' => array( 'completions', false ),
133
-						'average_grade' => array( 'average_grade', false )
130
+						'title' => array('title', false),
131
+						'num_learners' => array('num_learners', false),
132
+						'completions' => array('completions', false),
133
+						'average_grade' => array('average_grade', false)
134 134
 					);
135 135
 
136 136
 				}
137 137
 				break;
138 138
 		}
139 139
 		// Backwards compatible
140
-		$columns = apply_filters( 'sensei_analysis_course_' . $this->view . '_columns_sortable', $columns, $this );
140
+		$columns = apply_filters('sensei_analysis_course_'.$this->view.'_columns_sortable', $columns, $this);
141 141
 		// Moving forward, single filter with args
142
-		$columns = apply_filters( 'sensei_analysis_course_columns_sortable', $columns, $this );
142
+		$columns = apply_filters('sensei_analysis_course_columns_sortable', $columns, $this);
143 143
 		return $columns;
144 144
 	}
145 145
 
@@ -153,32 +153,32 @@  discard block
 block discarded – undo
153 153
 
154 154
 		// Handle orderby (needs work)
155 155
 		$orderby = '';
156
-		if ( !empty( $_GET['orderby'] ) ) {
157
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
158
-				$orderby = esc_html( $_GET['orderby'] );
156
+		if ( ! empty($_GET['orderby'])) {
157
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
158
+				$orderby = esc_html($_GET['orderby']);
159 159
 			} // End If Statement
160 160
 		}
161 161
 
162 162
 		// Handle order
163 163
 		$order = 'ASC';
164
-		if ( !empty( $_GET['order'] ) ) {
165
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
164
+		if ( ! empty($_GET['order'])) {
165
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
166 166
 		}
167 167
 
168 168
 		// Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids
169 169
 		$search = false;
170
-		if ( !empty( $_GET['s'] ) ) {
171
-			$search = esc_html( $_GET['s'] );
170
+		if ( ! empty($_GET['s'])) {
171
+			$search = esc_html($_GET['s']);
172 172
 		} // End If Statement
173 173
 		$this->search = $search;
174 174
 
175
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
176
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
175
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
176
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
177 177
 
178 178
 		$paged = $this->get_pagenum();
179 179
 		$offset = 0;
180
-		if ( !empty($paged) ) {
181
-			$offset = $per_page * ( $paged - 1 );
180
+		if ( ! empty($paged)) {
181
+			$offset = $per_page * ($paged - 1);
182 182
 		} // End If Statement
183 183
 
184 184
 		$args = array(
@@ -187,28 +187,28 @@  discard block
 block discarded – undo
187 187
 			'orderby' => $orderby,
188 188
 			'order' => $order,
189 189
 		);
190
-		if ( $this->search ) {
190
+		if ($this->search) {
191 191
 			$args['search'] = $this->search;
192 192
 		} // End If Statement
193 193
 
194
-		switch( $this->view ) {
194
+		switch ($this->view) {
195 195
 			case 'user' :
196
-				$this->items = $this->get_course_statuses( $args );
196
+				$this->items = $this->get_course_statuses($args);
197 197
 				break;
198 198
 
199 199
 			case 'lesson':
200 200
 			default:
201
-				$this->items = $this->get_lessons( $args );
201
+				$this->items = $this->get_lessons($args);
202 202
 				break;
203 203
 		}
204 204
 
205 205
 		$total_items = $this->total_items;
206
-		$total_pages = ceil( $total_items / $per_page );
207
-		$this->set_pagination_args( array(
206
+		$total_pages = ceil($total_items / $per_page);
207
+		$this->set_pagination_args(array(
208 208
 			'total_items' => $total_items,
209 209
 			'total_pages' => $total_pages,
210 210
 			'per_page' => $per_page
211
-		) );
211
+		));
212 212
 	}
213 213
 
214 214
 	/**
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @since  1.7.0
217 217
 	 * @return data
218 218
 	 */
219
-	public function generate_report( $report ) {
219
+	public function generate_report($report) {
220 220
 
221 221
 		$data = array();
222 222
 
@@ -224,22 +224,22 @@  discard block
 block discarded – undo
224 224
 
225 225
 		// Handle orderby
226 226
 		$orderby = '';
227
-		if ( !empty( $_GET['orderby'] ) ) {
228
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
229
-				$orderby = esc_html( $_GET['orderby'] );
227
+		if ( ! empty($_GET['orderby'])) {
228
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
229
+				$orderby = esc_html($_GET['orderby']);
230 230
 			} // End If Statement
231 231
 		}
232 232
 
233 233
 		// Handle order
234 234
 		$order = 'ASC';
235
-		if ( !empty( $_GET['order'] ) ) {
236
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
235
+		if ( ! empty($_GET['order'])) {
236
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
237 237
 		}
238 238
 
239 239
 		// Handle search
240 240
 		$search = false;
241
-		if ( !empty( $_GET['s'] ) ) {
242
-			$search = esc_html( $_GET['s'] );
241
+		if ( ! empty($_GET['s'])) {
242
+			$search = esc_html($_GET['s']);
243 243
 		} // End If Statement
244 244
 		$this->search = $search;
245 245
 
@@ -247,32 +247,32 @@  discard block
 block discarded – undo
247 247
 			'orderby' => $orderby,
248 248
 			'order' => $order,
249 249
 		);
250
-		if ( $this->search ) {
250
+		if ($this->search) {
251 251
 			$args['search'] = $this->search;
252 252
 		} // End If Statement
253 253
 
254 254
 		// Start the csv with the column headings
255 255
 		$column_headers = array();
256 256
 		$columns = $this->get_columns();
257
-		foreach( $columns AS $key => $title ) {
257
+		foreach ($columns AS $key => $title) {
258 258
 			$column_headers[] = $title;
259 259
 		}
260 260
 		$data[] = $column_headers;
261 261
 
262
-		switch( $this->view ) {
262
+		switch ($this->view) {
263 263
 			case 'user' :
264
-				$this->items = $this->get_course_statuses( $args );
264
+				$this->items = $this->get_course_statuses($args);
265 265
 				break;
266 266
 
267 267
 			case 'lesson':
268 268
 			default:
269
-				$this->items = $this->get_lessons( $args );
269
+				$this->items = $this->get_lessons($args);
270 270
 				break;
271 271
 		}
272 272
 
273 273
 		// Process each row
274
-		foreach( $this->items AS $item) {
275
-			$data[] = $this->get_row_data( $item );
274
+		foreach ($this->items AS $item) {
275
+			$data[] = $this->get_row_data($item);
276 276
 		}
277 277
 
278 278
 		return $data;
@@ -284,37 +284,37 @@  discard block
 block discarded – undo
284 284
 	 * @since  1.7.0
285 285
 	 * @param object $item The current item
286 286
 	 */
287
-	protected function get_row_data( $item ) {
287
+	protected function get_row_data($item) {
288 288
 
289
-		switch( $this->view ) {
289
+		switch ($this->view) {
290 290
 			case 'user' :
291
-				$user_start_date = get_comment_meta( $item->comment_ID, 'start', true );
291
+				$user_start_date = get_comment_meta($item->comment_ID, 'start', true);
292 292
 				$user_end_date = $item->comment_date;
293 293
 
294
-				if( 'complete' == $item->comment_approved ) {
294
+				if ('complete' == $item->comment_approved) {
295 295
 
296
-					$status =  __( 'Completed', 'woothemes-sensei' );
296
+					$status = __('Completed', 'woothemes-sensei');
297 297
 					$status_class = 'graded';
298 298
 
299 299
 				} else {
300 300
 
301
-					$status =  __( 'In Progress', 'woothemes-sensei' );
301
+					$status = __('In Progress', 'woothemes-sensei');
302 302
 					$status_class = 'in-progress';
303 303
 					$user_end_date = '';
304 304
 
305 305
 				}
306
-				$course_percent = get_comment_meta( $item->comment_ID, 'percent', true );
306
+				$course_percent = get_comment_meta($item->comment_ID, 'percent', true);
307 307
 
308 308
 				// Output users data
309
-				$user_name = Sensei_Learner::get_full_name( $item->user_id );
309
+				$user_name = Sensei_Learner::get_full_name($item->user_id);
310 310
 
311
-				if ( !$this->csv_output ) {
311
+				if ( ! $this->csv_output) {
312 312
 
313
-					$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) );
313
+					$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id), admin_url('admin.php'));
314 314
 
315
-					$user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>';
316
-					$status = sprintf( '<span class="%s">%s</span>', $status_class, $status );
317
-					if ( is_numeric($course_percent) ) {
315
+					$user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$user_name.'</a></strong>';
316
+					$status = sprintf('<span class="%s">%s</span>', $status_class, $status);
317
+					if (is_numeric($course_percent)) {
318 318
 
319 319
 						$course_percent .= '%';
320 320
 
@@ -322,19 +322,19 @@  discard block
 block discarded – undo
322 322
 
323 323
 				} // End If Statement
324 324
 
325
-				$column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $user_name,
325
+				$column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $user_name,
326 326
 												'started' => $user_start_date,
327 327
 												'completed' => $user_end_date,
328 328
 												'user_status' => $status,
329 329
 												'percent' => $course_percent,
330
-											), $item, $this );
330
+											), $item, $this);
331 331
 				break;
332 332
 
333 333
 			case 'lesson':
334 334
 			default:
335 335
 				// Displaying lessons for this Course for a specific User
336
-				if ( $this->user_id ) {
337
-					$status = __( 'Not started', 'woothemes-sensei' );
336
+				if ($this->user_id) {
337
+					$status = __('Not started', 'woothemes-sensei');
338 338
 					$user_start_date = $user_end_date = $status_class = $grade = '';
339 339
 
340 340
 					$lesson_args = array(
@@ -343,66 +343,66 @@  discard block
 block discarded – undo
343 343
 							'type' => 'sensei_lesson_status',
344 344
 							'status' => 'any',
345 345
 						);
346
-					$lesson_status = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_course_user_lesson', $lesson_args, $item, $this->user_id ), true );
346
+					$lesson_status = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_course_user_lesson', $lesson_args, $item, $this->user_id), true);
347 347
 
348
-					if ( !empty($lesson_status) ) {
349
-						$user_start_date = get_comment_meta( $lesson_status->comment_ID, 'start', true );
348
+					if ( ! empty($lesson_status)) {
349
+						$user_start_date = get_comment_meta($lesson_status->comment_ID, 'start', true);
350 350
 						$user_end_date = $lesson_status->comment_date;
351 351
 
352
-						if( 'complete' == $lesson_status->comment_approved ) {
353
-							$status = __( 'Completed', 'woothemes-sensei' );
352
+						if ('complete' == $lesson_status->comment_approved) {
353
+							$status = __('Completed', 'woothemes-sensei');
354 354
 							$status_class = 'graded';
355 355
 
356
-							$grade = __( 'No Grade', 'woothemes-sensei' );
356
+							$grade = __('No Grade', 'woothemes-sensei');
357 357
 						}
358
-						elseif( 'graded' == $lesson_status->comment_approved ) {
359
-							$status =  __( 'Graded', 'woothemes-sensei' );
358
+						elseif ('graded' == $lesson_status->comment_approved) {
359
+							$status = __('Graded', 'woothemes-sensei');
360 360
 							$status_class = 'graded';
361 361
 
362
-							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
362
+							$grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
363 363
 						}
364
-						elseif( 'passed' == $lesson_status->comment_approved ) {
365
-							$status =  __( 'Passed', 'woothemes-sensei' );
364
+						elseif ('passed' == $lesson_status->comment_approved) {
365
+							$status = __('Passed', 'woothemes-sensei');
366 366
 							$status_class = 'graded';
367 367
 
368
-							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
368
+							$grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
369 369
 						}
370
-						elseif( 'failed' == $lesson_status->comment_approved ) {
371
-							$status =  __( 'Failed', 'woothemes-sensei' );
370
+						elseif ('failed' == $lesson_status->comment_approved) {
371
+							$status = __('Failed', 'woothemes-sensei');
372 372
 							$status_class = 'failed';
373 373
 
374
-							$grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true);
374
+							$grade = get_comment_meta($lesson_status->comment_ID, 'grade', true);
375 375
 						}
376
-						elseif( 'ungraded' == $lesson_status->comment_approved ) {
377
-							$status =  __( 'Ungraded', 'woothemes-sensei' );
376
+						elseif ('ungraded' == $lesson_status->comment_approved) {
377
+							$status = __('Ungraded', 'woothemes-sensei');
378 378
 							$status_class = 'ungraded';
379 379
 
380 380
 						}
381
-						elseif( 'in-progress' == $lesson_status->comment_approved ) {
382
-							$status =  __( 'In Progress', 'woothemes-sensei' );
381
+						elseif ('in-progress' == $lesson_status->comment_approved) {
382
+							$status = __('In Progress', 'woothemes-sensei');
383 383
 							$user_end_date = '';
384 384
 						}
385 385
 					} // END lesson_status
386 386
 
387 387
 					// Output users data
388
-					if ( $this->csv_output ) {
389
-						$lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID );
388
+					if ($this->csv_output) {
389
+						$lesson_title = apply_filters('the_title', $item->post_title, $item->ID);
390 390
 					}
391 391
 					else {
392
-						$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) );
393
-						$lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>';
392
+						$url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php'));
393
+						$lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>';
394 394
 
395
-						$status = sprintf( '<span class="%s">%s</span>', $status_class, $status );
396
-						if ( is_numeric($grade) ) {
395
+						$status = sprintf('<span class="%s">%s</span>', $status_class, $status);
396
+						if (is_numeric($grade)) {
397 397
 							$grade .= '%';
398 398
 						}
399 399
 					} // End If Statement
400
-					$column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $lesson_title,
400
+					$column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $lesson_title,
401 401
 													'started' => $user_start_date,
402 402
 													'completed' => $user_end_date,
403 403
 													'user_status' => $status,
404 404
 													'grade' => $grade,
405
-												), $item, $this );
405
+												), $item, $this);
406 406
 				}
407 407
 				// Display lessons for this Course regardless of users
408 408
 				else {
@@ -412,51 +412,51 @@  discard block
 block discarded – undo
412 412
 							'type' => 'sensei_lesson_status',
413 413
 							'status' => 'any',
414 414
 						);
415
-					$lesson_students = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_learners', $lesson_args, $item ) );
415
+					$lesson_students = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_learners', $lesson_args, $item));
416 416
 
417 417
 					// Get Course Completions
418 418
 					$lesson_args = array(
419 419
 							'post_id' => $item->ID,
420 420
 							'type' => 'sensei_lesson_status',
421
-							'status' => array( 'complete', 'graded', 'passed', 'failed' ),
421
+							'status' => array('complete', 'graded', 'passed', 'failed'),
422 422
 							'count' => true,
423 423
 						);
424
-					$lesson_completions = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_completions', $lesson_args, $item ) );
424
+					$lesson_completions = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_completions', $lesson_args, $item));
425 425
 
426 426
 					$lesson_average_grade = __('n/a', 'woothemes-sensei');
427
-					if ( false != get_post_meta($item->ID, '_quiz_has_questions', true) ) {
427
+					if (false != get_post_meta($item->ID, '_quiz_has_questions', true)) {
428 428
 						// Get Percent Complete
429 429
 						$grade_args = array(
430 430
 								'post_id' => $item->ID,
431 431
 								'type' => 'sensei_lesson_status',
432
-								'status' => array( 'graded', 'passed', 'failed' ),
432
+								'status' => array('graded', 'passed', 'failed'),
433 433
 								'meta_key' => 'grade',
434 434
 							);
435
-						add_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) );
436
-						$lesson_grades = Sensei_Utils::sensei_check_for_activity( apply_filters( 'sensei_analysis_lesson_grades', $grade_args, $item ), true );
437
-						remove_filter( 'comments_clauses', array( 'WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter' ) );
435
+						add_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter'));
436
+						$lesson_grades = Sensei_Utils::sensei_check_for_activity(apply_filters('sensei_analysis_lesson_grades', $grade_args, $item), true);
437
+						remove_filter('comments_clauses', array('WooThemes_Sensei_Utils', 'comment_total_sum_meta_value_filter'));
438 438
 
439
-						$grade_count = !empty( $lesson_grades->total ) ? $lesson_grades->total : 1;
440
-						$grade_total = !empty( $lesson_grades->meta_sum ) ? doubleval( $lesson_grades->meta_sum ) : 0;
441
-						$lesson_average_grade = abs( round( doubleval( $grade_total / $grade_count ), 2 ) );
439
+						$grade_count = ! empty($lesson_grades->total) ? $lesson_grades->total : 1;
440
+						$grade_total = ! empty($lesson_grades->meta_sum) ? doubleval($lesson_grades->meta_sum) : 0;
441
+						$lesson_average_grade = abs(round(doubleval($grade_total / $grade_count), 2));
442 442
 					}
443 443
 					// Output lesson data
444
-					if ( $this->csv_output ) {
445
-						$lesson_title = apply_filters( 'the_title', $item->post_title, $item->ID );
444
+					if ($this->csv_output) {
445
+						$lesson_title = apply_filters('the_title', $item->post_title, $item->ID);
446 446
 					}
447 447
 					else {
448
-						$url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->ID ), admin_url( 'admin.php' ) );
449
-						$lesson_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . apply_filters( 'the_title', $item->post_title, $item->ID ) . '</a></strong>';
448
+						$url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->ID), admin_url('admin.php'));
449
+						$lesson_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.apply_filters('the_title', $item->post_title, $item->ID).'</a></strong>';
450 450
 
451
-						if ( is_numeric( $lesson_average_grade ) ) {
451
+						if (is_numeric($lesson_average_grade)) {
452 452
 							$lesson_average_grade .= '%';
453 453
 						}
454 454
 					} // End If Statement
455
-					$column_data = apply_filters( 'sensei_analysis_course_column_data', array( 'title' => $lesson_title,
455
+					$column_data = apply_filters('sensei_analysis_course_column_data', array('title' => $lesson_title,
456 456
 													'num_learners' => $lesson_students,
457 457
 													'completions' => $lesson_completions,
458 458
 													'average_grade' => $lesson_average_grade,
459
-												), $item, $this );
459
+												), $item, $this);
460 460
 				} // END if
461 461
 				break;
462 462
 		} // END switch
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 	 * @since  1.7.0
470 470
 	 * @return array statuses
471 471
 	 */
472
-	private function get_course_statuses( $args ) {
472
+	private function get_course_statuses($args) {
473 473
 
474 474
 		$activity_args = array(
475 475
 				'post_id' => $this->course_id,
@@ -482,34 +482,34 @@  discard block
 block discarded – undo
482 482
 			);
483 483
 
484 484
 		// Searching users on statuses requires sub-selecting the statuses by user_ids
485
-		if ( $this->search ) {
485
+		if ($this->search) {
486 486
 			$user_args = array(
487
-				'search' => '*' . $this->search . '*',
487
+				'search' => '*'.$this->search.'*',
488 488
 				'fields' => 'ID',
489 489
 			);
490 490
 			// Filter for extending
491
-			$user_args = apply_filters( 'sensei_analysis_course_search_users', $user_args );
492
-			if ( !empty( $user_args ) ) {
493
-				$learners_search = new WP_User_Query( $user_args );
491
+			$user_args = apply_filters('sensei_analysis_course_search_users', $user_args);
492
+			if ( ! empty($user_args)) {
493
+				$learners_search = new WP_User_Query($user_args);
494 494
 				// Store for reuse on counts
495 495
 				$activity_args['user_id'] = (array) $learners_search->get_results();
496 496
 			}
497 497
 		} // End If Statement
498 498
 
499
-		$activity_args = apply_filters( 'sensei_analysis_course_filter_statuses', $activity_args );
499
+		$activity_args = apply_filters('sensei_analysis_course_filter_statuses', $activity_args);
500 500
 
501 501
 		// WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice
502
-		$this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
502
+		$this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0)));
503 503
 
504 504
 		// Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views?
505
-		if ( $this->total_items < $activity_args['offset'] ) {
506
-			$new_paged = floor( $this->total_items / $activity_args['number'] );
505
+		if ($this->total_items < $activity_args['offset']) {
506
+			$new_paged = floor($this->total_items / $activity_args['number']);
507 507
 			$activity_args['offset'] = $new_paged * $activity_args['number'];
508 508
 		}
509
-		$statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true );
509
+		$statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true);
510 510
 		// Need to always return an array, even with only 1 item
511
-		if ( !is_array($statuses) ) {
512
-			$statuses = array( $statuses );
511
+		if ( ! is_array($statuses)) {
512
+			$statuses = array($statuses);
513 513
 		}
514 514
 		return $statuses;
515 515
 	} // End get_course_statuses()
@@ -519,32 +519,32 @@  discard block
 block discarded – undo
519 519
 	 * @since  1.7.0
520 520
 	 * @return array statuses
521 521
 	 */
522
-	private function get_lessons( $args ) {
522
+	private function get_lessons($args) {
523 523
 
524
-		$lessons_args = array( 'post_type'         => 'lesson',
524
+		$lessons_args = array('post_type'         => 'lesson',
525 525
 							'posts_per_page'      => $args['number'],
526 526
 							'offset'              => $args['offset'],
527
-							'meta_key'            => '_order_' . $this->course_id,
527
+							'meta_key'            => '_order_'.$this->course_id,
528 528
 //							'orderby'             => $args['orderby'],
529 529
 							'order'               => $args['order'],
530 530
 							'meta_query'          => array(
531 531
 								array(
532 532
 									'key' => '_lesson_course',
533
-									'value' => intval( $this->course_id ),
533
+									'value' => intval($this->course_id),
534 534
 								),
535 535
 							),
536 536
 							'post_status'         => array('publish', 'private'),
537 537
 							'suppress_filters'    => 0
538 538
 							);
539
-		if ( $this->search ) {
539
+		if ($this->search) {
540 540
 			$lessons_args['s'] = $this->search;
541 541
 		}
542
-		if ( $this->csv_output ) {
542
+		if ($this->csv_output) {
543 543
 			$lessons_args['posts_per_page'] = '-1';
544 544
 		}
545 545
 
546 546
 		// Using WP_Query as get_posts() doesn't support 'found_posts'
547
-		$lessons_query = new WP_Query( apply_filters( 'sensei_analysis_course_filter_lessons', $lessons_args ) );
547
+		$lessons_query = new WP_Query(apply_filters('sensei_analysis_course_filter_lessons', $lessons_args));
548 548
 		$this->total_items = $lessons_query->found_posts;
549 549
 		return $lessons_query->posts;
550 550
 	} // End get_lessons()
@@ -556,17 +556,17 @@  discard block
 block discarded – undo
556 556
 	 * @return void
557 557
 	 */
558 558
 	public function no_items() {
559
-		switch( $this->view ) {
559
+		switch ($this->view) {
560 560
 			case 'user' :
561
-				$text = __( 'No learners found.', 'woothemes-sensei' );
561
+				$text = __('No learners found.', 'woothemes-sensei');
562 562
 				break;
563 563
 
564 564
 			case 'lesson':
565 565
 			default:
566
-				$text = __( 'No lessons found.', 'woothemes-sensei' );
566
+				$text = __('No lessons found.', 'woothemes-sensei');
567 567
 				break;
568 568
 		}
569
-		echo apply_filters( 'sensei_analysis_course_no_items_text', $text );
569
+		echo apply_filters('sensei_analysis_course_no_items_text', $text);
570 570
 	} // End no_items()
571 571
 
572 572
 	/**
@@ -575,25 +575,25 @@  discard block
 block discarded – undo
575 575
 	 * @return void
576 576
 	 */
577 577
 	public function data_table_header() {
578
-		if ( $this->user_id ) {
579
-			$learners_text = __( 'Other Learners taking this Course', 'woothemes-sensei' );
578
+		if ($this->user_id) {
579
+			$learners_text = __('Other Learners taking this Course', 'woothemes-sensei');
580 580
 		}
581 581
 		else {
582
-			$learners_text = __( 'Learners taking this Course', 'woothemes-sensei' );
582
+			$learners_text = __('Learners taking this Course', 'woothemes-sensei');
583 583
 		}
584
-		$lessons_text = __( 'Lessons in this Course', 'woothemes-sensei' );
584
+		$lessons_text = __('Lessons in this Course', 'woothemes-sensei');
585 585
 
586 586
 		$url_args = array(
587 587
 			'page' => $this->page_slug,
588 588
 			'course_id' => $this->course_id,
589 589
 		);
590
-		$learners_url = esc_url( add_query_arg( array_merge( $url_args, array( 'view' => 'user' ) ), admin_url( 'admin.php' ) ) );
591
-		$lessons_url = esc_url( add_query_arg( array_merge( $url_args, array( 'view' => 'lesson' ) ), admin_url( 'admin.php' ) ) );
590
+		$learners_url = esc_url(add_query_arg(array_merge($url_args, array('view' => 'user')), admin_url('admin.php')));
591
+		$lessons_url = esc_url(add_query_arg(array_merge($url_args, array('view' => 'lesson')), admin_url('admin.php')));
592 592
 
593 593
 		$learners_class = $lessons_class = '';
594 594
 
595 595
 		$menu = array();
596
-		switch( $this->view ) {
596
+		switch ($this->view) {
597 597
 			case 'user' :
598 598
 				$learners_class = 'current';
599 599
 				break;
@@ -603,17 +603,17 @@  discard block
 block discarded – undo
603 603
 				$lessons_class = 'current';
604 604
 				break;
605 605
 		}
606
-		$menu['lesson'] = sprintf( '<a href="%s" class="%s">%s</a>', $lessons_url, $lessons_class, $lessons_text );
607
-		$menu['user'] = sprintf( '<a href="%s" class="%s">%s</a>', $learners_url, $learners_class, $learners_text );
608
-
609
-		$menu = apply_filters( 'sensei_analysis_course_sub_menu', $menu );
610
-		if ( !empty($menu) ) {
611
-			echo '<ul class="subsubsub">' . "\n";
612
-			foreach ( $menu as $class => $item ) {
613
-				$menu[ $class ] = "\t<li class='$class'>$item";
606
+		$menu['lesson'] = sprintf('<a href="%s" class="%s">%s</a>', $lessons_url, $lessons_class, $lessons_text);
607
+		$menu['user'] = sprintf('<a href="%s" class="%s">%s</a>', $learners_url, $learners_class, $learners_text);
608
+
609
+		$menu = apply_filters('sensei_analysis_course_sub_menu', $menu);
610
+		if ( ! empty($menu)) {
611
+			echo '<ul class="subsubsub">'."\n";
612
+			foreach ($menu as $class => $item) {
613
+				$menu[$class] = "\t<li class='$class'>$item";
614 614
 			}
615
-			echo implode( " |</li>\n", $menu ) . "</li>\n";
616
-			echo '</ul>' . "\n";
615
+			echo implode(" |</li>\n", $menu)."</li>\n";
616
+			echo '</ul>'."\n";
617 617
 		}
618 618
 	} // End data_table_header()
619 619
 
@@ -624,19 +624,19 @@  discard block
 block discarded – undo
624 624
 	 */
625 625
 	public function data_table_footer() {
626 626
 
627
-		$course = get_post( $this->course_id );
628
-		$report = sanitize_title( $course->post_title ) . '-' . $this->view . 's-overview';
629
-		if ( $this->user_id ) {
630
-            $user_name = Sensei_Learner::get_full_name( $this->user_id );
631
-			$report = sanitize_title( $user_name  ) . '-' . $report;
627
+		$course = get_post($this->course_id);
628
+		$report = sanitize_title($course->post_title).'-'.$this->view.'s-overview';
629
+		if ($this->user_id) {
630
+            $user_name = Sensei_Learner::get_full_name($this->user_id);
631
+			$report = sanitize_title($user_name).'-'.$report;
632 632
 		}
633 633
 
634
-		$url_args = array( 'page' => $this->page_slug, 'course_id' => $this->course_id, 'view' => $this->view, 'sensei_report_download' => $report );
635
-		if ( $this->user_id ) {
634
+		$url_args = array('page' => $this->page_slug, 'course_id' => $this->course_id, 'view' => $this->view, 'sensei_report_download' => $report);
635
+		if ($this->user_id) {
636 636
 			$url_args['user_id'] = $this->user_id;
637 637
 		}
638
-		$url =  add_query_arg( $url_args, admin_url( 'admin.php' ) );
639
-		echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>';
638
+		$url = add_query_arg($url_args, admin_url('admin.php'));
639
+		echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>';
640 640
 	} // End data_table_footer()
641 641
 
642 642
 	/**
@@ -644,15 +644,15 @@  discard block
 block discarded – undo
644 644
 	 * @since  1.7.0
645 645
 	 * @return string $text
646 646
 	 */
647
-	public function search_button( $text = '' ) {
648
-		switch( $this->view ) {
647
+	public function search_button($text = '') {
648
+		switch ($this->view) {
649 649
 			case 'user':
650
-				$text = __( 'Search Learners', 'woothemes-sensei' );
650
+				$text = __('Search Learners', 'woothemes-sensei');
651 651
 			break;
652 652
 
653 653
 			case 'lesson':
654 654
 			default:
655
-				$text = __( 'Search Lessons', 'woothemes-sensei' );
655
+				$text = __('Search Lessons', 'woothemes-sensei');
656 656
 			break;
657 657
 		} // End Switch Statement
658 658
 
Please login to merge, or discard this patch.
includes/class-sensei-updates.php 4 patches
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 								'1.7.2' => array( 	'auto' 		=> array( 'index_comment_status_field' => array( 'title' => __( 'Add database index to comment statuses', 'woothemes-sensei' ), 'desc' => __( 'This indexes the comment statuses in the database, which will speed up all Sensei activity queries.', 'woothemes-sensei' ) ), ),
71 71
 													/*'manual' 		=> array( 'remove_legacy_comments' => array( 'title' => __( 'Remove legacy Sensei activity types', 'woothemes-sensei' ), 'desc' => __( 'This removes all legacy (pre-1.7) Sensei activity types - only run this update once the update to v1.7 is complete and everything is stable.', 'woothemes-sensei' ) ) )*/
72 72
 												),
73
-                                '1.8.0' => array(   'auto' => array( 'enhance_teacher_role' => array( 'title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.' ), ),
74
-                            						'manual' 	=> array()
75
-                    							),
73
+								'1.8.0' => array(   'auto' => array( 'enhance_teacher_role' => array( 'title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.' ), ),
74
+													'manual' 	=> array()
75
+												),
76 76
 							);
77 77
 
78 78
 		$this->updates = apply_filters( 'sensei_upgrade_functions', $this->updates, $this->updates );
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
 				} // End For Loop
330 330
 			} // End For Loop
331 331
 
332
-            $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
332
+			$this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
333 333
 			update_option( $this->token . '-upgrades', $this->updates_run );
334 334
 			return true;
335 335
 
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 	 */
447 447
 	private function set_update_run( $update ) {
448 448
 		array_push( $this->updates_run, $update );
449
-        $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
449
+		$this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
450 450
 		update_option( $this->token . '-upgrades', $this->updates_run );
451 451
 	}
452 452
 
@@ -918,11 +918,11 @@  discard block
 block discarded – undo
918 918
 				update_post_meta( $lesson->ID, '_order_' . $course_id, 0 );
919 919
 			}
920 920
 
921
-            $module = Sensei()->modules->get_lesson_module( $lesson->ID );
921
+			$module = Sensei()->modules->get_lesson_module( $lesson->ID );
922 922
 
923
-            if( $module ) {
924
-                update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 );
925
-            }
923
+			if( $module ) {
924
+				update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 );
925
+			}
926 926
 
927 927
 		}
928 928
 
@@ -1732,22 +1732,22 @@  discard block
 block discarded – undo
1732 1732
 
1733 1733
 	}
1734 1734
 
1735
-     /**
1736
-     * WooThemes_Sensei_Updates::enhance_teacher_role
1737
-     *
1738
-     * This runs the update to create the teacher role
1739
-     * @access public
1740
-     * @since 1.8.0
1741
-     * @return bool;
1742
-     */
1743
-    public  function enhance_teacher_role ( ) {
1744
-
1745
-        require_once('class-sensei-teacher.php');
1746
-        $teacher = new Sensei_Teacher();
1747
-        $teacher->create_role();
1748
-        return true;
1749
-
1750
-    }// end enhance_teacher_role
1735
+	 /**
1736
+	  * WooThemes_Sensei_Updates::enhance_teacher_role
1737
+	  *
1738
+	  * This runs the update to create the teacher role
1739
+	  * @access public
1740
+	  * @since 1.8.0
1741
+	  * @return bool;
1742
+	  */
1743
+	public  function enhance_teacher_role ( ) {
1744
+
1745
+		require_once('class-sensei-teacher.php');
1746
+		$teacher = new Sensei_Teacher();
1747
+		$teacher->create_role();
1748
+		return true;
1749
+
1750
+	}// end enhance_teacher_role
1751 1751
 
1752 1752
 } // End Class
1753 1753
 
Please login to merge, or discard this patch.
Braces   +44 added lines, -26 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Updates Class
@@ -769,9 +772,15 @@  discard block
 block discarded – undo
769 772
 		$all_activity = get_comments( array( 'status' => 'approve' ) );
770 773
 		$activity_count = array();
771 774
 		foreach( $all_activity as $activity ) {
772
-			if( '' == $activity->comment_type ) continue;
773
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
774
-			if( 0 == $activity->user_id ) continue;
775
+			if( '' == $activity->comment_type ) {
776
+				continue;
777
+			}
778
+			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) {
779
+				continue;
780
+			}
781
+			if( 0 == $activity->user_id ) {
782
+				continue;
783
+			}
775 784
 			$activity_count[] = $activity->comment_ID;
776 785
 		}
777 786
 
@@ -784,9 +793,15 @@  discard block
 block discarded – undo
784 793
 		$activities = get_comments( $args );
785 794
 
786 795
 		foreach( $activities as $activity ) {
787
-			if( '' == $activity->comment_type ) continue;
788
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
789
-			if( 0 == $activity->user_id ) continue;
796
+			if( '' == $activity->comment_type ) {
797
+				continue;
798
+			}
799
+			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) {
800
+				continue;
801
+			}
802
+			if( 0 == $activity->user_id ) {
803
+				continue;
804
+			}
790 805
 
791 806
 			$user_exists = get_userdata( $activity->user_id );
792 807
 
@@ -845,7 +860,9 @@  discard block
 block discarded – undo
845 860
 
846 861
 		foreach( $questions as $question ) {
847 862
 
848
-			if( ! isset( $question->ID ) ) continue;
863
+			if( ! isset( $question->ID ) ) {
864
+				continue;
865
+			}
849 866
 
850 867
 			$quiz_id = get_post_meta( $question->ID, '_quiz_id', true );
851 868
 
@@ -882,7 +899,9 @@  discard block
 block discarded – undo
882 899
 
883 900
 		foreach( $quizzes as $quiz ) {
884 901
 
885
-			if( ! isset( $quiz->ID ) ) continue;
902
+			if( ! isset( $quiz->ID ) ) {
903
+				continue;
904
+			}
886 905
 
887 906
 			if( isset( $lesson_completion ) && 'passed' == $lesson_completion ) {
888 907
 				update_post_meta( $quiz->ID, '_pass_required', 'on' );
@@ -910,7 +929,9 @@  discard block
 block discarded – undo
910 929
 
911 930
 		foreach( $lessons as $lesson ) {
912 931
 
913
-			if( ! isset( $lesson->ID ) ) continue;
932
+			if( ! isset( $lesson->ID ) ) {
933
+				continue;
934
+			}
914 935
 
915 936
 			$course_id = get_post_meta( $lesson->ID, '_lesson_course', true);
916 937
 
@@ -984,11 +1005,15 @@  discard block
 block discarded – undo
984 1005
 
985 1006
 		foreach( $quizzes as $quiz ) {
986 1007
 
987
-			if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) continue;
1008
+			if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) {
1009
+				continue;
1010
+			}
988 1011
 
989 1012
 			$lesson_id = get_post_meta( $quiz->ID, '_quiz_lesson', true );
990 1013
 
991
-			if( empty( $lesson_id ) ) continue;
1014
+			if( empty( $lesson_id ) ) {
1015
+				continue;
1016
+			}
992 1017
 
993 1018
 			$data = array(
994 1019
 				'ID' => $quiz->ID,
@@ -1071,8 +1096,7 @@  discard block
 block discarded – undo
1071 1096
 				delete_post_meta( $quiz_id, '_quiz_passmark' );
1072 1097
 				delete_post_meta( $lesson_id, '_quiz_has_questions' );
1073 1098
 				$d_count++;
1074
-			}
1075
-			else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1099
+			} else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1076 1100
 
1077 1101
 				// Quiz has no questions, drop the corresponding data
1078 1102
 				update_post_meta( $lesson_id, '_quiz_has_questions', true );
@@ -1222,20 +1246,16 @@  discard block
 block discarded – undo
1222 1246
 							// Check if the user has to get the passmark and has or not
1223 1247
 							if ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] <= $quiz_grade ) {
1224 1248
 								$status = 'passed';
1225
-							}
1226
-							elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) {
1249
+							} elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) {
1227 1250
 								$status = 'failed';
1228
-							}
1229
-							else {
1251
+							} else {
1230 1252
 								$status = 'graded';
1231 1253
 							}
1232
-						}
1233
-						else {
1254
+						} else {
1234 1255
 							// If the lesson has a quiz, but the user doesn't have a grade, it's not yet been graded
1235 1256
 							$status = 'ungraded';
1236 1257
 						}
1237
-					}
1238
-					else {
1258
+					} else {
1239 1259
 						// Lesson has no quiz, so it can only ever be this status
1240 1260
 						$status = 'complete';
1241 1261
 					}
@@ -1374,8 +1394,7 @@  discard block
 block discarded – undo
1374 1394
 					}
1375 1395
 					$meta_data['complete'] = $lessons_completed;
1376 1396
 					$meta_data['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) );
1377
-				}
1378
-				else {
1397
+				} else {
1379 1398
 					// Course has no lessons, therefore cannot be 'complete'
1380 1399
 					$status = 'in-progress';
1381 1400
 				}
@@ -1506,8 +1525,7 @@  discard block
 block discarded – undo
1506 1525
 									$lessons_completed++;
1507 1526
 									break;
1508 1527
 							}
1509
-						}
1510
-						else {
1528
+						} else {
1511 1529
 							switch ( $lesson_status ) {
1512 1530
 								case 'complete': // Lesson has no quiz/questions
1513 1531
 								case 'graded': // Lesson has quiz, but it's not important what the grade was
Please login to merge, or discard this patch.
Spacing   +481 added lines, -481 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Updates Class
@@ -27,59 +27,59 @@  discard block
 block discarded – undo
27 27
 	 * @param   string $parent The main Sensei object by Ref.
28 28
 	 * @return  void
29 29
 	 */
30
-	public function __construct ( $parent ) {
30
+	public function __construct($parent) {
31 31
 
32 32
 		// Setup object data
33 33
 		$this->parent = $parent;
34
-		$this->updates_run = get_option( 'woothemes-sensei-upgrades', array() );
34
+		$this->updates_run = get_option('woothemes-sensei-upgrades', array());
35 35
 
36 36
 		// The list of upgrades to run
37
-		$this->updates = array( '1.1.0' => array( 	'auto' 		=> array( 'assign_role_caps' => array( 'title' => __( 'Assign role capabilities', 'woothemes-sensei' ), 'desc' => __( 'Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei' ), 'product' => 'Sensei' ) ),
37
+		$this->updates = array('1.1.0' => array('auto' 		=> array('assign_role_caps' => array('title' => __('Assign role capabilities', 'woothemes-sensei'), 'desc' => __('Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei'), 'product' => 'Sensei')),
38 38
 													'manual' 	=> array()
39 39
 												),
40
-								'1.3.0' => array( 	'auto' 		=> array( 'set_default_quiz_grade_type' => array( 'title' => __( 'Set default quiz grade type', 'woothemes-sensei' ), 'desc' => __( 'Sets all quizzes to the default \'auto\' grade type.', 'woothemes-sensei' ) ),
41
-																		  'set_default_question_type' => array( 'title' => __( 'Set default question type', 'woothemes-sensei' ), 'desc' => __( 'Sets all questions to the default \'multiple choice\' type.', 'woothemes-sensei' ) )
40
+								'1.3.0' => array('auto' 		=> array('set_default_quiz_grade_type' => array('title' => __('Set default quiz grade type', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to the default \'auto\' grade type.', 'woothemes-sensei')),
41
+																		  'set_default_question_type' => array('title' => __('Set default question type', 'woothemes-sensei'), 'desc' => __('Sets all questions to the default \'multiple choice\' type.', 'woothemes-sensei'))
42 42
 													),
43
-													'manual' 	=> array( 'update_question_answer_data' => array( 'title' => __( 'Update question answer data', 'woothemes-sensei' ), 'desc' => __( 'Updates questions to use the new question types structure.', 'woothemes-sensei' ) ) )
43
+													'manual' 	=> array('update_question_answer_data' => array('title' => __('Update question answer data', 'woothemes-sensei'), 'desc' => __('Updates questions to use the new question types structure.', 'woothemes-sensei')))
44 44
 												),
45
-								'1.4.0' => array( 	'auto' 		=> array( 'update_question_grade_points' => array( 'title' => __( 'Update question grade points', 'woothemes-sensei' ), 'desc' => __( 'Sets all question grade points to the default value of \'1\'.', 'woothemes-sensei' ) ) ),
45
+								'1.4.0' => array('auto' 		=> array('update_question_grade_points' => array('title' => __('Update question grade points', 'woothemes-sensei'), 'desc' => __('Sets all question grade points to the default value of \'1\'.', 'woothemes-sensei'))),
46 46
 													'manual' 	=> array()
47 47
 												),
48
-								'1.5.0' => array( 	'auto' 		=> array( 'convert_essay_paste_questions' => array( 'title' => __( 'Convert essay paste questions into multi-line questions', 'woothemes-sensei' ), 'desc' => __( 'Converts all essay paste questions into multi-line questions as the essay paste question type was removed in v1.5.0.', 'woothemes-sensei' ) ) ),
49
-													'manual' 	=> array( 'set_random_question_order' => array( 'title' => __( 'Set all quizzes to have a random question order', 'woothemes-sensei' ), 'desc' => __( 'Sets the order all of questions in all quizzes to a random order, which can be switched off per quiz.', 'woothemes-sensei' ) ),
50
-																		  'set_default_show_question_count' => array( 'title' => __( 'Set all quizzes to show all questions', 'woothemes-sensei' ), 'desc' => __( 'Sets all quizzes to show all questions - this can be changed per quiz.', 'woothemes-sensei' ) ),
51
-																		  'remove_deleted_user_activity' => array( 'title' => __( 'Remove Sensei activity for deleted users', 'woothemes-sensei' ), 'desc' => __( 'Removes all course, lesson &amp; quiz activity for users that have already been deleted from the database. This will fix incorrect learner counts in the Analysis section.', 'woothemes-sensei' ) ) )
48
+								'1.5.0' => array('auto' 		=> array('convert_essay_paste_questions' => array('title' => __('Convert essay paste questions into multi-line questions', 'woothemes-sensei'), 'desc' => __('Converts all essay paste questions into multi-line questions as the essay paste question type was removed in v1.5.0.', 'woothemes-sensei'))),
49
+													'manual' 	=> array('set_random_question_order' => array('title' => __('Set all quizzes to have a random question order', 'woothemes-sensei'), 'desc' => __('Sets the order all of questions in all quizzes to a random order, which can be switched off per quiz.', 'woothemes-sensei')),
50
+																		  'set_default_show_question_count' => array('title' => __('Set all quizzes to show all questions', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to show all questions - this can be changed per quiz.', 'woothemes-sensei')),
51
+																		  'remove_deleted_user_activity' => array('title' => __('Remove Sensei activity for deleted users', 'woothemes-sensei'), 'desc' => __('Removes all course, lesson &amp; quiz activity for users that have already been deleted from the database. This will fix incorrect learner counts in the Analysis section.', 'woothemes-sensei')))
52 52
 												),
53
-								'1.6.0' => array( 	'auto' 		=> array( 'add_teacher_role' => array( 'title' => __( 'Add \'Teacher\' role', 'woothemes-sensei' ), 'desc' => __( 'Adds a \'Teacher\' role to your WordPress site that will allow users to mange the Grading and Analysis pages.', 'woothemes-sensei' ) ),
54
-																		  'add_sensei_caps' => array( 'title' => __( 'Add administrator capabilities', 'woothemes-sensei' ), 'desc' => __( 'Adds the \'manage_sensei\' and \'manage_sensei_grades\' capabilities to the Administrator role.', 'woothemes-sensei' ) ),
55
-																		  'restructure_question_meta' => array( 'title' => __( 'Restructure question meta data', 'woothemes-sensei' ), 'desc' => __( 'Restructures the question meta data as it relates to quizzes - this accounts for changes in the data structure in v1.6+.', 'woothemes-sensei' ) ),
56
-																		  'update_quiz_settings' => array( 'title' => __( 'Add new quiz settings', 'woothemes-sensei' ), 'desc' => __( 'Adds new settings to quizzes that were previously registered as global settings.', 'woothemes-sensei' ) ),
57
-																		  'reset_lesson_order_meta' => array( 'title' => __( 'Set default order of lessons', 'woothemes-sensei' ), 'desc' => __( 'Adds data to lessons to ensure that they show up on the \'Order Lessons\' screen - if this update has been run once before then it will reset all lessons to the default order.', 'woothemes-sensei' ) ), ),
53
+								'1.6.0' => array('auto' 		=> array('add_teacher_role' => array('title' => __('Add \'Teacher\' role', 'woothemes-sensei'), 'desc' => __('Adds a \'Teacher\' role to your WordPress site that will allow users to mange the Grading and Analysis pages.', 'woothemes-sensei')),
54
+																		  'add_sensei_caps' => array('title' => __('Add administrator capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei\' and \'manage_sensei_grades\' capabilities to the Administrator role.', 'woothemes-sensei')),
55
+																		  'restructure_question_meta' => array('title' => __('Restructure question meta data', 'woothemes-sensei'), 'desc' => __('Restructures the question meta data as it relates to quizzes - this accounts for changes in the data structure in v1.6+.', 'woothemes-sensei')),
56
+																		  'update_quiz_settings' => array('title' => __('Add new quiz settings', 'woothemes-sensei'), 'desc' => __('Adds new settings to quizzes that were previously registered as global settings.', 'woothemes-sensei')),
57
+																		  'reset_lesson_order_meta' => array('title' => __('Set default order of lessons', 'woothemes-sensei'), 'desc' => __('Adds data to lessons to ensure that they show up on the \'Order Lessons\' screen - if this update has been run once before then it will reset all lessons to the default order.', 'woothemes-sensei')),),
58 58
 													'manual' 	=> array()
59 59
 												),
60
-								'1.7.0' => array( 	'auto' 		=> array( 'add_editor_caps' => array( 'title' => __( 'Add Editor capabilities', 'woothemes-sensei' ), 'desc' => __( 'Adds the \'manage_sensei_grades\' capability to the Editor role.', 'woothemes-sensei' ) ), ),
61
-													'forced' 	=> array(  'update_question_gap_fill_separators' => array( 'title' => __( 'Update Gap Fill questions', 'woothemes-sensei' ), 'desc' => __( 'Updates the format of gap fill questions to allow auto grading and greater flexibility in matching.', 'woothemes-sensei' ) ),
62
-																		  'update_quiz_lesson_relationship' => array( 'title' => __( 'Restructure quiz lesson relationship', 'woothemes-sensei' ), 'desc' => __( 'Adds data to quizzes and lessons to ensure that they maintain their 1 to 1 relationship.', 'woothemes-sensei' ) ),
63
-																		  'status_changes_fix_lessons' => array( 'title' => __( 'Update lesson statuses', 'woothemes-sensei' ), 'desc' => __( 'Update existing lesson statuses.', 'woothemes-sensei' ) ),
64
-																		  'status_changes_convert_lessons' => array( 'title' => __( 'Convert lesson statuses', 'woothemes-sensei' ), 'desc' => __( 'Convert to new lesson statuses.', 'woothemes-sensei' ) ),
65
-																		  'status_changes_convert_courses' => array( 'title' => __( 'Convert course statuses', 'woothemes-sensei' ), 'desc' => __( 'Convert to new course statuses.', 'woothemes-sensei' ) ),
66
-																		  'status_changes_convert_questions' => array( 'title' => __( 'Convert question statuses', 'woothemes-sensei' ), 'desc' => __( 'Convert to new question statuses.', 'woothemes-sensei' ) ),
67
-																		  'update_legacy_sensei_comments_status' => array( 'title' => __( 'Convert legacy Sensei activity types', 'woothemes-sensei' ), 'desc' => __( 'Convert all legacy Sensei activity types such as \'sensei_lesson_start\' and \'sensei_user_answer\' to new status format.', 'woothemes-sensei' ) ),
68
-																		  'update_comment_course_lesson_comment_counts' => array( 'title' => __( 'Update comment counts', 'woothemes-sensei' ), 'desc' => __( 'Update comment counts on Courses and Lessons due to status changes.', 'woothemes-sensei' ) ), ),
60
+								'1.7.0' => array('auto' 		=> array('add_editor_caps' => array('title' => __('Add Editor capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei_grades\' capability to the Editor role.', 'woothemes-sensei')),),
61
+													'forced' 	=> array('update_question_gap_fill_separators' => array('title' => __('Update Gap Fill questions', 'woothemes-sensei'), 'desc' => __('Updates the format of gap fill questions to allow auto grading and greater flexibility in matching.', 'woothemes-sensei')),
62
+																		  'update_quiz_lesson_relationship' => array('title' => __('Restructure quiz lesson relationship', 'woothemes-sensei'), 'desc' => __('Adds data to quizzes and lessons to ensure that they maintain their 1 to 1 relationship.', 'woothemes-sensei')),
63
+																		  'status_changes_fix_lessons' => array('title' => __('Update lesson statuses', 'woothemes-sensei'), 'desc' => __('Update existing lesson statuses.', 'woothemes-sensei')),
64
+																		  'status_changes_convert_lessons' => array('title' => __('Convert lesson statuses', 'woothemes-sensei'), 'desc' => __('Convert to new lesson statuses.', 'woothemes-sensei')),
65
+																		  'status_changes_convert_courses' => array('title' => __('Convert course statuses', 'woothemes-sensei'), 'desc' => __('Convert to new course statuses.', 'woothemes-sensei')),
66
+																		  'status_changes_convert_questions' => array('title' => __('Convert question statuses', 'woothemes-sensei'), 'desc' => __('Convert to new question statuses.', 'woothemes-sensei')),
67
+																		  'update_legacy_sensei_comments_status' => array('title' => __('Convert legacy Sensei activity types', 'woothemes-sensei'), 'desc' => __('Convert all legacy Sensei activity types such as \'sensei_lesson_start\' and \'sensei_user_answer\' to new status format.', 'woothemes-sensei')),
68
+																		  'update_comment_course_lesson_comment_counts' => array('title' => __('Update comment counts', 'woothemes-sensei'), 'desc' => __('Update comment counts on Courses and Lessons due to status changes.', 'woothemes-sensei')),),
69 69
 												),
70
-								'1.7.2' => array( 	'auto' 		=> array( 'index_comment_status_field' => array( 'title' => __( 'Add database index to comment statuses', 'woothemes-sensei' ), 'desc' => __( 'This indexes the comment statuses in the database, which will speed up all Sensei activity queries.', 'woothemes-sensei' ) ), ),
70
+								'1.7.2' => array('auto' 		=> array('index_comment_status_field' => array('title' => __('Add database index to comment statuses', 'woothemes-sensei'), 'desc' => __('This indexes the comment statuses in the database, which will speed up all Sensei activity queries.', 'woothemes-sensei')),),
71 71
 													/*'manual' 		=> array( 'remove_legacy_comments' => array( 'title' => __( 'Remove legacy Sensei activity types', 'woothemes-sensei' ), 'desc' => __( 'This removes all legacy (pre-1.7) Sensei activity types - only run this update once the update to v1.7 is complete and everything is stable.', 'woothemes-sensei' ) ) )*/
72 72
 												),
73
-                                '1.8.0' => array(   'auto' => array( 'enhance_teacher_role' => array( 'title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.' ), ),
73
+                                '1.8.0' => array('auto' => array('enhance_teacher_role' => array('title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.'),),
74 74
                             						'manual' 	=> array()
75 75
                     							),
76 76
 							);
77 77
 
78
-		$this->updates = apply_filters( 'sensei_upgrade_functions', $this->updates, $this->updates );
79
-		$this->version = get_option( 'woothemes-sensei-version' );
78
+		$this->updates = apply_filters('sensei_upgrade_functions', $this->updates, $this->updates);
79
+		$this->version = get_option('woothemes-sensei-version');
80 80
 
81 81
 		// Manual Update Screen
82
-		add_action('admin_menu', array( $this, 'add_update_admin_screen' ), 50 );
82
+		add_action('admin_menu', array($this, 'add_update_admin_screen'), 50);
83 83
 
84 84
 	} // End __construct()
85 85
 
@@ -91,8 +91,8 @@  discard block
 block discarded – undo
91 91
 	 * @return void
92 92
 	 */
93 93
 	public function add_update_admin_screen() {
94
-		if ( current_user_can( 'manage_options' ) ) {
95
-			add_submenu_page( 'sensei', __( 'Sensei Updates', 'woothemes-sensei' ), __( 'Data Updates', 'woothemes-sensei' ), 'manage_options', 'sensei_updates', array( $this, 'sensei_updates_page' ) );
94
+		if (current_user_can('manage_options')) {
95
+			add_submenu_page('sensei', __('Sensei Updates', 'woothemes-sensei'), __('Data Updates', 'woothemes-sensei'), 'manage_options', 'sensei_updates', array($this, 'sensei_updates_page'));
96 96
 		}
97 97
 	} // End add_update_admin_screen()
98 98
 
@@ -106,80 +106,80 @@  discard block
 block discarded – undo
106 106
 	public function sensei_updates_page() {
107 107
 
108 108
 		// Only allow admins to load this page and run the update functions
109
-		if( current_user_can( 'manage_options' ) ) {
109
+		if (current_user_can('manage_options')) {
110 110
 			?>
111 111
 			<div class="wrap">
112 112
 
113 113
 				<div id="icon-woothemes-sensei" class="icon32"><br></div>
114
-				<h2><?php _e( 'Sensei Updates', 'woothemes-sensei' ); ?></h2>
114
+				<h2><?php _e('Sensei Updates', 'woothemes-sensei'); ?></h2>
115 115
 
116 116
 				<?php
117
-				if ( isset( $_GET['action'] ) && $_GET['action'] == 'update' && isset( $_GET['n'] ) && intval( $_GET['n'] ) >= 0 && ( ( isset( $_POST['checked'][0] ) && '' != $_POST['checked'][0] ) || ( isset( $_GET['functions'] ) && '' != $_GET['functions'] ) ) ) {
117
+				if (isset($_GET['action']) && $_GET['action'] == 'update' && isset($_GET['n']) && intval($_GET['n']) >= 0 && ((isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) {
118 118
 
119 119
 					// Setup the data variables
120
-					$n = intval( $_GET['n'] );
120
+					$n = intval($_GET['n']);
121 121
 					$functions_list = '';
122 122
 					$done_processing = false;
123 123
 
124 124
 					// Check for updates to run
125
-					if ( isset( $_POST['checked'][0] ) && '' != $_POST['checked'][0] ) {
125
+					if (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) {
126 126
 
127
-						foreach ( $_POST['checked'] as $key => $value ) {
127
+						foreach ($_POST['checked'] as $key => $value) {
128 128
 
129 129
 							// Dynamic function call
130
-							if ( method_exists( $this, $value) ) {
131
-								$done_processing = call_user_func_array( array( $this, $value ), array( 50, $n ) );
130
+							if (method_exists($this, $value)) {
131
+								$done_processing = call_user_func_array(array($this, $value), array(50, $n));
132 132
 							} else {
133
-								$done_processing = call_user_func_array( $value, array( 50, $n ) );
133
+								$done_processing = call_user_func_array($value, array(50, $n));
134 134
 							} // End If Statement
135 135
 
136 136
 							// Add to functions list get args
137
-							if ( '' == $functions_list ) {
137
+							if ('' == $functions_list) {
138 138
 								$functions_list .= $value;
139 139
 							} else {
140
-								$functions_list .= '+' . $value;
140
+								$functions_list .= '+'.$value;
141 141
 							} // End If Statement
142 142
 
143 143
 							// Mark update has having been run
144
-							$this->set_update_run( $value );
144
+							$this->set_update_run($value);
145 145
 
146 146
 						} // End For Loop
147 147
 
148 148
 					} // End If Statement
149 149
 
150 150
 					// Check for updates to run
151
-					if ( isset( $_GET['functions'] ) && '' != $_GET['functions'] ) {
151
+					if (isset($_GET['functions']) && '' != $_GET['functions']) {
152 152
 
153 153
 						// Existing functions from GET variables instead of POST
154 154
 						$functions_array = $_GET['functions'];
155 155
 
156
-						foreach ( $functions_array as $key => $value ) {
156
+						foreach ($functions_array as $key => $value) {
157 157
 
158 158
 							// Dynamic function call
159
-							if ( method_exists( $this, $value) ) {
160
-								$done_processing = call_user_func_array( array( $this, $value ), array( 50, $n ) );
159
+							if (method_exists($this, $value)) {
160
+								$done_processing = call_user_func_array(array($this, $value), array(50, $n));
161 161
 							} else {
162
-								$done_processing = call_user_func_array( $value, array( 50, $n ) );
162
+								$done_processing = call_user_func_array($value, array(50, $n));
163 163
 							} // End If Statement
164 164
 
165 165
 							// Add to functions list get args
166
-							if ( '' == $functions_list ) {
166
+							if ('' == $functions_list) {
167 167
 								$functions_list .= $value;
168 168
 							} else {
169
-								$functions_list .= '+' . $value;
169
+								$functions_list .= '+'.$value;
170 170
 							} // End If Statement
171 171
 
172
-							$this->set_update_run( $value );
172
+							$this->set_update_run($value);
173 173
 
174 174
 						} // End For Loop
175 175
 
176 176
 					} // End If Statement
177 177
 
178
-					if ( ! $done_processing ) { ?>
178
+					if ( ! $done_processing) { ?>
179 179
 
180
-						<h3><?php _e( 'Processing Updates...', 'woothemes-sensei' ); ?></h3>
180
+						<h3><?php _e('Processing Updates...', 'woothemes-sensei'); ?></h3>
181 181
 
182
-						<p><?php _e( 'If your browser doesn&#8217;t start loading the next page automatically, click this button:', 'woothemes-sensei' ); ?>&nbsp;&nbsp;<a class="button" href="admin.php?page=sensei_updates&action=update&n=<?php echo ($n + 50) ?>&functions[]=<?php echo $functions_list; ?>"><?php _e( 'Next', 'woothemes-sensei' ); ?></a></p>
182
+						<p><?php _e('If your browser doesn&#8217;t start loading the next page automatically, click this button:', 'woothemes-sensei'); ?>&nbsp;&nbsp;<a class="button" href="admin.php?page=sensei_updates&action=update&n=<?php echo ($n + 50) ?>&functions[]=<?php echo $functions_list; ?>"><?php _e('Next', 'woothemes-sensei'); ?></a></p>
183 183
 						<script type='text/javascript'>
184 184
 						<!--
185 185
 						function sensei_nextpage() {
@@ -191,48 +191,48 @@  discard block
 block discarded – undo
191 191
 
192 192
 					} else { ?>
193 193
 
194
-						<p><strong><?php _e( 'Update completed successfully!', 'woothemes-sensei' ); ?></strong></p>
195
-						<p><a href="<?php echo admin_url('edit.php?post_type=lesson'); ?>"><?php _e( 'Create a new lesson', 'woothemes-sensei' ); ?></a> or <a href="<?php echo admin_url('admin.php?page=sensei_updates'); ?>"><?php _e( 'run some more updates', 'woothemes-sensei' ); ?></a>.</p>
194
+						<p><strong><?php _e('Update completed successfully!', 'woothemes-sensei'); ?></strong></p>
195
+						<p><a href="<?php echo admin_url('edit.php?post_type=lesson'); ?>"><?php _e('Create a new lesson', 'woothemes-sensei'); ?></a> or <a href="<?php echo admin_url('admin.php?page=sensei_updates'); ?>"><?php _e('run some more updates', 'woothemes-sensei'); ?></a>.</p>
196 196
 
197 197
 					<?php } // End If Statement
198 198
 
199 199
 				} else { ?>
200 200
 
201
-					<h3><?php _e( 'Updates', 'woothemes-sensei' ); ?></h3>
202
-					<p><?php printf( __( 'These are updates that have been made available as new Sensei versions have been released. Updates of type %1$sAuto%2$s will run as you update Sensei to the relevant version - other updates need to be run manually and you can do that here.', 'woothemes-sensei' ), '<code>', '</code>' ); ?></p>
201
+					<h3><?php _e('Updates', 'woothemes-sensei'); ?></h3>
202
+					<p><?php printf(__('These are updates that have been made available as new Sensei versions have been released. Updates of type %1$sAuto%2$s will run as you update Sensei to the relevant version - other updates need to be run manually and you can do that here.', 'woothemes-sensei'), '<code>', '</code>'); ?></p>
203 203
 
204
-					<div class="updated"><p><strong><?php _e( 'Only run these updates if you have been instructed to do so by WooThemes support staff.', 'woothemes-sensei' ); ?></strong></p></div>
204
+					<div class="updated"><p><strong><?php _e('Only run these updates if you have been instructed to do so by WooThemes support staff.', 'woothemes-sensei'); ?></strong></p></div>
205 205
 
206 206
 					<table class="widefat" cellspacing="0" id="update-plugins-table">
207 207
 
208 208
 						<thead>
209 209
 							<tr>
210
-								<th scope="col" class="manage-column"><?php _e( 'Update', 'woothemes-sensei' ); ?></th>
211
-								<th scope="col" class="manage-column"><?php _e( 'Type', 'woothemes-sensei' ); ?></th>
212
-								<th scope="col" class="manage-column"><?php _e( 'Action', 'woothemes-sensei' ); ?></th>
210
+								<th scope="col" class="manage-column"><?php _e('Update', 'woothemes-sensei'); ?></th>
211
+								<th scope="col" class="manage-column"><?php _e('Type', 'woothemes-sensei'); ?></th>
212
+								<th scope="col" class="manage-column"><?php _e('Action', 'woothemes-sensei'); ?></th>
213 213
 							</tr>
214 214
 						</thead>
215 215
 
216 216
 						<tfoot>
217 217
 							<tr>
218
-								<th scope="col" class="manage-column"><?php _e( 'Update', 'woothemes-sensei' ); ?></th>
219
-								<th scope="col" class="manage-column"><?php _e( 'Type', 'woothemes-sensei' ); ?></th>
220
-								<th scope="col" class="manage-column"><?php _e( 'Action', 'woothemes-sensei' ); ?></th>
218
+								<th scope="col" class="manage-column"><?php _e('Update', 'woothemes-sensei'); ?></th>
219
+								<th scope="col" class="manage-column"><?php _e('Type', 'woothemes-sensei'); ?></th>
220
+								<th scope="col" class="manage-column"><?php _e('Action', 'woothemes-sensei'); ?></th>
221 221
 							</tr>
222 222
 						</tfoot>
223 223
 
224 224
 						<tbody class="updates">
225 225
 							<?php
226 226
 							// Sort updates with the latest at the top
227
-							uksort( $this->updates, array( $this, 'sort_updates' ) );
228
-							$this->updates = array_reverse( $this->updates, true );
227
+							uksort($this->updates, array($this, 'sort_updates'));
228
+							$this->updates = array_reverse($this->updates, true);
229 229
 							$class = 'alternate';
230
-							foreach( $this->updates as $version => $version_updates ) {
231
-								foreach( $version_updates as $type => $updates ) {
232
-									foreach( $updates as $update => $data ) {
233
-										$update_run = $this->has_update_run( $update );
230
+							foreach ($this->updates as $version => $version_updates) {
231
+								foreach ($version_updates as $type => $updates) {
232
+									foreach ($updates as $update => $data) {
233
+										$update_run = $this->has_update_run($update);
234 234
 										$product = 'Sensei';
235
-										if ( isset( $data['product'] ) && '' != $data['product'] ) {
235
+										if (isset($data['product']) && '' != $data['product']) {
236 236
 											$product = $data['product'];
237 237
 										} // End If Statement
238 238
 										?>
@@ -242,21 +242,21 @@  discard block
 block discarded – undo
242 242
 													<p>
243 243
 														<input type="hidden" name="checked[]" value="<?php echo $update; ?>">
244 244
 														<strong><?php echo $data['title']; ?></strong><br><?php echo $data['desc']; ?><br>
245
-														<em><?php printf( __( 'Originally included in %s v%s', 'woothemes-sensei' ), $product, $version ); ?></em>
245
+														<em><?php printf(__('Originally included in %s v%s', 'woothemes-sensei'), $product, $version); ?></em>
246 246
 													</p>
247 247
 												</td>
248 248
 												<?php
249
-												$type_label = __( 'Auto', 'woothemes-sensei' );
250
-												if( $type != 'auto' ) {
251
-													$type_label = __( 'Manual', 'woothemes-sensei' );
249
+												$type_label = __('Auto', 'woothemes-sensei');
250
+												if ($type != 'auto') {
251
+													$type_label = __('Manual', 'woothemes-sensei');
252 252
 												}
253 253
 												?>
254 254
 												<td><p><?php echo $type_label; ?></p></td>
255
-												<td><p><input onclick="javascript:return confirm('<?php echo addslashes( sprintf( __( 'Are you sure you want to run the \'%s\' update?', 'woothemes-sensei' ), $data['title'] ) ); ?>');" id="update-sensei" class="button<?php if( ! $update_run ) { echo ' button-primary'; } ?>" type="submit" value="<?php if( $update_run ) { _e( 'Re-run Update', 'woothemes-sensei' ); } else { _e( 'Run Update', 'woothemes-sensei' ); } ?>" name="update"></p></td>
255
+												<td><p><input onclick="javascript:return confirm('<?php echo addslashes(sprintf(__('Are you sure you want to run the \'%s\' update?', 'woothemes-sensei'), $data['title'])); ?>');" id="update-sensei" class="button<?php if ( ! $update_run) { echo ' button-primary'; } ?>" type="submit" value="<?php if ($update_run) { _e('Re-run Update', 'woothemes-sensei'); } else { _e('Run Update', 'woothemes-sensei'); } ?>" name="update"></p></td>
256 256
 											</tr>
257 257
 										</form>
258 258
 										<?php
259
-										if( 'alternate' == $class ) {
259
+										if ('alternate' == $class) {
260 260
 											$class = '';
261 261
 										} else {
262 262
 											$class = 'alternate';
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
 	 * @param  string $b Second key
284 284
 	 * @return integer
285 285
 	 */
286
-	private function sort_updates( $a, $b ) {
287
-		return strcmp( $a, $b );
286
+	private function sort_updates($a, $b) {
287
+		return strcmp($a, $b);
288 288
 	}
289 289
 
290 290
 	/**
@@ -295,32 +295,32 @@  discard block
 block discarded – undo
295 295
 	 * @access public
296 296
 	 * @return boolean
297 297
 	 */
298
-	public function update ( $type = 'auto' ) {
298
+	public function update($type = 'auto') {
299 299
 
300 300
 		// Only allow admins to run update functions
301
-		if( current_user_can( 'manage_options' ) ) {
301
+		if (current_user_can('manage_options')) {
302 302
 
303 303
 			$this->force_updates();
304 304
 
305 305
 			// Run through all functions
306
-			foreach ( $this->updates as $version => $value ) {
307
-				foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) {
308
-					if ( $upgrade_type == $type ) {
306
+			foreach ($this->updates as $version => $value) {
307
+				foreach ($this->updates[$version] as $upgrade_type => $function_to_run) {
308
+					if ($upgrade_type == $type) {
309 309
 						$updated = false;
310 310
 						// Run the update function
311
-						foreach ( $function_to_run as $function_name => $update_data ) {
312
-							if ( isset( $function_name ) && '' != $function_name ) {
313
-								if ( ! in_array( $function_name, $this->updates_run ) ) {
311
+						foreach ($function_to_run as $function_name => $update_data) {
312
+							if (isset($function_name) && '' != $function_name) {
313
+								if ( ! in_array($function_name, $this->updates_run)) {
314 314
 									$updated = false;
315
-									if ( method_exists( $this, $function_name ) ) {
316
-										$updated = call_user_func( array( $this, $function_name ) );
317
-									} elseif( function_exists( $function_name ) ) {
318
-										$updated = call_user_func( $function_name );
315
+									if (method_exists($this, $function_name)) {
316
+										$updated = call_user_func(array($this, $function_name));
317
+									} elseif (function_exists($function_name)) {
318
+										$updated = call_user_func($function_name);
319 319
 									} else {
320 320
 										// Nothing to see here...
321 321
 									} // End If Statement
322
-									if ( $updated ) {
323
-										array_push( $this->updates_run, $function_name );
322
+									if ($updated) {
323
+										array_push($this->updates_run, $function_name);
324 324
 									} // End If Statement
325 325
 								}
326 326
 							} // End If Statement
@@ -329,8 +329,8 @@  discard block
 block discarded – undo
329 329
 				} // End For Loop
330 330
 			} // End For Loop
331 331
 
332
-            $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
333
-			update_option( Sensei()->token . '-upgrades', $this->updates_run );
332
+            $this->updates_run = array_unique($this->updates_run); // we only need one reference per update
333
+			update_option(Sensei()->token.'-upgrades', $this->updates_run);
334 334
 			return true;
335 335
 
336 336
 		}
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
 
340 340
 	private function force_updates() {
341 341
 
342
-		if( ! isset( $_GET['page'] ) || 'sensei_updates' != $_GET['page'] ) {
342
+		if ( ! isset($_GET['page']) || 'sensei_updates' != $_GET['page']) {
343 343
 
344 344
 			// $skip_forced_updates = false;
345 345
 			// if( ! get_option( 'woothemes-sensei-force-updates', false ) ) {
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
 
349 349
 			// Force critical updates if only if lessons already exist
350 350
 			$skip_forced_updates = false;
351
-			$lesson_posts = wp_count_posts( 'lesson' );
352
-			if( ! isset( $lesson_posts->publish ) || ! $lesson_posts->publish ) {
351
+			$lesson_posts = wp_count_posts('lesson');
352
+			if ( ! isset($lesson_posts->publish) || ! $lesson_posts->publish) {
353 353
 				$skip_forced_updates = true;
354 354
 			}
355 355
 
@@ -357,69 +357,69 @@  discard block
 block discarded – undo
357 357
 
358 358
 			$updates_to_run = array();
359 359
 
360
-			foreach ( $this->updates as $version => $value ) {
361
-				foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) {
362
-					if ( $upgrade_type == 'forced' ) {
363
-						foreach ( $function_to_run as $function_name => $update_data ) {
360
+			foreach ($this->updates as $version => $value) {
361
+				foreach ($this->updates[$version] as $upgrade_type => $function_to_run) {
362
+					if ($upgrade_type == 'forced') {
363
+						foreach ($function_to_run as $function_name => $update_data) {
364 364
 
365
-							if( $skip_forced_updates ) {
366
-								$this->set_update_run( $function_name );
365
+							if ($skip_forced_updates) {
366
+								$this->set_update_run($function_name);
367 367
 								continue;
368 368
 							}
369 369
 
370
-							$update_run = $this->has_update_run( $function_name );
370
+							$update_run = $this->has_update_run($function_name);
371 371
 
372
-							if( ! $update_run ) {
372
+							if ( ! $update_run) {
373 373
 								$use_the_force = true;
374
-								$updates_to_run[ $function_name ] = $update_data;
374
+								$updates_to_run[$function_name] = $update_data;
375 375
 							}
376 376
 						}
377 377
 					}
378 378
 				}
379 379
 			}
380 380
 
381
-			if( $skip_forced_updates ) {
381
+			if ($skip_forced_updates) {
382 382
 				return;
383 383
 			}
384 384
 
385
-			if( $use_the_force && 0 < count( $updates_to_run ) ) {
385
+			if ($use_the_force && 0 < count($updates_to_run)) {
386 386
 
387
-				$update_title = __( 'Important Sensei updates required', 'woothemes-sensei' );
387
+				$update_title = __('Important Sensei updates required', 'woothemes-sensei');
388 388
 
389
-				$update_message = '<h1>' . __( 'Important Sensei upgrades required!', 'woothemes-sensei' ) . '</h1>' . "\n";
389
+				$update_message = '<h1>'.__('Important Sensei upgrades required!', 'woothemes-sensei').'</h1>'."\n";
390 390
 
391 391
 				// $update_message .= '<h4>' . sprintf( __( 'These updates are only required if you are updating from a previous version of Sensei. If you are installing Sensei for the first time, %1$syou can dismiss this page by clicking here%2$s.', 'woothemes-sensei' ), '<a href="' . add_query_arg( array( 'sensei_skip_forced_updates' => 'true' ) ) . '">', '</a>' ) . '</h4>' ."\n";
392 392
 
393
-				$update_message .= '<p>' . __( 'The latest version of Sensei requires some important database upgrades. In order to run these upgrades you will need to follow the step by step guide below. Your site will not function correctly unless you run these critical updates.', 'woothemes-sensei' ) . '</p>' . "\n";
393
+				$update_message .= '<p>'.__('The latest version of Sensei requires some important database upgrades. In order to run these upgrades you will need to follow the step by step guide below. Your site will not function correctly unless you run these critical updates.', 'woothemes-sensei').'</p>'."\n";
394 394
 
395
-				$update_message .= '<p><b>' . __( 'To run the upgrades click on each of the links below in the order that they appear.', 'woothemes-sensei' ) . '</b></p>' . "\n";
395
+				$update_message .= '<p><b>'.__('To run the upgrades click on each of the links below in the order that they appear.', 'woothemes-sensei').'</b></p>'."\n";
396 396
 
397
-				$update_message .= '<p>' . __( 'Clicking each link will open up a new window/tab - do not close that window/tab until you see the message \'Update completed successfully\'. Once you see that message you can close the window/tab and start the next upgrade by clicking on the next link in the list.', 'woothemes-sensei' ) . '</p>' . "\n";
397
+				$update_message .= '<p>'.__('Clicking each link will open up a new window/tab - do not close that window/tab until you see the message \'Update completed successfully\'. Once you see that message you can close the window/tab and start the next upgrade by clicking on the next link in the list.', 'woothemes-sensei').'</p>'."\n";
398 398
 
399
-				$update_message .= '<p><b>' . __( 'Once all the upgrades have been completed you will be able to use your WordPress site again.', 'woothemes-sensei' ) . '</b></p>' . "\n";
399
+				$update_message .= '<p><b>'.__('Once all the upgrades have been completed you will be able to use your WordPress site again.', 'woothemes-sensei').'</b></p>'."\n";
400 400
 
401
-				$update_message .= '<ol>' . "\n";
401
+				$update_message .= '<ol>'."\n";
402 402
 
403
-					foreach( $updates_to_run as $function => $data ) {
403
+					foreach ($updates_to_run as $function => $data) {
404 404
 
405
-						if( ! isset( $data['title'] ) ) {
405
+						if ( ! isset($data['title'])) {
406 406
 							break;
407 407
 						}
408 408
 
409
-						$update_message .= '<li style="margin:5px 0;"><a href="' . admin_url( 'admin.php?page=sensei_updates&action=update&n=0&functions[]=' . $function ) . '" target="_blank">' . $data['title'] . '</a></li>';
409
+						$update_message .= '<li style="margin:5px 0;"><a href="'.admin_url('admin.php?page=sensei_updates&action=update&n=0&functions[]='.$function).'" target="_blank">'.$data['title'].'</a></li>';
410 410
 					}
411 411
 
412
-				$update_message .= '</ol>' . "\n";
412
+				$update_message .= '</ol>'."\n";
413 413
 
414
-				switch( $version ) {
414
+				switch ($version) {
415 415
 
416 416
 					case '1.7.0':
417
-						$update_message .= '<p><em>' . sprintf( __( 'Want to know what these upgrades are all about? %1$sFind out more here%2$s.', 'woothemes-sensei' ), '<a href="http://develop.woothemes.com/sensei/2014/12/03/important-information-about-sensei-1-7" target="_blank">', '</a>' ) . '</em></p>' . "\n";
417
+						$update_message .= '<p><em>'.sprintf(__('Want to know what these upgrades are all about? %1$sFind out more here%2$s.', 'woothemes-sensei'), '<a href="http://develop.woothemes.com/sensei/2014/12/03/important-information-about-sensei-1-7" target="_blank">', '</a>').'</em></p>'."\n";
418 418
 					break;
419 419
 
420 420
 				}
421 421
 
422
-				wp_die( $update_message, $update_title );
422
+				wp_die($update_message, $update_title);
423 423
 			}
424 424
 		}
425 425
 	}
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @since  1.4.0
432 432
 	 * @return boolean
433 433
 	 */
434
-	private function has_update_run( $update ) {
435
-		if ( in_array( $update, $this->updates_run ) ) {
434
+	private function has_update_run($update) {
435
+		if (in_array($update, $this->updates_run)) {
436 436
 			return true;
437 437
 		}
438 438
 		return false;
@@ -444,10 +444,10 @@  discard block
 block discarded – undo
444 444
 	 * @param string $update Update to process
445 445
 	 * @since  1.4.0
446 446
 	 */
447
-	private function set_update_run( $update ) {
448
-		array_push( $this->updates_run, $update );
449
-        $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update
450
-		update_option( Sensei()->token . '-upgrades', $this->updates_run );
447
+	private function set_update_run($update) {
448
+		array_push($this->updates_run, $update);
449
+        $this->updates_run = array_unique($this->updates_run); // we only need one reference per update
450
+		update_option(Sensei()->token.'-upgrades', $this->updates_run);
451 451
 	}
452 452
 
453 453
 	/**
@@ -458,15 +458,15 @@  discard block
 block discarded – undo
458 458
 	 * @return void
459 459
 	 */
460 460
 	public function assign_role_caps() {
461
-		foreach ( $this->parent->post_types->role_caps as $role_cap_set  ) {
462
-			foreach ( $role_cap_set as $role_key => $capabilities_array ) {
461
+		foreach ($this->parent->post_types->role_caps as $role_cap_set) {
462
+			foreach ($role_cap_set as $role_key => $capabilities_array) {
463 463
 				/* Get the role. */
464
-				$role = get_role( $role_key );
465
-				foreach ( $capabilities_array as $cap_name  ) {
464
+				$role = get_role($role_key);
465
+				foreach ($capabilities_array as $cap_name) {
466 466
 					/* If the role exists, add required capabilities for the plugin. */
467
-					if ( !empty( $role ) ) {
468
-						if ( !$role->has_cap( $cap_name ) ) {
469
-							$role->add_cap( $cap_name );
467
+					if ( ! empty($role)) {
468
+						if ( ! $role->has_cap($cap_name)) {
469
+							$role->add_cap($cap_name);
470 470
 						} // End If Statement
471 471
 					} // End If Statement
472 472
 				} // End For Loop
@@ -483,16 +483,16 @@  discard block
 block discarded – undo
483 483
 	 * @return void
484 484
 	 */
485 485
 	public function set_default_quiz_grade_type() {
486
-		$args = array(	'post_type' 		=> 'quiz',
486
+		$args = array('post_type' 		=> 'quiz',
487 487
 						'posts_per_page' 		=> -1,
488 488
 						'post_status'		=> 'publish',
489 489
 						'suppress_filters' 	=> 0
490 490
 						);
491
-		$quizzes = get_posts( $args );
491
+		$quizzes = get_posts($args);
492 492
 
493
-		foreach( $quizzes as $quiz ) {
494
-			update_post_meta( $quiz->ID, '_quiz_grade_type', 'auto' );
495
-			update_post_meta( $quiz->ID, '_quiz_grade_type_disabled', '' );
493
+		foreach ($quizzes as $quiz) {
494
+			update_post_meta($quiz->ID, '_quiz_grade_type', 'auto');
495
+			update_post_meta($quiz->ID, '_quiz_grade_type_disabled', '');
496 496
 		}
497 497
 		return true;
498 498
 	} // End set_default_quiz_grade_type
@@ -505,23 +505,23 @@  discard block
 block discarded – undo
505 505
 	 * @return void
506 506
 	 */
507 507
 	public function set_default_question_type() {
508
-		$args = array(	'post_type' 		=> 'question',
508
+		$args = array('post_type' 		=> 'question',
509 509
 						'posts_per_page' 		=> -1,
510 510
 						'post_status'		=> 'publish',
511 511
 						'suppress_filters' 	=> 0
512 512
 						);
513
-		$questions = get_posts( $args );
513
+		$questions = get_posts($args);
514 514
 
515 515
 		$already_run = true;
516
-		foreach( $questions as $question ) {
517
-			if( $already_run ) {
518
-				$terms = wp_get_post_terms( $question->ID, 'question-type' );
519
-				if( is_array( $terms ) && count( $terms ) > 0 ) {
516
+		foreach ($questions as $question) {
517
+			if ($already_run) {
518
+				$terms = wp_get_post_terms($question->ID, 'question-type');
519
+				if (is_array($terms) && count($terms) > 0) {
520 520
 					break;
521 521
 				}
522 522
 			}
523 523
 			$already_run = false;
524
-			wp_set_post_terms( $question->ID, array( 'multiple-choice' ), 'question-type' );
524
+			wp_set_post_terms($question->ID, array('multiple-choice'), 'question-type');
525 525
 		}
526 526
 
527 527
 		return true;
@@ -534,90 +534,90 @@  discard block
 block discarded – undo
534 534
 	 * @access public
535 535
 	 * @return void
536 536
 	 */
537
-	public function update_question_answer_data( $n = 50, $offset = 0 ) {
537
+	public function update_question_answer_data($n = 50, $offset = 0) {
538 538
 
539 539
 		// Get Total Number of Updates to run
540
-		$quiz_count_object = wp_count_posts( 'quiz' );
540
+		$quiz_count_object = wp_count_posts('quiz');
541 541
 		$quiz_count_published = $quiz_count_object->publish;
542 542
 
543 543
 		// Calculate if this is the last page
544
-		if ( 0 == $offset ) {
544
+		if (0 == $offset) {
545 545
 			$current_page = 1;
546 546
 		} else {
547
-			$current_page = intval( $offset / $n );
547
+			$current_page = intval($offset / $n);
548 548
 		} // End If Statement
549
-		$total_pages = intval( $quiz_count_published / $n );
549
+		$total_pages = intval($quiz_count_published / $n);
550 550
 
551 551
 
552
-		$args = array(	'post_type' 		=> 'quiz',
552
+		$args = array('post_type' 		=> 'quiz',
553 553
 						'posts_per_page' 		=> $n,
554 554
 						'offset'			=> $offset,
555 555
 						'post_status'		=> 'publish',
556 556
 						'suppress_filters' 	=> 0
557 557
 						);
558
-		$quizzes = get_posts( $args );
558
+		$quizzes = get_posts($args);
559 559
 
560 560
 		$old_answers = array();
561 561
 		$right_answers = array();
562 562
 		$old_user_answers = array();
563 563
 
564
-		if( is_array( $quizzes ) ) {
565
-			foreach( $quizzes as $quiz ) {
564
+		if (is_array($quizzes)) {
565
+			foreach ($quizzes as $quiz) {
566 566
 				$quiz_id = $quiz->ID;
567 567
 
568 568
 				// Get current user answers
569
-				$comments = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $quiz_id, 'type' => 'sensei_quiz_answers' ), true  );
569
+				$comments = Sensei_Utils::sensei_check_for_activity(array('post_id' => $quiz_id, 'type' => 'sensei_quiz_answers'), true);
570 570
 				// Need to always return an array, even with only 1 item
571
-				if ( !is_array($comments) ) {
572
-					$comments = array( $comments );
571
+				if ( ! is_array($comments)) {
572
+					$comments = array($comments);
573 573
 				}
574
-				foreach ( $comments as $comment ) {
574
+				foreach ($comments as $comment) {
575 575
 					$user_id = $comment->user_id;
576
-					$content = maybe_unserialize( base64_decode( $comment->comment_content ) );
577
-					$old_user_answers[ $quiz_id ][ $user_id ] = $content;
576
+					$content = maybe_unserialize(base64_decode($comment->comment_content));
577
+					$old_user_answers[$quiz_id][$user_id] = $content;
578 578
 				}
579 579
 
580 580
 				// Get correct answers
581
-				$questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id );
582
-				if( is_array( $questions ) ) {
583
-					foreach( $questions as $question ) {
584
-						$right_answer = get_post_meta( $question->ID, '_question_right_answer', true );
585
-						$right_answers[ $quiz_id ][ $question->ID ] = $right_answer;
581
+				$questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id);
582
+				if (is_array($questions)) {
583
+					foreach ($questions as $question) {
584
+						$right_answer = get_post_meta($question->ID, '_question_right_answer', true);
585
+						$right_answers[$quiz_id][$question->ID] = $right_answer;
586 586
 					}
587 587
 				}
588 588
 			}
589 589
 		}
590 590
 
591
-		if( is_array( $right_answers ) ) {
592
-			foreach( $right_answers as $quiz_id => $question ) {
591
+		if (is_array($right_answers)) {
592
+			foreach ($right_answers as $quiz_id => $question) {
593 593
 				$count = 0;
594
-				if( is_array( $question ) ) {
595
-					foreach( $question as $question_id => $answer ) {
594
+				if (is_array($question)) {
595
+					foreach ($question as $question_id => $answer) {
596 596
 						++$count;
597
-						if( isset( $old_user_answers[ $quiz_id ] ) ) {
598
-							$answers_linkup[ $quiz_id ][ $count ] = $question_id;
597
+						if (isset($old_user_answers[$quiz_id])) {
598
+							$answers_linkup[$quiz_id][$count] = $question_id;
599 599
 						}
600 600
 					}
601 601
 				}
602 602
 			}
603 603
 		}
604 604
 
605
-		if( is_array( $old_user_answers ) ) {
606
-			foreach( $old_user_answers as $quiz_id => $user_answers ) {
607
-				foreach( $user_answers as $user_id => $answers ) {
608
-					foreach( $answers as $answer_id => $user_answer ) {
609
-						$question_id = $answers_linkup[ $quiz_id ][ $answer_id ];
610
-						$new_user_answers[ $question_id ] = $user_answer;
611
-						Sensei_Utils::sensei_grade_question_auto( $question_id, '', $user_answer, $user_id );
605
+		if (is_array($old_user_answers)) {
606
+			foreach ($old_user_answers as $quiz_id => $user_answers) {
607
+				foreach ($user_answers as $user_id => $answers) {
608
+					foreach ($answers as $answer_id => $user_answer) {
609
+						$question_id = $answers_linkup[$quiz_id][$answer_id];
610
+						$new_user_answers[$question_id] = $user_answer;
611
+						Sensei_Utils::sensei_grade_question_auto($question_id, '', $user_answer, $user_id);
612 612
 					}
613
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
614
-					Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id );
615
-					Sensei_Utils::sensei_save_quiz_answers( $new_user_answers, $user_id );
613
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
614
+					Sensei_Utils::sensei_start_lesson($lesson_id, $user_id);
615
+					Sensei_Utils::sensei_save_quiz_answers($new_user_answers, $user_id);
616 616
 				}
617 617
 			}
618 618
 		}
619 619
 
620
-		if ( $current_page == $total_pages ) {
620
+		if ($current_page == $total_pages) {
621 621
 			return true;
622 622
 		} else {
623 623
 			return false;
@@ -632,15 +632,15 @@  discard block
 block discarded – undo
632 632
 	 * @return boolean
633 633
 	 */
634 634
 	public function update_question_grade_points() {
635
-		$args = array(	'post_type' 		=> 'question',
635
+		$args = array('post_type' 		=> 'question',
636 636
 						'posts_per_page' 		=> -1,
637 637
 						'post_status'		=> 'publish',
638 638
 						'suppress_filters' 	=> 0
639 639
 						);
640
-		$questions = get_posts( $args );
640
+		$questions = get_posts($args);
641 641
 
642
-		foreach( $questions as $question ) {
643
-			update_post_meta( $question->ID, '_question_grade', '1' );
642
+		foreach ($questions as $question) {
643
+			update_post_meta($question->ID, '_question_grade', '1');
644 644
 		}
645 645
 		return true;
646 646
 	} // End update_question_grade_points
@@ -652,7 +652,7 @@  discard block
 block discarded – undo
652 652
 	 * @return boolean
653 653
 	 */
654 654
 	public function convert_essay_paste_questions() {
655
-		$args = array(	'post_type' 		=> 'question',
655
+		$args = array('post_type' 		=> 'question',
656 656
 						'posts_per_page' 		=> -1,
657 657
 						'post_status'		=> 'publish',
658 658
 						'tax_query'			=> array(
@@ -664,14 +664,14 @@  discard block
 block discarded – undo
664 664
 						),
665 665
 						'suppress_filters' 	=> 0
666 666
 						);
667
-		$questions = get_posts( $args );
667
+		$questions = get_posts($args);
668 668
 
669
-		foreach( $questions as $question ) {
670
-			wp_set_object_terms( $question->ID, 'multi-line', 'question-type', false );
669
+		foreach ($questions as $question) {
670
+			wp_set_object_terms($question->ID, 'multi-line', 'question-type', false);
671 671
 
672
-			$quiz_id = get_post_meta( $question->ID, '_quiz_id', true );
673
-			if( 0 < intval( $quiz_id ) ) {
674
-				add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '0000', true );
672
+			$quiz_id = get_post_meta($question->ID, '_quiz_id', true);
673
+			if (0 < intval($quiz_id)) {
674
+				add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'0000', true);
675 675
 			}
676 676
 		}
677 677
 		return true;
@@ -683,33 +683,33 @@  discard block
 block discarded – undo
683 683
 	 * @since  1.5.0
684 684
 	 * @return boolean
685 685
 	 */
686
-	public function set_random_question_order( $n = 50, $offset = 0 ) {
686
+	public function set_random_question_order($n = 50, $offset = 0) {
687 687
 
688 688
 		// Get Total Number of Updates to run
689
-		$quiz_count_object = wp_count_posts( 'quiz' );
689
+		$quiz_count_object = wp_count_posts('quiz');
690 690
 		$quiz_count_published = $quiz_count_object->publish;
691 691
 
692 692
 		// Calculate if this is the last page
693
-		if ( 0 == $offset ) {
693
+		if (0 == $offset) {
694 694
 			$current_page = 1;
695 695
 		} else {
696
-			$current_page = intval( $offset / $n );
696
+			$current_page = intval($offset / $n);
697 697
 		} // End If Statement
698
-		$total_pages = intval( $quiz_count_published / $n );
698
+		$total_pages = intval($quiz_count_published / $n);
699 699
 
700
-		$args = array(	'post_type' 		=> 'quiz',
700
+		$args = array('post_type' 		=> 'quiz',
701 701
 						'post_status'		=> 'any',
702 702
 						'posts_per_page' 		=> $n,
703 703
 						'offset'			=> $offset,
704 704
 						'suppress_filters' 	=> 0
705 705
 						);
706
-		$quizzes = get_posts( $args );
706
+		$quizzes = get_posts($args);
707 707
 
708
-		foreach( $quizzes as $quiz ) {
709
-			update_post_meta( $quiz->ID, '_random_question_order', 'yes' );
708
+		foreach ($quizzes as $quiz) {
709
+			update_post_meta($quiz->ID, '_random_question_order', 'yes');
710 710
 		}
711 711
 
712
-		if ( $current_page == $total_pages ) {
712
+		if ($current_page == $total_pages) {
713 713
 			return true;
714 714
 		} else {
715 715
 			return false;
@@ -723,37 +723,37 @@  discard block
 block discarded – undo
723 723
 	 * @since  1.5.0
724 724
 	 * @return boolean
725 725
 	 */
726
-	public function set_default_show_question_count( $n = 50, $offset = 0 ) {
726
+	public function set_default_show_question_count($n = 50, $offset = 0) {
727 727
 
728
-		$args = array(	'post_type' 		=> 'quiz',
728
+		$args = array('post_type' 		=> 'quiz',
729 729
 						'post_status'		=> 'any',
730 730
 						'posts_per_page' 		=> $n,
731 731
 						'offset'			=> $offset,
732 732
 						'meta_key'			=> '_show_questions',
733 733
 						'suppress_filters' 	=> 0
734 734
 						);
735
-		$quizzes = get_posts( $args );
735
+		$quizzes = get_posts($args);
736 736
 
737
-		$total_quizzes = count( $quizzes );
737
+		$total_quizzes = count($quizzes);
738 738
 
739
-		if( 0 == intval( $total_quizzes ) ) {
739
+		if (0 == intval($total_quizzes)) {
740 740
 			return true;
741 741
 		}
742 742
 
743
-		foreach( $quizzes as $quiz ) {
744
-			delete_post_meta( $quiz->ID, '_show_questions' );
743
+		foreach ($quizzes as $quiz) {
744
+			delete_post_meta($quiz->ID, '_show_questions');
745 745
 		}
746 746
 
747
-		$total_pages = intval( $total_quizzes / $n );
747
+		$total_pages = intval($total_quizzes / $n);
748 748
 
749 749
 		// Calculate if this is the last page
750
-		if ( 0 == $offset ) {
750
+		if (0 == $offset) {
751 751
 			$current_page = 1;
752 752
 		} else {
753
-			$current_page = intval( $offset / $n );
753
+			$current_page = intval($offset / $n);
754 754
 		} // End If Statement
755 755
 
756
-		if ( $current_page == $total_pages ) {
756
+		if ($current_page == $total_pages) {
757 757
 			return true;
758 758
 		} else {
759 759
 			return false;
@@ -761,17 +761,17 @@  discard block
 block discarded – undo
761 761
 
762 762
 	}
763 763
 
764
-	public function remove_deleted_user_activity( $n = 50, $offset = 0 ) {
764
+	public function remove_deleted_user_activity($n = 50, $offset = 0) {
765 765
 
766 766
 
767 767
 //		remove_filter( 'comments_clauses', array( Sensei()->admin, 'comments_admin_filter' ) );
768 768
 
769
-		$all_activity = get_comments( array( 'status' => 'approve' ) );
769
+		$all_activity = get_comments(array('status' => 'approve'));
770 770
 		$activity_count = array();
771
-		foreach( $all_activity as $activity ) {
772
-			if( '' == $activity->comment_type ) continue;
773
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
774
-			if( 0 == $activity->user_id ) continue;
771
+		foreach ($all_activity as $activity) {
772
+			if ('' == $activity->comment_type) continue;
773
+			if (strpos('sensei_', $activity->comment_type) != 0) continue;
774
+			if (0 == $activity->user_id) continue;
775 775
 			$activity_count[] = $activity->comment_ID;
776 776
 		}
777 777
 
@@ -781,35 +781,35 @@  discard block
 block discarded – undo
781 781
 			'status' => 'approve'
782 782
 		);
783 783
 
784
-		$activities = get_comments( $args );
784
+		$activities = get_comments($args);
785 785
 
786
-		foreach( $activities as $activity ) {
787
-			if( '' == $activity->comment_type ) continue;
788
-			if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue;
789
-			if( 0 == $activity->user_id ) continue;
786
+		foreach ($activities as $activity) {
787
+			if ('' == $activity->comment_type) continue;
788
+			if (strpos('sensei_', $activity->comment_type) != 0) continue;
789
+			if (0 == $activity->user_id) continue;
790 790
 
791
-			$user_exists = get_userdata( $activity->user_id );
791
+			$user_exists = get_userdata($activity->user_id);
792 792
 
793
-			if( ! $user_exists ) {
794
-				wp_delete_comment( intval( $activity->comment_ID ), true );
793
+			if ( ! $user_exists) {
794
+				wp_delete_comment(intval($activity->comment_ID), true);
795 795
 				wp_cache_flush();
796 796
 			}
797 797
 		}
798 798
 
799
-		$total_activities = count( $activity_count );
799
+		$total_activities = count($activity_count);
800 800
 
801
-		$total_pages = intval( $total_activities / $n );
801
+		$total_pages = intval($total_activities / $n);
802 802
 
803 803
 		// Calculate if this is the last page
804
-		if ( 0 == $offset ) {
804
+		if (0 == $offset) {
805 805
 			$current_page = 1;
806 806
 		} else {
807
-			$current_page = intval( $offset / $n );
807
+			$current_page = intval($offset / $n);
808 808
 		} // End If Statement
809 809
 
810 810
 //		add_filter( 'comments_clauses', array( Sensei()->admin, 'comments_admin_filter' ) );
811 811
 
812
-		if ( $current_page >= $total_pages ) {
812
+		if ($current_page >= $total_pages) {
813 813
 			return true;
814 814
 		} else {
815 815
 			return false;
@@ -818,16 +818,16 @@  discard block
 block discarded – undo
818 818
 	}
819 819
 
820 820
 	public function add_teacher_role() {
821
-		add_role( 'teacher', __( 'Teacher', 'woothemes-sensei' ), array( 'read' => true, 'manage_sensei_grades' => true ) );
821
+		add_role('teacher', __('Teacher', 'woothemes-sensei'), array('read' => true, 'manage_sensei_grades' => true));
822 822
 		return true;
823 823
 	}
824 824
 
825 825
 	public function add_sensei_caps() {
826
-		$role = get_role( 'administrator' );
826
+		$role = get_role('administrator');
827 827
 
828
-		if( ! is_null( $role ) ) {
829
-			$role->add_cap( 'manage_sensei' );
830
-			$role->add_cap( 'manage_sensei_grades' );
828
+		if ( ! is_null($role)) {
829
+			$role->add_cap('manage_sensei');
830
+			$role->add_cap('manage_sensei_grades');
831 831
 		}
832 832
 
833 833
 		return true;
@@ -841,16 +841,16 @@  discard block
 block discarded – undo
841 841
 			'suppress_filters' 	=> 0
842 842
 		);
843 843
 
844
-		$questions = get_posts( $args );
844
+		$questions = get_posts($args);
845 845
 
846
-		foreach( $questions as $question ) {
846
+		foreach ($questions as $question) {
847 847
 
848
-			if( ! isset( $question->ID ) ) continue;
848
+			if ( ! isset($question->ID)) continue;
849 849
 
850
-			$quiz_id = get_post_meta( $question->ID, '_quiz_id', true );
850
+			$quiz_id = get_post_meta($question->ID, '_quiz_id', true);
851 851
 
852
-			$question_order = get_post_meta( $question->ID, '_quiz_question_order', true );
853
-			update_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $question_order );
852
+			$question_order = get_post_meta($question->ID, '_quiz_question_order', true);
853
+			update_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $question_order);
854 854
 
855 855
 		}
856 856
 
@@ -859,15 +859,15 @@  discard block
 block discarded – undo
859 859
 
860 860
 	public function update_quiz_settings() {
861 861
 
862
-		$settings = get_option( 'woothemes-sensei-settings', array() );
862
+		$settings = get_option('woothemes-sensei-settings', array());
863 863
 
864 864
 		$lesson_completion = false;
865
-		if( isset( $settings['lesson_completion'] ) ) {
865
+		if (isset($settings['lesson_completion'])) {
866 866
 			$lesson_completion = $settings['lesson_completion'];
867 867
 		}
868 868
 
869 869
 		$reset_quiz_allowed = false;
870
-		if( isset( $settings['quiz_reset_allowed'] ) ) {
870
+		if (isset($settings['quiz_reset_allowed'])) {
871 871
 			$reset_quiz_allowed = $settings['quiz_reset_allowed'];
872 872
 		}
873 873
 
@@ -878,20 +878,20 @@  discard block
 block discarded – undo
878 878
 			'suppress_filters' 	=> 0
879 879
 		);
880 880
 
881
-		$quizzes = get_posts( $args );
881
+		$quizzes = get_posts($args);
882 882
 
883
-		foreach( $quizzes as $quiz ) {
883
+		foreach ($quizzes as $quiz) {
884 884
 
885
-			if( ! isset( $quiz->ID ) ) continue;
885
+			if ( ! isset($quiz->ID)) continue;
886 886
 
887
-			if( isset( $lesson_completion ) && 'passed' == $lesson_completion ) {
888
-				update_post_meta( $quiz->ID, '_pass_required', 'on' );
887
+			if (isset($lesson_completion) && 'passed' == $lesson_completion) {
888
+				update_post_meta($quiz->ID, '_pass_required', 'on');
889 889
 			} else {
890
-				update_post_meta( $quiz->ID, '_quiz_passmark', 0 );
890
+				update_post_meta($quiz->ID, '_quiz_passmark', 0);
891 891
 			}
892 892
 
893
-			if( isset( $reset_quiz_allowed ) && $reset_quiz_allowed ) {
894
-				update_post_meta( $quiz->ID, '_enable_quiz_reset', 'on' );
893
+			if (isset($reset_quiz_allowed) && $reset_quiz_allowed) {
894
+				update_post_meta($quiz->ID, '_enable_quiz_reset', 'on');
895 895
 			}
896 896
 		}
897 897
 
@@ -906,22 +906,22 @@  discard block
 block discarded – undo
906 906
 			'suppress_filters' 	=> 0
907 907
 		);
908 908
 
909
-		$lessons = get_posts( $args );
909
+		$lessons = get_posts($args);
910 910
 
911
-		foreach( $lessons as $lesson ) {
911
+		foreach ($lessons as $lesson) {
912 912
 
913
-			if( ! isset( $lesson->ID ) ) continue;
913
+			if ( ! isset($lesson->ID)) continue;
914 914
 
915
-			$course_id = get_post_meta( $lesson->ID, '_lesson_course', true);
915
+			$course_id = get_post_meta($lesson->ID, '_lesson_course', true);
916 916
 
917
-			if( $course_id ) {
918
-				update_post_meta( $lesson->ID, '_order_' . $course_id, 0 );
917
+			if ($course_id) {
918
+				update_post_meta($lesson->ID, '_order_'.$course_id, 0);
919 919
 			}
920 920
 
921
-            $module = Sensei()->modules->get_lesson_module( $lesson->ID );
921
+            $module = Sensei()->modules->get_lesson_module($lesson->ID);
922 922
 
923
-            if( $module ) {
924
-                update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 );
923
+            if ($module) {
924
+                update_post_meta($lesson->ID, '_order_module_'.$module->term_id, 0);
925 925
             }
926 926
 
927 927
 		}
@@ -930,10 +930,10 @@  discard block
 block discarded – undo
930 930
 	}
931 931
 
932 932
 	public function add_editor_caps() {
933
-		$role = get_role( 'editor' );
933
+		$role = get_role('editor');
934 934
 
935
-		if( ! is_null( $role ) ) {
936
-			$role->add_cap( 'manage_sensei_grades' );
935
+		if ( ! is_null($role)) {
936
+			$role->add_cap('manage_sensei_grades');
937 937
 		}
938 938
 
939 939
 		return true;
@@ -952,26 +952,26 @@  discard block
 block discarded – undo
952 952
 					WHERE m.meta_key = '_question_right_answer' AND m.meta_value LIKE '%|%' AND m.meta_value NOT LIKE '%||%'
953 953
 						AND m.post_id = tr.object_id AND tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.term_id = t.term_id
954 954
 						AND tt.taxonomy = 'question-type' AND t.slug = 'gap-fill'";
955
-		$wpdb->query( $sql );
955
+		$wpdb->query($sql);
956 956
 
957 957
 		return true;
958 958
 	}
959 959
 
960
-	public function update_quiz_lesson_relationship( $n = 50, $offset = 0 ) {
961
-		$count_object = wp_count_posts( 'quiz' );
960
+	public function update_quiz_lesson_relationship($n = 50, $offset = 0) {
961
+		$count_object = wp_count_posts('quiz');
962 962
 
963 963
 		$count_published = 0;
964
-		foreach ( $count_object AS $status => $count ) {
964
+		foreach ($count_object AS $status => $count) {
965 965
 			$count_published += $count;
966 966
 		}
967 967
 
968 968
 		// Calculate if this is the last page
969
-		if ( 0 == $offset ) {
969
+		if (0 == $offset) {
970 970
 			$current_page = 1;
971 971
 		} else {
972
-			$current_page = intval( $offset / $n );
972
+			$current_page = intval($offset / $n);
973 973
 		}
974
-		$total_pages = ceil( $count_published / $n );
974
+		$total_pages = ceil($count_published / $n);
975 975
 
976 976
 		$args = array(
977 977
 			'post_type' => 'quiz',
@@ -980,52 +980,52 @@  discard block
 block discarded – undo
980 980
 			'post_status' => 'any'
981 981
 		);
982 982
 
983
-		$quizzes = get_posts( $args );
983
+		$quizzes = get_posts($args);
984 984
 
985
-		foreach( $quizzes as $quiz ) {
985
+		foreach ($quizzes as $quiz) {
986 986
 
987
-			if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) continue;
987
+			if ( ! isset($quiz->ID) || 0 != $quiz->post_parent) continue;
988 988
 
989
-			$lesson_id = get_post_meta( $quiz->ID, '_quiz_lesson', true );
989
+			$lesson_id = get_post_meta($quiz->ID, '_quiz_lesson', true);
990 990
 
991
-			if( empty( $lesson_id ) ) continue;
991
+			if (empty($lesson_id)) continue;
992 992
 
993 993
 			$data = array(
994 994
 				'ID' => $quiz->ID,
995 995
 				'post_parent' => $lesson_id,
996 996
 			);
997
-			wp_update_post( $data );
997
+			wp_update_post($data);
998 998
 
999
-			update_post_meta( $lesson_id, '_lesson_quiz', $quiz->ID );
999
+			update_post_meta($lesson_id, '_lesson_quiz', $quiz->ID);
1000 1000
 		}
1001 1001
 
1002
-		if ( $current_page == $total_pages || 0 == $total_pages ) {
1002
+		if ($current_page == $total_pages || 0 == $total_pages) {
1003 1003
 			return true;
1004 1004
 		} else {
1005 1005
 			return false;
1006 1006
 		}
1007 1007
 	}
1008 1008
 
1009
-	function status_changes_fix_lessons( $n = 50, $offset = 0 ) {
1009
+	function status_changes_fix_lessons($n = 50, $offset = 0) {
1010 1010
 		global $wpdb;
1011 1011
 
1012
-		$count_object = wp_count_posts( 'lesson' );
1012
+		$count_object = wp_count_posts('lesson');
1013 1013
 		$count_published = 0;
1014
-		foreach ( $count_object AS $status => $count ) {
1014
+		foreach ($count_object AS $status => $count) {
1015 1015
 			$count_published += $count;
1016 1016
 		}
1017 1017
 
1018
-		if ( 0 == $count_published ) {
1018
+		if (0 == $count_published) {
1019 1019
 			return true;
1020 1020
 		}
1021 1021
 
1022 1022
 		// Calculate if this is the last page
1023
-		if ( 0 == $offset ) {
1023
+		if (0 == $offset) {
1024 1024
 			$current_page = 1;
1025 1025
 		} else {
1026
-			$current_page = intval( $offset / $n );
1026
+			$current_page = intval($offset / $n);
1027 1027
 		}
1028
-		$total_pages = ceil( $count_published / $n );
1028
+		$total_pages = ceil($count_published / $n);
1029 1029
 
1030 1030
 		// Get all Lessons with (and without) Quizzes...
1031 1031
 		$args = array(
@@ -1035,26 +1035,26 @@  discard block
 block discarded – undo
1035 1035
 			'offset' => $offset,
1036 1036
 			'fields' => 'ids'
1037 1037
 		);
1038
-		$lesson_ids = get_posts( $args );
1038
+		$lesson_ids = get_posts($args);
1039 1039
 
1040 1040
 		// ...get all Quiz IDs for the above Lessons
1041
-		$id_list = join( ',', $lesson_ids );
1042
-		$meta_list = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A );
1041
+		$id_list = join(',', $lesson_ids);
1042
+		$meta_list = $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A);
1043 1043
 		$lesson_quiz_ids = array();
1044
-		if ( !empty($meta_list) ) {
1045
-			foreach ( $meta_list as $metarow ) {
1044
+		if ( ! empty($meta_list)) {
1045
+			foreach ($meta_list as $metarow) {
1046 1046
 				$lesson_id = $metarow['meta_value'];
1047 1047
 				$quiz_id = $metarow['post_id'];
1048
-				$lesson_quiz_ids[ $lesson_id ] = $quiz_id;
1048
+				$lesson_quiz_ids[$lesson_id] = $quiz_id;
1049 1049
 			}
1050 1050
 		}
1051 1051
 
1052 1052
 		// ...check all Quiz IDs for questions
1053
-		$id_list = join( ',', array_values($lesson_quiz_ids) );
1054
-		$meta_list = $wpdb->get_results( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A );
1053
+		$id_list = join(',', array_values($lesson_quiz_ids));
1054
+		$meta_list = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A);
1055 1055
 		$lesson_quiz_ids_with_questions = array();
1056
-		if ( !empty($meta_list) ) {
1057
-			foreach ( $meta_list as $metarow ) {
1056
+		if ( ! empty($meta_list)) {
1057
+			foreach ($meta_list as $metarow) {
1058 1058
 				$quiz_id = $metarow['meta_value'];
1059 1059
 				$lesson_quiz_ids_with_questions[] = $quiz_id;
1060 1060
 			}
@@ -1062,49 +1062,49 @@  discard block
 block discarded – undo
1062 1062
 
1063 1063
 		// For each quiz check there are questions, if not remove the corresponding meta keys from Quizzes and Lessons
1064 1064
 		// if there are questions on the quiz add the corresponding meta keys to Quizzes and Lessons
1065
-		$d_count = $a_count =0;
1066
-		foreach ( $lesson_quiz_ids AS $lesson_id => $quiz_id ) {
1067
-			if ( !in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1065
+		$d_count = $a_count = 0;
1066
+		foreach ($lesson_quiz_ids AS $lesson_id => $quiz_id) {
1067
+			if ( ! in_array($quiz_id, $lesson_quiz_ids_with_questions)) {
1068 1068
 
1069 1069
 				// Quiz has no questions, drop the corresponding data
1070
-				delete_post_meta( $quiz_id, '_pass_required' );
1071
-				delete_post_meta( $quiz_id, '_quiz_passmark' );
1072
-				delete_post_meta( $lesson_id, '_quiz_has_questions' );
1070
+				delete_post_meta($quiz_id, '_pass_required');
1071
+				delete_post_meta($quiz_id, '_quiz_passmark');
1072
+				delete_post_meta($lesson_id, '_quiz_has_questions');
1073 1073
 				$d_count++;
1074 1074
 			}
1075
-			else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) {
1075
+			else if (in_array($quiz_id, $lesson_quiz_ids_with_questions)) {
1076 1076
 
1077 1077
 				// Quiz has no questions, drop the corresponding data
1078
-				update_post_meta( $lesson_id, '_quiz_has_questions', true );
1078
+				update_post_meta($lesson_id, '_quiz_has_questions', true);
1079 1079
 				$a_count++;
1080 1080
 			}
1081 1081
 		}
1082 1082
 
1083
-		if ( $current_page == $total_pages ) {
1083
+		if ($current_page == $total_pages) {
1084 1084
 			return true;
1085 1085
 		} else {
1086 1086
 			return false;
1087 1087
 		}
1088 1088
 	}
1089 1089
 
1090
-	function status_changes_convert_lessons( $n = 50, $offset = 0 ) {
1090
+	function status_changes_convert_lessons($n = 50, $offset = 0) {
1091 1091
 		global $wpdb;
1092 1092
 
1093
-		wp_defer_comment_counting( true );
1093
+		wp_defer_comment_counting(true);
1094 1094
 
1095
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1095
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1096 1096
 
1097
-		if ( 0 == $user_count_result ) {
1097
+		if (0 == $user_count_result) {
1098 1098
 			return true;
1099 1099
 		}
1100 1100
 
1101
-		if ( 0 == $offset ) {
1101
+		if (0 == $offset) {
1102 1102
 			$current_page = 1;
1103 1103
 		} else {
1104
-			$current_page = intval( $offset / $n );
1104
+			$current_page = intval($offset / $n);
1105 1105
 		}
1106 1106
 
1107
-		$total_pages = ceil( $user_count_result / $n );
1107
+		$total_pages = ceil($user_count_result / $n);
1108 1108
 
1109 1109
 		// Get all Lessons with Quizzes...
1110 1110
 		$args = array(
@@ -1119,34 +1119,34 @@  discard block
 block discarded – undo
1119 1119
 			),
1120 1120
 			'fields' => 'ids'
1121 1121
 		);
1122
-		$lesson_ids_with_quizzes = get_posts( $args );
1122
+		$lesson_ids_with_quizzes = get_posts($args);
1123 1123
 		// ...get all Quiz IDs for the above Lessons
1124
-		$id_list = join( ',', $lesson_ids_with_quizzes );
1125
-		$meta_list = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A );
1124
+		$id_list = join(',', $lesson_ids_with_quizzes);
1125
+		$meta_list = $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A);
1126 1126
 		$lesson_quiz_ids = array();
1127
-		if ( !empty($meta_list) ) {
1128
-			foreach ( $meta_list as $metarow ) {
1127
+		if ( ! empty($meta_list)) {
1128
+			foreach ($meta_list as $metarow) {
1129 1129
 				$lesson_id = $metarow['meta_value'];
1130 1130
 				$quiz_id = $metarow['post_id'];
1131
-				$lesson_quiz_ids[ $lesson_id ] = $quiz_id;
1131
+				$lesson_quiz_ids[$lesson_id] = $quiz_id;
1132 1132
 			}
1133 1133
 		}
1134 1134
 
1135 1135
 		// ...get all Pass Required & Passmarks for the above Lesson/Quizzes
1136
-		$id_list = join( ',', array_values($lesson_quiz_ids) );
1137
-		$meta_list = $wpdb->get_results( "SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE ( meta_key = '_pass_required' OR meta_key = '_quiz_passmark' ) AND post_id IN ($id_list)", ARRAY_A );
1136
+		$id_list = join(',', array_values($lesson_quiz_ids));
1137
+		$meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE ( meta_key = '_pass_required' OR meta_key = '_quiz_passmark' ) AND post_id IN ($id_list)", ARRAY_A);
1138 1138
 		$quizzes_pass_required = $quizzes_passmarks = array();
1139
-		if ( !empty($meta_list) ) {
1140
-			foreach ( $meta_list as $metarow ) {
1141
-				if ( !empty($metarow['meta_value']) ) {
1139
+		if ( ! empty($meta_list)) {
1140
+			foreach ($meta_list as $metarow) {
1141
+				if ( ! empty($metarow['meta_value'])) {
1142 1142
 					$quiz_id = $metarow['post_id'];
1143 1143
 					$key = $metarow['meta_key'];
1144 1144
 					$value = $metarow['meta_value'];
1145
-					if ( '_pass_required' == $key ) {
1146
-						$quizzes_pass_required[ $quiz_id ] = $value;
1145
+					if ('_pass_required' == $key) {
1146
+						$quizzes_pass_required[$quiz_id] = $value;
1147 1147
 					}
1148
-					if ( '_quiz_passmark' == $key ) {
1149
-						$quizzes_passmarks[ $quiz_id ] = $value;
1148
+					if ('_quiz_passmark' == $key) {
1149
+						$quizzes_passmarks[$quiz_id] = $value;
1150 1150
 					}
1151 1151
 				}
1152 1152
 			}
@@ -1160,41 +1160,41 @@  discard block
 block discarded – undo
1160 1160
 		$check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_lesson_status' ";
1161 1161
 
1162 1162
 		// $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time?
1163
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1163
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1164 1164
 
1165
-		foreach ( $user_ids AS $user_id ) {
1165
+		foreach ($user_ids AS $user_id) {
1166 1166
 
1167 1167
 			$lesson_ends = $lesson_grades = $lesson_answers = array();
1168 1168
 
1169 1169
 			// Pre-process the lesson ends
1170
-			$_lesson_ends = $wpdb->get_results( $wpdb->prepare($end_sql, $user_id), ARRAY_A );
1171
-			foreach ( $_lesson_ends as $lesson_end ) {
1170
+			$_lesson_ends = $wpdb->get_results($wpdb->prepare($end_sql, $user_id), ARRAY_A);
1171
+			foreach ($_lesson_ends as $lesson_end) {
1172 1172
 				// This will overwrite existing entries with the newer ones
1173
-				$lesson_ends[ $lesson_end['comment_post_ID'] ] = $lesson_end['comment_date'];
1173
+				$lesson_ends[$lesson_end['comment_post_ID']] = $lesson_end['comment_date'];
1174 1174
 			}
1175
-			unset( $_lesson_ends );
1175
+			unset($_lesson_ends);
1176 1176
 
1177 1177
 			// Pre-process the lesson grades
1178
-			$_lesson_grades = $wpdb->get_results( $wpdb->prepare($grade_sql, $user_id), ARRAY_A );
1179
-			foreach ( $_lesson_grades as $lesson_grade ) {
1178
+			$_lesson_grades = $wpdb->get_results($wpdb->prepare($grade_sql, $user_id), ARRAY_A);
1179
+			foreach ($_lesson_grades as $lesson_grade) {
1180 1180
 				// This will overwrite existing entries with the newer ones (assuming the grade is higher)
1181
-				if ( empty($lesson_grades[ $lesson_grade['comment_post_ID'] ]) || $lesson_grades[ $lesson_grade['comment_post_ID'] ] < $lesson_grade['comment_content'] ) {
1182
-					$lesson_grades[ $lesson_grade['comment_post_ID'] ] = $lesson_grade['comment_content'];
1181
+				if (empty($lesson_grades[$lesson_grade['comment_post_ID']]) || $lesson_grades[$lesson_grade['comment_post_ID']] < $lesson_grade['comment_content']) {
1182
+					$lesson_grades[$lesson_grade['comment_post_ID']] = $lesson_grade['comment_content'];
1183 1183
 				}
1184 1184
 			}
1185
-			unset( $_lesson_grades );
1185
+			unset($_lesson_grades);
1186 1186
 
1187 1187
 			// Pre-process the lesson answers
1188
-			$_lesson_answers = $wpdb->get_results( $wpdb->prepare($answers_sql, $user_id), ARRAY_A );
1189
-			foreach ( $_lesson_answers as $lesson_answer ) {
1188
+			$_lesson_answers = $wpdb->get_results($wpdb->prepare($answers_sql, $user_id), ARRAY_A);
1189
+			foreach ($_lesson_answers as $lesson_answer) {
1190 1190
 				// This will overwrite existing entries with the newer ones
1191
-				$lesson_answers[ $lesson_answer['comment_post_ID'] ] = $lesson_answer['comment_content'];
1191
+				$lesson_answers[$lesson_answer['comment_post_ID']] = $lesson_answer['comment_content'];
1192 1192
 			}
1193
-			unset( $_lesson_answers );
1193
+			unset($_lesson_answers);
1194 1194
 
1195 1195
 			// Grab all the lesson starts for the user
1196
-			$lesson_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A );
1197
-			foreach ( $lesson_starts as $lesson_log ) {
1196
+			$lesson_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A);
1197
+			foreach ($lesson_starts as $lesson_log) {
1198 1198
 
1199 1199
 				$lesson_id = $lesson_log['comment_post_ID'];
1200 1200
 
@@ -1207,23 +1207,23 @@  discard block
 block discarded – undo
1207 1207
 					'start' => $status_date,
1208 1208
 				);
1209 1209
 				// Check if there is a lesson end
1210
-				if ( !empty($lesson_ends[$lesson_id]) ) {
1210
+				if ( ! empty($lesson_ends[$lesson_id])) {
1211 1211
 					$status_date = $lesson_ends[$lesson_id];
1212 1212
 					// Check lesson has quiz
1213
-					if ( !empty( $lesson_quiz_ids[$lesson_id] ) ) {
1213
+					if ( ! empty($lesson_quiz_ids[$lesson_id])) {
1214 1214
 						// Check for the quiz answers
1215
-						if ( !empty($lesson_answers[$quiz_id]) ) {
1215
+						if ( ! empty($lesson_answers[$quiz_id])) {
1216 1216
 							$meta_data['questions_asked'] = $lesson_answers[$quiz_id];
1217 1217
 						}
1218 1218
 						// Check if there is a quiz grade
1219 1219
 						$quiz_id = $lesson_quiz_ids[$lesson_id];
1220
-						if ( !empty($lesson_grades[$quiz_id]) ) {
1220
+						if ( ! empty($lesson_grades[$quiz_id])) {
1221 1221
 							$meta_data['grade'] = $quiz_grade = $lesson_grades[$quiz_id];
1222 1222
 							// Check if the user has to get the passmark and has or not
1223
-							if ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] <= $quiz_grade ) {
1223
+							if ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] <= $quiz_grade) {
1224 1224
 								$status = 'passed';
1225 1225
 							}
1226
-							elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) {
1226
+							elseif ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] > $quiz_grade) {
1227 1227
 								$status = 'failed';
1228 1228
 							}
1229 1229
 							else {
@@ -1251,26 +1251,26 @@  discard block
 block discarded – undo
1251 1251
 						'comment_author' => '',
1252 1252
 					);
1253 1253
 				// Check it doesn't already exist
1254
-				$sql = $wpdb->prepare( $check_existing_sql, $lesson_id, $user_id );
1255
-				$comment_ID = $wpdb->get_var( $sql );
1256
-				if ( !$comment_ID ) {
1254
+				$sql = $wpdb->prepare($check_existing_sql, $lesson_id, $user_id);
1255
+				$comment_ID = $wpdb->get_var($sql);
1256
+				if ( ! $comment_ID) {
1257 1257
 					// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1258 1258
 					$wpdb->insert($wpdb->comments, $data);
1259 1259
 					$comment_ID = (int) $wpdb->insert_id;
1260 1260
 
1261
-					if ( $comment_ID && !empty($meta_data) ) {
1262
-						foreach ( $meta_data as $key => $value ) {
1261
+					if ($comment_ID && ! empty($meta_data)) {
1262
+						foreach ($meta_data as $key => $value) {
1263 1263
 							// Bypassing WP add_comment_meta(() so no actions/filters are run
1264
-							if ( $wpdb->get_var( $wpdb->prepare(
1264
+							if ($wpdb->get_var($wpdb->prepare(
1265 1265
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1266
-									$comment_ID, $key ) ) ) {
1266
+									$comment_ID, $key ))) {
1267 1267
 									continue; // Found the meta data already
1268 1268
 							}
1269
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1269
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1270 1270
 								'comment_id' => $comment_ID,
1271 1271
 								'meta_key' => $key,
1272 1272
 								'meta_value' => $value
1273
-							) );
1273
+							));
1274 1274
 						}
1275 1275
 					}
1276 1276
 				}
@@ -1278,40 +1278,40 @@  discard block
 block discarded – undo
1278 1278
 		}
1279 1279
 		$wpdb->flush();
1280 1280
 
1281
-		if ( $current_page == $total_pages ) {
1281
+		if ($current_page == $total_pages) {
1282 1282
 			return true;
1283 1283
 		} else {
1284 1284
 			return false;
1285 1285
 		}
1286 1286
 	}
1287 1287
 
1288
-	function status_changes_convert_courses( $n = 50, $offset = 0 ) {
1288
+	function status_changes_convert_courses($n = 50, $offset = 0) {
1289 1289
 		global $wpdb;
1290 1290
 
1291
-		wp_defer_comment_counting( true );
1291
+		wp_defer_comment_counting(true);
1292 1292
 
1293
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1293
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1294 1294
 
1295
-		if ( 0 == $user_count_result ) {
1295
+		if (0 == $user_count_result) {
1296 1296
 			return true;
1297 1297
 		}
1298 1298
 
1299
-		if ( 0 == $offset ) {
1299
+		if (0 == $offset) {
1300 1300
 			$current_page = 1;
1301 1301
 		} else {
1302
-			$current_page = intval( $offset / $n );
1302
+			$current_page = intval($offset / $n);
1303 1303
 		}
1304 1304
 
1305
-		$total_pages = ceil( $user_count_result / $n );
1305
+		$total_pages = ceil($user_count_result / $n);
1306 1306
 
1307 1307
 		// Get all Lesson => Course relationships
1308
-		$meta_list = $wpdb->get_results( "SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course'", ARRAY_A );
1308
+		$meta_list = $wpdb->get_results("SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course'", ARRAY_A);
1309 1309
 		$course_lesson_ids = array();
1310
-		if ( !empty($meta_list) ) {
1311
-			foreach ( $meta_list as $metarow ) {
1310
+		if ( ! empty($meta_list)) {
1311
+			foreach ($meta_list as $metarow) {
1312 1312
 				$lesson_id = $metarow['post_id'];
1313 1313
 				$course_id = $metarow['meta_value'];
1314
-				$course_lesson_ids[ $course_id ][] = $lesson_id;
1314
+				$course_lesson_ids[$course_id][] = $lesson_id;
1315 1315
 			}
1316 1316
 		}
1317 1317
 
@@ -1321,13 +1321,13 @@  discard block
 block discarded – undo
1321 1321
 		$check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_course_status' ";
1322 1322
 
1323 1323
 		// $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time?
1324
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1324
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1325 1325
 
1326
-		foreach ( $user_ids AS $user_id ) {
1326
+		foreach ($user_ids AS $user_id) {
1327 1327
 
1328 1328
 			// Grab all the course starts for the user
1329
-			$course_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A );
1330
-			foreach ( $course_starts as $course_log ) {
1329
+			$course_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A);
1330
+			foreach ($course_starts as $course_log) {
1331 1331
 
1332 1332
 				$course_id = $course_log['comment_post_ID'];
1333 1333
 
@@ -1342,23 +1342,23 @@  discard block
 block discarded – undo
1342 1342
 					'percent' => 0,
1343 1343
 				);
1344 1344
 				// Check if the course has lessons
1345
-				if ( !empty( $course_lesson_ids[$course_id] ) ) {
1345
+				if ( ! empty($course_lesson_ids[$course_id])) {
1346 1346
 
1347 1347
 					$lessons_completed = 0;
1348
-					$total_lessons = count( $course_lesson_ids[ $course_id ] );
1348
+					$total_lessons = count($course_lesson_ids[$course_id]);
1349 1349
 
1350 1350
 					// Don't use prepare as we need to provide the id join
1351
-					$sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[ $course_id ]) );
1351
+					$sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[$course_id]));
1352 1352
 					// Get all lesson statuses for this Courses' lessons
1353
-					$lesson_statuses = $wpdb->get_results( $sql, ARRAY_A );
1353
+					$lesson_statuses = $wpdb->get_results($sql, ARRAY_A);
1354 1354
 					// Not enough lesson statuses, thus cannot be complete
1355
-					if ( $total_lessons > count($lesson_statuses) ) {
1355
+					if ($total_lessons > count($lesson_statuses)) {
1356 1356
 						$status = 'in-progress';
1357 1357
 					}
1358 1358
 					// Count each lesson to work out the overall percentage
1359
-					foreach ( $lesson_statuses as $lesson_status ) {
1359
+					foreach ($lesson_statuses as $lesson_status) {
1360 1360
 						$status_date = $lesson_status['comment_date'];
1361
-						switch ( $lesson_status['status'] ) {
1361
+						switch ($lesson_status['status']) {
1362 1362
 							case 'complete': // Lesson has no quiz/questions
1363 1363
 							case 'graded': // Lesson has quiz, but it's not important what the grade was
1364 1364
 							case 'passed':
@@ -1373,7 +1373,7 @@  discard block
 block discarded – undo
1373 1373
 						}
1374 1374
 					}
1375 1375
 					$meta_data['complete'] = $lessons_completed;
1376
-					$meta_data['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) );
1376
+					$meta_data['percent'] = abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0));
1377 1377
 				}
1378 1378
 				else {
1379 1379
 					// Course has no lessons, therefore cannot be 'complete'
@@ -1390,26 +1390,26 @@  discard block
 block discarded – undo
1390 1390
 						'comment_author' => '',
1391 1391
 					);
1392 1392
 				// Check it doesn't already exist
1393
-				$sql = $wpdb->prepare( $check_existing_sql, $course_id, $user_id );
1394
-				$comment_ID = $wpdb->get_var( $sql );
1395
-				if ( !$comment_ID ) {
1393
+				$sql = $wpdb->prepare($check_existing_sql, $course_id, $user_id);
1394
+				$comment_ID = $wpdb->get_var($sql);
1395
+				if ( ! $comment_ID) {
1396 1396
 					// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1397 1397
 					$wpdb->insert($wpdb->comments, $data);
1398 1398
 					$comment_ID = (int) $wpdb->insert_id;
1399 1399
 
1400
-					if ( $comment_ID && !empty($meta_data) ) {
1401
-						foreach ( $meta_data as $key => $value ) {
1400
+					if ($comment_ID && ! empty($meta_data)) {
1401
+						foreach ($meta_data as $key => $value) {
1402 1402
 							// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1403
-							if ( $wpdb->get_var( $wpdb->prepare(
1403
+							if ($wpdb->get_var($wpdb->prepare(
1404 1404
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1405
-									$comment_ID, $key ) ) ) {
1405
+									$comment_ID, $key ))) {
1406 1406
 									continue; // Found the meta data already
1407 1407
 							}
1408
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1408
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1409 1409
 								'comment_id' => $comment_ID,
1410 1410
 								'meta_key' => $key,
1411 1411
 								'meta_value' => $value
1412
-							) );
1412
+							));
1413 1413
 						}
1414 1414
 					}
1415 1415
 				}
@@ -1417,7 +1417,7 @@  discard block
 block discarded – undo
1417 1417
 		}
1418 1418
 		$wpdb->flush();
1419 1419
 
1420
-		if ( $current_page == $total_pages ) {
1420
+		if ($current_page == $total_pages) {
1421 1421
 			return true;
1422 1422
 		} else {
1423 1423
 			return false;
@@ -1433,70 +1433,70 @@  discard block
 block discarded – undo
1433 1433
 	 * @param type $offset
1434 1434
 	 * @return boolean
1435 1435
 	 */
1436
-	function status_changes_repair_course_statuses( $n = 50, $offset = 0 ) {
1436
+	function status_changes_repair_course_statuses($n = 50, $offset = 0) {
1437 1437
 		global $wpdb;
1438 1438
 
1439
-		$count_object = wp_count_posts( 'lesson' );
1439
+		$count_object = wp_count_posts('lesson');
1440 1440
 		$count_published = $count_object->publish;
1441 1441
 
1442
-		if ( 0 == $count_published ) {
1442
+		if (0 == $count_published) {
1443 1443
 			return true;
1444 1444
 		}
1445 1445
 
1446 1446
 		// Calculate if this is the last page
1447
-		if ( 0 == $offset ) {
1447
+		if (0 == $offset) {
1448 1448
 			$current_page = 1;
1449 1449
 		} else {
1450
-			$current_page = intval( $offset / $n );
1450
+			$current_page = intval($offset / $n);
1451 1451
 		}
1452
-		$total_pages = ceil( $count_published / $n );
1452
+		$total_pages = ceil($count_published / $n);
1453 1453
 
1454 1454
 		$course_lesson_ids = $lesson_user_statuses = array();
1455 1455
 
1456 1456
 		// Get all Lesson => Course relationships
1457
-		$meta_list = $wpdb->get_results( "SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course' LIMIT $n OFFSET $offset ", ARRAY_A );
1458
-		if ( !empty($meta_list) ) {
1459
-			foreach ( $meta_list as $metarow ) {
1457
+		$meta_list = $wpdb->get_results("SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course' LIMIT $n OFFSET $offset ", ARRAY_A);
1458
+		if ( ! empty($meta_list)) {
1459
+			foreach ($meta_list as $metarow) {
1460 1460
 				$lesson_id = $metarow['post_id'];
1461 1461
 				$course_id = $metarow['meta_value'];
1462
-				$course_lesson_ids[ $course_id ][] = $lesson_id;
1462
+				$course_lesson_ids[$course_id][] = $lesson_id;
1463 1463
 			}
1464 1464
 		}
1465 1465
 
1466 1466
 		// Get all Lesson => Course relationships
1467
-		$status_list = $wpdb->get_results( "SELECT user_id, comment_post_ID, comment_approved FROM $wpdb->comments WHERE comment_type = 'sensei_lesson_status' GROUP BY user_id, comment_post_ID ", ARRAY_A );
1468
-		if ( !empty($status_list) ) {
1469
-			foreach ( $status_list as $status ) {
1470
-				$lesson_user_statuses[ $status['comment_post_ID'] ][ $status['user_id'] ] = $status['comment_approved'];
1467
+		$status_list = $wpdb->get_results("SELECT user_id, comment_post_ID, comment_approved FROM $wpdb->comments WHERE comment_type = 'sensei_lesson_status' GROUP BY user_id, comment_post_ID ", ARRAY_A);
1468
+		if ( ! empty($status_list)) {
1469
+			foreach ($status_list as $status) {
1470
+				$lesson_user_statuses[$status['comment_post_ID']][$status['user_id']] = $status['comment_approved'];
1471 1471
 			}
1472 1472
 		}
1473 1473
 
1474
-		$course_completion = Sensei()->settings->settings[ 'course_completion' ];
1474
+		$course_completion = Sensei()->settings->settings['course_completion'];
1475 1475
 
1476 1476
 		$per_page = 40;
1477 1477
 		$comment_id_offset = $count = 0;
1478 1478
 
1479 1479
 		$course_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_course_status' AND comment_ID > %d LIMIT $per_page";
1480 1480
 		// $per_page users at a time
1481
-		while ( $course_statuses = $wpdb->get_results( $wpdb->prepare($course_sql, $comment_id_offset) ) ) {
1481
+		while ($course_statuses = $wpdb->get_results($wpdb->prepare($course_sql, $comment_id_offset))) {
1482 1482
 
1483
-			foreach ( $course_statuses AS $course_status ) {
1483
+			foreach ($course_statuses AS $course_status) {
1484 1484
 				$user_id = $course_status->user_id;
1485 1485
 				$course_id = $course_status->comment_post_ID;
1486
-				$total_lessons = count( $course_lesson_ids[ $course_id ] );
1487
-				if ( $total_lessons <= 0 ) {
1486
+				$total_lessons = count($course_lesson_ids[$course_id]);
1487
+				if ($total_lessons <= 0) {
1488 1488
 					$total_lessons = 1; // Fix division of zero error, some courses have no lessons
1489 1489
 				}
1490 1490
 				$lessons_completed = 0;
1491 1491
 				$status = 'in-progress';
1492 1492
 
1493 1493
 				// Some Courses have no lessons... (can they ever be complete?)
1494
-				if ( !empty($course_lesson_ids[ $course_id ]) ) {
1495
-					foreach( $course_lesson_ids[ $course_id ] AS $lesson_id ) {
1496
-						$lesson_status = $lesson_user_statuses[ $lesson_id ][ $user_id ];
1494
+				if ( ! empty($course_lesson_ids[$course_id])) {
1495
+					foreach ($course_lesson_ids[$course_id] AS $lesson_id) {
1496
+						$lesson_status = $lesson_user_statuses[$lesson_id][$user_id];
1497 1497
 						// If lessons are complete without needing quizzes to be passed
1498
-						if ( 'passed' != $course_completion ) {
1499
-							switch ( $lesson_status ) {
1498
+						if ('passed' != $course_completion) {
1499
+							switch ($lesson_status) {
1500 1500
 								// A user cannot 'complete' a course if a lesson...
1501 1501
 								case 'in-progress': // ...is still in progress
1502 1502
 								case 'ungraded': // ...hasn't yet been graded
@@ -1508,7 +1508,7 @@  discard block
 block discarded – undo
1508 1508
 							}
1509 1509
 						}
1510 1510
 						else {
1511
-							switch ( $lesson_status ) {
1511
+							switch ($lesson_status) {
1512 1512
 								case 'complete': // Lesson has no quiz/questions
1513 1513
 								case 'graded': // Lesson has quiz, but it's not important what the grade was
1514 1514
 								case 'passed': // Lesson has quiz and the user passed
@@ -1523,79 +1523,79 @@  discard block
 block discarded – undo
1523 1523
 						}
1524 1524
 					} // Each lesson
1525 1525
 				} // Check for lessons
1526
-				if ( $lessons_completed == $total_lessons ) {
1526
+				if ($lessons_completed == $total_lessons) {
1527 1527
 					$status = 'complete';
1528 1528
 				}
1529 1529
 				// update the overall percentage of the course lessons complete (or graded) compared to 'in-progress' regardless of the above
1530 1530
 				$metadata = array(
1531 1531
 					'complete' => $lessons_completed,
1532
-					'percent' => abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) ),
1532
+					'percent' => abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0)),
1533 1533
 				);
1534
-				Sensei_Utils::update_course_status( $user_id, $course_id, $status, $metadata );
1534
+				Sensei_Utils::update_course_status($user_id, $course_id, $status, $metadata);
1535 1535
 				$count++;
1536 1536
 
1537 1537
 			} // per course status
1538 1538
 			$comment_id_offset = $course_status->comment_ID;
1539 1539
 		} // all course statuses
1540 1540
 
1541
-		if ( $current_page == $total_pages ) {
1541
+		if ($current_page == $total_pages) {
1542 1542
 			return true;
1543 1543
 		} else {
1544 1544
 			return false;
1545 1545
 		}
1546 1546
 	}
1547 1547
 
1548
-	function status_changes_convert_questions( $n = 50, $offset = 0 ) {
1548
+	function status_changes_convert_questions($n = 50, $offset = 0) {
1549 1549
 		global $wpdb;
1550 1550
 
1551
-		wp_defer_comment_counting( true );
1551
+		wp_defer_comment_counting(true);
1552 1552
 
1553
-		$user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " );
1553
+		$user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users ");
1554 1554
 
1555
-		if ( 0 == $user_count_result ) {
1555
+		if (0 == $user_count_result) {
1556 1556
 			return true;
1557 1557
 		}
1558 1558
 
1559 1559
 		// Calculate if this is the last page
1560
-		if ( 0 == $offset ) {
1560
+		if (0 == $offset) {
1561 1561
 			$current_page = 1;
1562 1562
 		} else {
1563
-			$current_page = intval( $offset / $n );
1563
+			$current_page = intval($offset / $n);
1564 1564
 		}
1565 1565
 
1566
-		$total_pages = ceil( $user_count_result / $n );
1566
+		$total_pages = ceil($user_count_result / $n);
1567 1567
 
1568 1568
 		$users_sql = "SELECT ID FROM $wpdb->users ORDER BY ID ASC LIMIT %d OFFSET %d";
1569 1569
 		$answers_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_user_answer' AND user_id = %d GROUP BY comment_post_ID ";
1570 1570
 		$grades_sql = "SELECT comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_type = 'sensei_user_grade' AND user_id = %d GROUP BY comment_post_ID ";
1571 1571
 		$notes_sql = "SELECT comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_type = 'sensei_answer_notes' AND user_id = %d GROUP BY comment_post_ID ";
1572 1572
 
1573
-		$user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) );
1573
+		$user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset));
1574 1574
 
1575
-		foreach ( $user_ids AS $user_id ) {
1575
+		foreach ($user_ids AS $user_id) {
1576 1576
 
1577 1577
 			$answer_grades = $answer_notes = array();
1578 1578
 
1579 1579
 			// Pre-process the answer grades
1580
-			$_answer_grades = $wpdb->get_results( $wpdb->prepare($grades_sql, $user_id), ARRAY_A );
1581
-			foreach ( $_answer_grades as $answer_grade ) {
1580
+			$_answer_grades = $wpdb->get_results($wpdb->prepare($grades_sql, $user_id), ARRAY_A);
1581
+			foreach ($_answer_grades as $answer_grade) {
1582 1582
 				// This will overwrite existing entries with the newer ones
1583
-				$answer_grades[ $answer_grade['comment_post_ID'] ] = $answer_grade['comment_content'];
1583
+				$answer_grades[$answer_grade['comment_post_ID']] = $answer_grade['comment_content'];
1584 1584
 			}
1585
-			unset( $_answer_grades );
1585
+			unset($_answer_grades);
1586 1586
 
1587 1587
 			// Pre-process the answer notes
1588
-			$_answer_notes = $wpdb->get_results( $wpdb->prepare($notes_sql, $user_id), ARRAY_A );
1589
-			foreach ( $_answer_notes as $answer_note ) {
1588
+			$_answer_notes = $wpdb->get_results($wpdb->prepare($notes_sql, $user_id), ARRAY_A);
1589
+			foreach ($_answer_notes as $answer_note) {
1590 1590
 				// This will overwrite existing entries with the newer ones
1591
-				$answer_notes[ $answer_note['comment_post_ID'] ] = $answer_note['comment_content'];
1591
+				$answer_notes[$answer_note['comment_post_ID']] = $answer_note['comment_content'];
1592 1592
 			}
1593
-			unset( $_answer_notes );
1593
+			unset($_answer_notes);
1594 1594
 
1595 1595
 			// Grab all the questions for the user
1596 1596
 			$sql = $wpdb->prepare($answers_sql, $user_id);
1597
-			$answers = $wpdb->get_results( $sql, ARRAY_A );
1598
-			foreach ( $answers as $answer ) {
1597
+			$answers = $wpdb->get_results($sql, ARRAY_A);
1598
+			foreach ($answers as $answer) {
1599 1599
 
1600 1600
 				// Excape data
1601 1601
 				$answer = wp_slash($answer);
@@ -1605,12 +1605,12 @@  discard block
 block discarded – undo
1605 1605
 				$meta_data = array();
1606 1606
 
1607 1607
 				// Check if the question has been graded, add as meta
1608
-				if ( !empty($answer_grades[ $answer['comment_post_ID'] ]) ) {
1609
-					$meta_data['user_grade'] = $answer_grades[ $answer['comment_post_ID'] ];
1608
+				if ( ! empty($answer_grades[$answer['comment_post_ID']])) {
1609
+					$meta_data['user_grade'] = $answer_grades[$answer['comment_post_ID']];
1610 1610
 				}
1611 1611
 				// Check if there is an answer note, add as meta
1612
-				if ( !empty($answer_notes[ $answer['comment_post_ID'] ]) ) {
1613
-					$meta_data['answer_note'] = $answer_notes[ $answer['comment_post_ID'] ];
1612
+				if ( ! empty($answer_notes[$answer['comment_post_ID']])) {
1613
+					$meta_data['answer_note'] = $answer_notes[$answer['comment_post_ID']];
1614 1614
 				}
1615 1615
 
1616 1616
 				// Wipe the unnessary data from the main comment
@@ -1623,21 +1623,21 @@  discard block
 block discarded – undo
1623 1623
 					);
1624 1624
 				$data = array_merge($answer, $data);
1625 1625
 
1626
-				$rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) );
1627
-				if ( $rval ) {
1628
-					if ( !empty($meta_data) ) {
1629
-						foreach ( $meta_data as $key => $value ) {
1626
+				$rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID'));
1627
+				if ($rval) {
1628
+					if ( ! empty($meta_data)) {
1629
+						foreach ($meta_data as $key => $value) {
1630 1630
 							// Bypassing WP wp_insert_comment( $data ), so no actions/filters are run
1631
-							if ( $wpdb->get_var( $wpdb->prepare(
1631
+							if ($wpdb->get_var($wpdb->prepare(
1632 1632
 									"SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ",
1633
-									$comment_ID, $key ) ) ) {
1633
+									$comment_ID, $key ))) {
1634 1634
 									continue; // Found the meta data already
1635 1635
 							}
1636
-							$result = $wpdb->insert( $wpdb->commentmeta, array(
1636
+							$result = $wpdb->insert($wpdb->commentmeta, array(
1637 1637
 								'comment_id' => $comment_ID,
1638 1638
 								'meta_key' => $key,
1639 1639
 								'meta_value' => $value
1640
-							) );
1640
+							));
1641 1641
 						}
1642 1642
 					}
1643 1643
 				}
@@ -1645,7 +1645,7 @@  discard block
 block discarded – undo
1645 1645
 		}
1646 1646
 		$wpdb->flush();
1647 1647
 
1648
-		if ( $current_page == $total_pages ) {
1648
+		if ($current_page == $total_pages) {
1649 1649
 			return true;
1650 1650
 		} else {
1651 1651
 			return false;
@@ -1662,10 +1662,10 @@  discard block
 block discarded – undo
1662 1662
 		global $wpdb;
1663 1663
 
1664 1664
 		// Update 'sensei_user_answer' entries to use comment_approved = 'log' so they don't appear in counts
1665
-		$wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' " );
1665
+		$wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' ");
1666 1666
 
1667 1667
 		// Mark all old Sensei comment types with comment_approved = 'legacy' so they no longer appear in counts, but can be restored if required
1668
-		$wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'legacy' WHERE comment_type IN ('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_answer_notes', 'sensei_quiz_grade') " );
1668
+		$wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'legacy' WHERE comment_type IN ('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_answer_notes', 'sensei_quiz_grade') ");
1669 1669
 
1670 1670
 		return true;
1671 1671
 	}
@@ -1678,50 +1678,50 @@  discard block
 block discarded – undo
1678 1678
 	 * @param type $offset
1679 1679
 	 * @return boolean
1680 1680
 	 */
1681
-	public function update_comment_course_lesson_comment_counts( $n = 50, $offset = 0 ) {
1681
+	public function update_comment_course_lesson_comment_counts($n = 50, $offset = 0) {
1682 1682
 		global $wpdb;
1683 1683
 
1684
-		$item_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') " );
1684
+		$item_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') ");
1685 1685
 
1686
-		if ( 0 == $item_count_result ) {
1686
+		if (0 == $item_count_result) {
1687 1687
 			return true;
1688 1688
 		}
1689 1689
 
1690 1690
 		// Calculate if this is the last page
1691
-		if ( 0 == $offset ) {
1691
+		if (0 == $offset) {
1692 1692
 			$current_page = 1;
1693 1693
 		} else {
1694
-			$current_page = intval( $offset / $n );
1694
+			$current_page = intval($offset / $n);
1695 1695
 		}
1696 1696
 
1697
-		$total_pages = ceil( $item_count_result / $n );
1697
+		$total_pages = ceil($item_count_result / $n);
1698 1698
 
1699 1699
 		// Recalculate all counts
1700
-		$items = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset ) );
1701
-		foreach ( (array) $items as $post ) {
1700
+		$items = $wpdb->get_results($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset));
1701
+		foreach ((array) $items as $post) {
1702 1702
 			// Code copied from wp_update_comment_count_now()
1703
-			$new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID) );
1704
-			$wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID) );
1703
+			$new = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID));
1704
+			$wpdb->update($wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID));
1705 1705
 
1706
-			clean_post_cache( $post->ID );
1706
+			clean_post_cache($post->ID);
1707 1707
 		}
1708 1708
 
1709
-		if ( $current_page == $total_pages ) {
1709
+		if ($current_page == $total_pages) {
1710 1710
 			return true;
1711 1711
 		} else {
1712 1712
 			return false;
1713 1713
 		}
1714 1714
 	}
1715 1715
 
1716
-	public function remove_legacy_comments () {
1716
+	public function remove_legacy_comments() {
1717 1717
 		global $wpdb;
1718 1718
 
1719
-		$result = $wpdb->delete( $wpdb->comments, array( 'comment_approved' => 'legacy' ) );
1719
+		$result = $wpdb->delete($wpdb->comments, array('comment_approved' => 'legacy'));
1720 1720
 
1721 1721
 		return true;
1722 1722
 	}
1723 1723
 
1724
-	public function index_comment_status_field () {
1724
+	public function index_comment_status_field() {
1725 1725
 		global $wpdb;
1726 1726
 
1727 1727
 		$wpdb->query("ALTER TABLE `$wpdb->comments` ADD INDEX `comment_type` ( `comment_type` )");
@@ -1740,7 +1740,7 @@  discard block
 block discarded – undo
1740 1740
      * @since 1.8.0
1741 1741
      * @return bool;
1742 1742
      */
1743
-    public  function enhance_teacher_role ( ) {
1743
+    public  function enhance_teacher_role( ) {
1744 1744
 
1745 1745
         require_once('class-sensei-teacher.php');
1746 1746
         $teacher = new Sensei_Teacher();
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1424,8 +1424,8 @@  discard block
 block discarded – undo
1424 1424
 	 *
1425 1425
 	 * @global type $woothemes_sensei
1426 1426
 	 * @global type $wpdb
1427
-	 * @param type $n
1428
-	 * @param type $offset
1427
+	 * @param integer $n
1428
+	 * @param integer $offset
1429 1429
 	 * @return boolean
1430 1430
 	 */
1431 1431
 	function status_changes_repair_course_statuses( $n = 50, $offset = 0 ) {
@@ -1669,8 +1669,8 @@  discard block
 block discarded – undo
1669 1669
 	 * Update the comment counts for all Courses and Lessons now that sensei comments will no longer be counted.
1670 1670
 	 *
1671 1671
 	 * @global type $wpdb
1672
-	 * @param type $n
1673
-	 * @param type $offset
1672
+	 * @param integer $n
1673
+	 * @param integer $offset
1674 1674
 	 * @return boolean
1675 1675
 	 */
1676 1676
 	public function update_comment_course_lesson_comment_counts( $n = 50, $offset = 0 ) {
Please login to merge, or discard this patch.
includes/class-sensei-lesson.php 4 patches
Braces   +28 added lines, -16 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Lessons Class
@@ -378,8 +381,7 @@  discard block
 block discarded – undo
378 381
 		$quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
379 382
 		if( 0 < count( $quiz_questions ) ) {
380 383
 			update_post_meta( $post_id, '_quiz_has_questions', '1' );
381
-		}
382
-		else {
384
+		} else {
383 385
 			delete_post_meta( $post_id, '_quiz_has_questions' );
384 386
 		}
385 387
 
@@ -390,7 +392,9 @@  discard block
 block discarded – undo
390 392
 
391 393
 	public function get_submitted_setting_value( $field = false ) {
392 394
 
393
-		if( ! $field ) return;
395
+		if( ! $field ) {
396
+			return;
397
+		}
394 398
 
395 399
 		$value = false;
396 400
 
@@ -1507,7 +1511,7 @@  discard block
 block discarded – undo
1507 1511
 
1508 1512
             $field_name = 'answer_feedback_boolean';
1509 1513
 
1510
-        }elseif( 'multiple-choice' == $question_type ){
1514
+        } elseif( 'multiple-choice' == $question_type ){
1511 1515
 
1512 1516
             $field_name = 'answer_feedback_multiple_choice';
1513 1517
 
@@ -1603,7 +1607,9 @@  discard block
 block discarded – undo
1603 1607
 
1604 1608
 		$html = '';
1605 1609
 
1606
-		if( ! $lesson_id && ! $quiz_id ) return $html;
1610
+		if( ! $lesson_id && ! $quiz_id ) {
1611
+			return $html;
1612
+		}
1607 1613
 
1608 1614
 		$settings = $this->get_quiz_settings( $quiz_id );
1609 1615
 
@@ -2258,11 +2264,11 @@  discard block
 block discarded – undo
2258 2264
 
2259 2265
             $answer_feedback = $data[ 'answer_feedback_boolean' ];
2260 2266
 
2261
-		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2267
+		} elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2262 2268
 
2263 2269
             $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2264 2270
 
2265
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2271
+        } elseif( isset( $data[ 'answer_feedback' ] )  ){
2266 2272
 
2267 2273
             $answer_feedback = $data[ 'answer_feedback' ];
2268 2274
 
@@ -2275,8 +2281,7 @@  discard block
 block discarded – undo
2275 2281
 		// Handle the extended question text
2276 2282
 		if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) {
2277 2283
 			$post_content = $data[ 'question_description' ];
2278
-		}
2279
-		else {
2284
+		} else {
2280 2285
 			$post_content = '';
2281 2286
 		}
2282 2287
 		// Question Query Arguments
@@ -2484,8 +2489,7 @@  discard block
 block discarded – undo
2484 2489
 				'key' => '_lesson_course',
2485 2490
 				'value' => $course_id,
2486 2491
 			);
2487
-		}
2488
-		else {
2492
+		} else {
2489 2493
 			// Simple check for connection to a Course
2490 2494
 			$post_args['meta_query'][] = array(
2491 2495
 				'key' => '_lesson_course',
@@ -2613,9 +2617,13 @@  discard block
 block discarded – undo
2613 2617
 				// Fetch each question in the order in which they were asked
2614 2618
 				$questions = array();
2615 2619
 				foreach( $selected_questions as $question_id ) {
2616
-					if( ! $question_id ) continue;
2620
+					if( ! $question_id ) {
2621
+						continue;
2622
+					}
2617 2623
 					$question = get_post( $question_id );
2618
-					if( ! isset( $question ) || ! isset( $question->ID ) ) continue;
2624
+					if( ! isset( $question ) || ! isset( $question->ID ) ) {
2625
+						continue;
2626
+					}
2619 2627
 					$questions[] = $question;
2620 2628
 				}
2621 2629
 
@@ -2628,7 +2636,9 @@  discard block
 block discarded – undo
2628 2636
 
2629 2637
 				// Set array of questions that already exist so we can prevent duplicates from appearing
2630 2638
 				foreach( $questions_array as $question ) {
2631
-					if( 'question' != $question->post_type ) continue;
2639
+					if( 'question' != $question->post_type ) {
2640
+						continue;
2641
+					}
2632 2642
 					$existing_questions[] = $question->ID;
2633 2643
 				}
2634 2644
 
@@ -2668,7 +2678,9 @@  discard block
 block discarded – undo
2668 2678
 
2669 2679
 						// Add selected questions to existing questions array to prevent duplicates from being added
2670 2680
 						foreach( $questions_array as $cat_question ) {
2671
-							if( in_array( $cat_question->ID, $existing_questions ) ) continue;
2681
+							if( in_array( $cat_question->ID, $existing_questions ) ) {
2682
+								continue;
2683
+							}
2672 2684
 							$existing_questions[] = $cat_question->ID;
2673 2685
 						}
2674 2686
 					}
Please login to merge, or discard this patch.
Spacing   +1082 added lines, -1082 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
@@ -20,83 +20,83 @@  discard block
 block discarded – undo
20 20
 	 * Constructor.
21 21
 	 * @since  1.0.0
22 22
 	 */
23
-	public function __construct () {
23
+	public function __construct() {
24 24
 
25 25
         $this->token = 'lesson';
26 26
 
27 27
 		// Setup meta fields for this post type
28
-		$this->meta_fields = array( 'lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed' );
28
+		$this->meta_fields = array('lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed');
29 29
 
30 30
         $this->question_order = '';
31 31
 
32 32
 		// Admin actions
33
-		if ( is_admin() ) {
33
+		if (is_admin()) {
34 34
 
35 35
 			// Metabox functions
36
-			add_action( 'admin_menu', array( $this, 'meta_box_setup' ), 20 );
37
-			add_action( 'save_post', array( $this, 'meta_box_save' ) );
38
-			add_action( 'save_post', array( $this, 'quiz_update' ) );
36
+			add_action('admin_menu', array($this, 'meta_box_setup'), 20);
37
+			add_action('save_post', array($this, 'meta_box_save'));
38
+			add_action('save_post', array($this, 'quiz_update'));
39 39
 
40 40
 			// Custom Write Panel Columns
41
-			add_filter( 'manage_edit-lesson_columns', array( $this, 'add_column_headings' ), 10, 1 );
42
-			add_action( 'manage_posts_custom_column', array( $this, 'add_column_data' ), 10, 2 );
41
+			add_filter('manage_edit-lesson_columns', array($this, 'add_column_headings'), 10, 1);
42
+			add_action('manage_posts_custom_column', array($this, 'add_column_data'), 10, 2);
43 43
 
44 44
 			// Add/Update question
45
-			add_action( 'wp_ajax_lesson_update_question', array( $this, 'lesson_update_question' ) );
46
-			add_action( 'wp_ajax_nopriv_lesson_update_question', array( $this, 'lesson_update_question' ) );
45
+			add_action('wp_ajax_lesson_update_question', array($this, 'lesson_update_question'));
46
+			add_action('wp_ajax_nopriv_lesson_update_question', array($this, 'lesson_update_question'));
47 47
 
48 48
 			// Add course
49
-			add_action( 'wp_ajax_lesson_add_course', array( $this, 'lesson_add_course' ) );
50
-			add_action( 'wp_ajax_nopriv_lesson_add_course', array( $this, 'lesson_add_course' ) );
49
+			add_action('wp_ajax_lesson_add_course', array($this, 'lesson_add_course'));
50
+			add_action('wp_ajax_nopriv_lesson_add_course', array($this, 'lesson_add_course'));
51 51
 
52 52
 			// Update grade type
53
-			add_action( 'wp_ajax_lesson_update_grade_type', array( $this, 'lesson_update_grade_type' ) );
54
-			add_action( 'wp_ajax_nopriv_lesson_update_grade_type', array( $this, 'lesson_update_grade_type' ) );
53
+			add_action('wp_ajax_lesson_update_grade_type', array($this, 'lesson_update_grade_type'));
54
+			add_action('wp_ajax_nopriv_lesson_update_grade_type', array($this, 'lesson_update_grade_type'));
55 55
 
56 56
 			// Update question order
57
-			add_action( 'wp_ajax_lesson_update_question_order', array( $this, 'lesson_update_question_order' ) );
58
-			add_action( 'wp_ajax_nopriv_lesson_update_question_order', array( $this, 'lesson_update_question_order' ) );
57
+			add_action('wp_ajax_lesson_update_question_order', array($this, 'lesson_update_question_order'));
58
+			add_action('wp_ajax_nopriv_lesson_update_question_order', array($this, 'lesson_update_question_order'));
59 59
 
60 60
 			//Update question order
61
-			add_action( 'wp_ajax_lesson_update_question_order_random', array( $this, 'lesson_update_question_order_random' ) );
62
-			add_action( 'wp_ajax_nopriv_lesson_update_question_order_random', array( $this, 'lesson_update_question_order_random' ) );
61
+			add_action('wp_ajax_lesson_update_question_order_random', array($this, 'lesson_update_question_order_random'));
62
+			add_action('wp_ajax_nopriv_lesson_update_question_order_random', array($this, 'lesson_update_question_order_random'));
63 63
 
64 64
 			// Get answer ID
65
-			add_action( 'wp_ajax_question_get_answer_id', array( $this, 'question_get_answer_id' ) );
66
-			add_action( 'wp_ajax_nopriv_question_get_answer_id', array( $this, 'question_get_answer_id' ) );
65
+			add_action('wp_ajax_question_get_answer_id', array($this, 'question_get_answer_id'));
66
+			add_action('wp_ajax_nopriv_question_get_answer_id', array($this, 'question_get_answer_id'));
67 67
 
68 68
 			// Add multiple questions
69
-			add_action( 'wp_ajax_lesson_add_multiple_questions', array( $this, 'lesson_add_multiple_questions' ) );
70
-			add_action( 'wp_ajax_nopriv_lesson_add_multiple_questions', array( $this, 'lesson_add_multiple_questions' ) );
69
+			add_action('wp_ajax_lesson_add_multiple_questions', array($this, 'lesson_add_multiple_questions'));
70
+			add_action('wp_ajax_nopriv_lesson_add_multiple_questions', array($this, 'lesson_add_multiple_questions'));
71 71
 
72 72
 			// Remove multiple questions
73
-			add_action( 'wp_ajax_lesson_remove_multiple_questions', array( $this, 'lesson_remove_multiple_questions' ) );
74
-			add_action( 'wp_ajax_nopriv_lesson_remove_multiple_questions', array( $this, 'lesson_remove_multiple_questions' ) );
73
+			add_action('wp_ajax_lesson_remove_multiple_questions', array($this, 'lesson_remove_multiple_questions'));
74
+			add_action('wp_ajax_nopriv_lesson_remove_multiple_questions', array($this, 'lesson_remove_multiple_questions'));
75 75
 
76 76
 			// Get question category limit
77
-			add_action( 'wp_ajax_get_question_category_limit', array( $this, 'get_question_category_limit' ) );
78
-			add_action( 'wp_ajax_nopriv_get_question_category_limit', array( $this, 'get_question_category_limit' ) );
77
+			add_action('wp_ajax_get_question_category_limit', array($this, 'get_question_category_limit'));
78
+			add_action('wp_ajax_nopriv_get_question_category_limit', array($this, 'get_question_category_limit'));
79 79
 
80 80
 			// Add existing questions
81
-			add_action( 'wp_ajax_lesson_add_existing_questions', array( $this, 'lesson_add_existing_questions' ) );
82
-			add_action( 'wp_ajax_nopriv_lesson_add_existing_questions', array( $this, 'lesson_add_existing_questions' ) );
81
+			add_action('wp_ajax_lesson_add_existing_questions', array($this, 'lesson_add_existing_questions'));
82
+			add_action('wp_ajax_nopriv_lesson_add_existing_questions', array($this, 'lesson_add_existing_questions'));
83 83
 
84 84
 			// Filter existing questions
85
-			add_action( 'wp_ajax_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
86
-			add_action( 'wp_ajax_nopriv_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
85
+			add_action('wp_ajax_filter_existing_questions', array($this, 'quiz_panel_filter_existing_questions'));
86
+			add_action('wp_ajax_nopriv_filter_existing_questions', array($this, 'quiz_panel_filter_existing_questions'));
87 87
 
88 88
             // output bulk edit fields
89
-            add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
90
-            add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
89
+            add_action('bulk_edit_custom_box', array($this, 'all_lessons_edit_fields'), 10, 2);
90
+            add_action('quick_edit_custom_box', array($this, 'all_lessons_edit_fields'), 10, 2);
91 91
 
92 92
             // load quick edit default values
93
-            add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2);
93
+            add_action('manage_lesson_posts_custom_column', array($this, 'set_quick_edit_admin_defaults'), 11, 2);
94 94
 
95 95
             // save bulk edit fields
96
-            add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) );
96
+            add_action('wp_ajax_save_bulk_edit_book', array($this, 'save_all_lessons_edit_fields'));
97 97
 
98 98
             // flush rewrite rules when saving a lesson
99
-            add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) );
99
+            add_action('save_post', array(__CLASS__, 'flush_rewrite_rules'));
100 100
 
101 101
 		} else {
102 102
 			// Frontend actions
@@ -109,34 +109,34 @@  discard block
 block discarded – undo
109 109
 	 * @access public
110 110
 	 * @return void
111 111
 	 */
112
-	public function meta_box_setup () {
112
+	public function meta_box_setup() {
113 113
 
114 114
 		// Add Meta Box for Prerequisite Lesson
115
-		add_meta_box( 'lesson-prerequisite', __( 'Lesson Prerequisite', 'woothemes-sensei' ), array( $this, 'lesson_prerequisite_meta_box_content' ), $this->token, 'side', 'default' );
115
+		add_meta_box('lesson-prerequisite', __('Lesson Prerequisite', 'woothemes-sensei'), array($this, 'lesson_prerequisite_meta_box_content'), $this->token, 'side', 'default');
116 116
 
117 117
 		// Add Meta Box for Lesson Course
118
-		add_meta_box( 'lesson-course', __( 'Lesson Course', 'woothemes-sensei' ), array( $this, 'lesson_course_meta_box_content' ), $this->token, 'side', 'default' );
118
+		add_meta_box('lesson-course', __('Lesson Course', 'woothemes-sensei'), array($this, 'lesson_course_meta_box_content'), $this->token, 'side', 'default');
119 119
 
120 120
 		// Add Meta Box for Lesson Preview
121
-		add_meta_box( 'lesson-preview', __( 'Lesson Preview', 'woothemes-sensei' ), array( $this, 'lesson_preview_meta_box_content' ), $this->token, 'side', 'default' );
121
+		add_meta_box('lesson-preview', __('Lesson Preview', 'woothemes-sensei'), array($this, 'lesson_preview_meta_box_content'), $this->token, 'side', 'default');
122 122
 
123 123
 		// Add Meta Box for Lesson Information
124
-		add_meta_box( 'lesson-info', __( 'Lesson Information', 'woothemes-sensei' ), array( $this, 'lesson_info_meta_box_content' ), $this->token, 'normal', 'default' );
124
+		add_meta_box('lesson-info', __('Lesson Information', 'woothemes-sensei'), array($this, 'lesson_info_meta_box_content'), $this->token, 'normal', 'default');
125 125
 
126 126
 		// Add Meta Box for Quiz Settings
127
-		add_meta_box( 'lesson-quiz-settings', __( 'Quiz Settings', 'woothemes-sensei' ), array( $this, 'lesson_quiz_settings_meta_box_content' ), $this->token, 'normal', 'default' );
127
+		add_meta_box('lesson-quiz-settings', __('Quiz Settings', 'woothemes-sensei'), array($this, 'lesson_quiz_settings_meta_box_content'), $this->token, 'normal', 'default');
128 128
 
129 129
 		// Add Meta Box for Lesson Quiz Questions
130
-		add_meta_box( 'lesson-quiz', __( 'Quiz Questions', 'woothemes-sensei' ), array( $this, 'lesson_quiz_meta_box_content' ), $this->token, 'normal', 'default' );
130
+		add_meta_box('lesson-quiz', __('Quiz Questions', 'woothemes-sensei'), array($this, 'lesson_quiz_meta_box_content'), $this->token, 'normal', 'default');
131 131
 
132 132
 		// Remove "Custom Settings" meta box.
133
-		remove_meta_box( 'woothemes-settings', $this->token, 'normal' );
133
+		remove_meta_box('woothemes-settings', $this->token, 'normal');
134 134
 
135 135
 		// Add JS scripts
136
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
136
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
137 137
 
138 138
 		// Add CSS
139
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
139
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_styles'));
140 140
 
141 141
 	} // End meta_box_setup()
142 142
 
@@ -147,30 +147,30 @@  discard block
 block discarded – undo
147 147
 	 * @access public
148 148
 	 * @return void
149 149
 	 */
150
-	public function lesson_info_meta_box_content () {
150
+	public function lesson_info_meta_box_content() {
151 151
 		global $post;
152 152
 
153
-		$lesson_length = get_post_meta( $post->ID, '_lesson_length', true );
154
-		$lesson_complexity = get_post_meta( $post->ID, '_lesson_complexity', true );
153
+		$lesson_length = get_post_meta($post->ID, '_lesson_length', true);
154
+		$lesson_complexity = get_post_meta($post->ID, '_lesson_complexity', true);
155 155
 		$complexity_array = $this->lesson_complexities();
156
-		$lesson_video_embed = get_post_meta( $post->ID, '_lesson_video_embed', true );
156
+		$lesson_video_embed = get_post_meta($post->ID, '_lesson_video_embed', true);
157 157
 
158 158
 		$html = '';
159 159
 		// Lesson Length
160
-		$html .= '<p><label for="lesson_length">' . __( 'Lesson Length in minutes', 'woothemes-sensei' ) . ': </label>';
161
-		$html .= '<input type="number" id="lesson-length" name="lesson_length" class="small-text" value="' . esc_attr( $lesson_length ) . '" /></p>' . "\n";
160
+		$html .= '<p><label for="lesson_length">'.__('Lesson Length in minutes', 'woothemes-sensei').': </label>';
161
+		$html .= '<input type="number" id="lesson-length" name="lesson_length" class="small-text" value="'.esc_attr($lesson_length).'" /></p>'."\n";
162 162
 		// Lesson Complexity
163
-		$html .= '<p><label for="lesson_complexity">' . __( 'Lesson Complexity', 'woothemes-sensei' ) . ': </label>';
163
+		$html .= '<p><label for="lesson_complexity">'.__('Lesson Complexity', 'woothemes-sensei').': </label>';
164 164
 		$html .= '<select id="lesson-complexity-options" name="lesson_complexity" class="chosen_select lesson-complexity-select">';
165
-			$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
166
-			foreach ($complexity_array as $key => $value){
167
-				$html .= '<option value="' . esc_attr( $key ) . '"' . selected( $key, $lesson_complexity, false ) . '>' . esc_html( $value ) . '</option>' . "\n";
165
+			$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
166
+			foreach ($complexity_array as $key => $value) {
167
+				$html .= '<option value="'.esc_attr($key).'"'.selected($key, $lesson_complexity, false).'>'.esc_html($value).'</option>'."\n";
168 168
 			} // End For Loop
169
-		$html .= '</select></p>' . "\n";
169
+		$html .= '</select></p>'."\n";
170 170
 
171
-		$html .= '<p><label for="lesson_video_embed">' . __( 'Video Embed Code', 'woothemes-sensei' ) . ':</label><br/>' . "\n";
172
-		$html .= '<textarea rows="5" cols="50" name="lesson_video_embed" tabindex="6" id="course-video-embed">' . $lesson_video_embed . '</textarea></p>' . "\n";
173
-		$html .= '<p>' .  __( 'Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei' ) . '</p>';
171
+		$html .= '<p><label for="lesson_video_embed">'.__('Video Embed Code', 'woothemes-sensei').':</label><br/>'."\n";
172
+		$html .= '<textarea rows="5" cols="50" name="lesson_video_embed" tabindex="6" id="course-video-embed">'.$lesson_video_embed.'</textarea></p>'."\n";
173
+		$html .= '<p>'.__('Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei').'</p>';
174 174
 
175 175
 		echo $html;
176 176
 
@@ -182,31 +182,31 @@  discard block
 block discarded – undo
182 182
 	 * @access public
183 183
 	 * @return void
184 184
 	 */
185
-	public function lesson_prerequisite_meta_box_content () {
185
+	public function lesson_prerequisite_meta_box_content() {
186 186
 		global $post;
187 187
 		// Get existing post meta
188
-		$select_lesson_prerequisite = get_post_meta( $post->ID, '_lesson_prerequisite', true );
188
+		$select_lesson_prerequisite = get_post_meta($post->ID, '_lesson_prerequisite', true);
189 189
 		// Get the Lesson Posts
190
-		$post_args = array(	'post_type' 		=> 'lesson',
190
+		$post_args = array('post_type' 		=> 'lesson',
191 191
 							'posts_per_page' 		=> -1,
192 192
 							'orderby'         	=> 'title',
193 193
     						'order'           	=> 'ASC',
194 194
     						'exclude' 			=> $post->ID,
195 195
 							'suppress_filters' 	=> 0
196 196
 							);
197
-		$posts_array = get_posts( $post_args );
197
+		$posts_array = get_posts($post_args);
198 198
 		// Build the HTML to Output
199 199
 		$html = '';
200
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
201
-		if ( count( $posts_array ) > 0 ) {
202
-			$html .= '<select id="lesson-prerequisite-options" name="lesson_prerequisite" class="chosen_select widefat">' . "\n";
203
-			$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
204
-				foreach ($posts_array as $post_item){
205
-					$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";
200
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
201
+		if (count($posts_array) > 0) {
202
+			$html .= '<select id="lesson-prerequisite-options" name="lesson_prerequisite" class="chosen_select widefat">'."\n";
203
+			$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
204
+				foreach ($posts_array as $post_item) {
205
+					$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";
206 206
 				} // End For Loop
207
-			$html .= '</select>' . "\n";
207
+			$html .= '</select>'."\n";
208 208
 		} else {
209
-			$html .= '<p>' . esc_html( __( 'No lessons exist yet. Please add some first.', 'woothemes-sensei' ) ) . '</p>';
209
+			$html .= '<p>'.esc_html(__('No lessons exist yet. Please add some first.', 'woothemes-sensei')).'</p>';
210 210
 		} // End If Statement
211 211
 		// Output the HTML
212 212
 		echo $html;
@@ -218,20 +218,20 @@  discard block
 block discarded – undo
218 218
 	 * @access public
219 219
 	 * @return void
220 220
 	 */
221
-	public function lesson_preview_meta_box_content () {
221
+	public function lesson_preview_meta_box_content() {
222 222
 		global $post;
223 223
 		// Get existing post meta
224
-		$lesson_preview = get_post_meta( $post->ID, '_lesson_preview', true );
224
+		$lesson_preview = get_post_meta($post->ID, '_lesson_preview', true);
225 225
 		$html = '';
226
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
226
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
227 227
 
228 228
 		$checked = '';
229
-		if ( isset( $lesson_preview ) && ( '' != $lesson_preview ) ) {
230
-	 	    $checked = checked( 'preview', $lesson_preview, false );
229
+		if (isset($lesson_preview) && ('' != $lesson_preview)) {
230
+	 	    $checked = checked('preview', $lesson_preview, false);
231 231
 	 	} // End If Statement
232 232
 
233 233
 	 	$html .= '<label for="lesson_preview">';
234
-	 	$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
+	 	$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>';
235 235
 
236 236
 		// Output the HTML
237 237
 		echo $html;
@@ -244,32 +244,32 @@  discard block
 block discarded – undo
244 244
 	 * @param int $post_id
245 245
 	 * @return void
246 246
 	 */
247
-	public function meta_box_save ( $post_id ) {
247
+	public function meta_box_save($post_id) {
248 248
 
249 249
 		// Verify the nonce before proceeding.
250
-		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
+		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')) {
251 251
 			return $post_id;
252 252
 		} // End If Statement
253 253
 		// Get the post type object.
254
-		$post_type = get_post_type_object( get_post_type( $post_id ) );
254
+		$post_type = get_post_type_object(get_post_type($post_id));
255 255
 		// Check if the current user has permission to edit the post.
256
-		if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) {
256
+		if ( ! current_user_can($post_type->cap->edit_post, $post_id)) {
257 257
 			return $post_id;
258 258
 		} // End If Statement
259 259
 		// Check if the current post type is a page
260
-		if ( 'page' == $_POST[ 'post_type' ] ) {
261
-			if ( ! current_user_can( 'edit_page', $post_id ) ) {
260
+		if ('page' == $_POST['post_type']) {
261
+			if ( ! current_user_can('edit_page', $post_id)) {
262 262
 				return $post_id;
263 263
 			} // End If Statement
264 264
 		} else {
265
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
265
+			if ( ! current_user_can('edit_post', $post_id)) {
266 266
 				return $post_id;
267 267
 			} // End If Statement
268 268
 		} // End If Statement
269 269
 		// Save the post meta data fields
270
-		if ( isset($this->meta_fields) && is_array($this->meta_fields) ) {
271
-			foreach ( $this->meta_fields as $meta_key ) {
272
-				$this->save_post_meta( $meta_key, $post_id );
270
+		if (isset($this->meta_fields) && is_array($this->meta_fields)) {
271
+			foreach ($this->meta_fields as $meta_key) {
272
+				$this->save_post_meta($meta_key, $post_id);
273 273
 			} // End For Loop
274 274
 		} // End If Statement
275 275
 	} // End meta_box_save()
@@ -281,37 +281,37 @@  discard block
 block discarded – undo
281 281
 	 * @access public
282 282
 	 * @return void
283 283
 	 */
284
-	public function quiz_update( $post_id ) {
284
+	public function quiz_update($post_id) {
285 285
 		global $post;
286 286
 		// Verify the nonce before proceeding.
287
-		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') ) {
288
-			if ( isset($post->ID) ) {
287
+		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')) {
288
+			if (isset($post->ID)) {
289 289
 				return $post->ID;
290 290
 			} else {
291 291
 				return false;
292 292
 			} // End If Statement
293 293
 		} // End If Statement
294 294
 
295
-		if( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
295
+		if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
296 296
 			return;
297 297
 		}
298 298
 
299 299
 		// Temporarily disable the filter
300
-        remove_action( 'save_post', array( $this, 'quiz_update' ) );
300
+        remove_action('save_post', array($this, 'quiz_update'));
301 301
 		// Save the Quiz
302
-		$quiz_id = $this->lesson_quizzes( $post_id, 'any');
302
+		$quiz_id = $this->lesson_quizzes($post_id, 'any');
303 303
 
304 304
 		 // Sanitize and setup the post data
305
-		$_POST = stripslashes_deep( $_POST );
306
-		if ( isset( $_POST[ 'quiz_id' ] ) && ( 0 < absint( $_POST[ 'quiz_id' ] ) ) ) {
307
-			$quiz_id = absint( $_POST[ 'quiz_id' ] );
305
+		$_POST = stripslashes_deep($_POST);
306
+		if (isset($_POST['quiz_id']) && (0 < absint($_POST['quiz_id']))) {
307
+			$quiz_id = absint($_POST['quiz_id']);
308 308
 		} // End If Statement
309
-		$post_title = esc_html( $_POST[ 'post_title' ] );
310
-		$post_status = esc_html( $_POST[ 'post_status' ] );
309
+		$post_title = esc_html($_POST['post_title']);
310
+		$post_status = esc_html($_POST['post_status']);
311 311
 		$post_content = '';
312 312
 
313 313
 		// Setup Query Arguments
314
-		$post_type_args = array(	'post_content' => $post_content,
314
+		$post_type_args = array('post_content' => $post_content,
315 315
   		    						'post_status' => $post_status,
316 316
   		    						'post_title' => $post_title,
317 317
   		    						'post_type' => 'quiz',
@@ -321,84 +321,84 @@  discard block
 block discarded – undo
321 321
 		$settings = $this->get_quiz_settings();
322 322
 
323 323
   		// Update or Insert the Lesson Quiz
324
-		if ( 0 < $quiz_id ) {
324
+		if (0 < $quiz_id) {
325 325
 			// Update the Quiz
326
-			$post_type_args[ 'ID' ] = $quiz_id;
326
+			$post_type_args['ID'] = $quiz_id;
327 327
 		    wp_update_post($post_type_args);
328 328
 
329 329
 		    // Update the post meta data
330
-		    update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
330
+		    update_post_meta($quiz_id, '_quiz_lesson', $post_id);
331 331
 
332
-		    foreach( $settings as $field ) {
333
-		    	if( 'random_question_order' != $field['id'] ) {
334
-			    	$value = $this->get_submitted_setting_value( $field );
335
-			    	if( isset( $value ) ) {
336
-			    		update_post_meta( $quiz_id, '_' . $field['id'], $value );
332
+		    foreach ($settings as $field) {
333
+		    	if ('random_question_order' != $field['id']) {
334
+			    	$value = $this->get_submitted_setting_value($field);
335
+			    	if (isset($value)) {
336
+			    		update_post_meta($quiz_id, '_'.$field['id'], $value);
337 337
 			    	}
338 338
 			    }
339 339
 		    }
340 340
 
341 341
 		    // Set the post terms for quiz-type
342
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
342
+		    wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type');
343 343
 		} else {
344 344
 			// Create the Quiz
345 345
 		    $quiz_id = wp_insert_post($post_type_args);
346 346
 
347 347
 		    // Add the post meta data WP will add it if it doesn't exist
348
-            update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
348
+            update_post_meta($quiz_id, '_quiz_lesson', $post_id);
349 349
 
350
-		    foreach( $settings as $field ) {
351
-		    	if( 'random_question_order' != $field['id'] ) {
350
+		    foreach ($settings as $field) {
351
+		    	if ('random_question_order' != $field['id']) {
352 352
 
353 353
                     //ignore values not posted to avoid
354 354
                     // overwriting with empty or default values
355 355
                     // when the values are posted from bulk edit or quick edit
356
-                    if( !isset( $_POST[ $field['id'] ] ) ){
356
+                    if ( ! isset($_POST[$field['id']])) {
357 357
                         continue;
358 358
                     }
359 359
 
360
-			    	$value = $this->get_submitted_setting_value( $field );
361
-			    	if( isset( $value ) ) {
362
-			    		add_post_meta( $quiz_id, '_' . $field['id'], $value );
360
+			    	$value = $this->get_submitted_setting_value($field);
361
+			    	if (isset($value)) {
362
+			    		add_post_meta($quiz_id, '_'.$field['id'], $value);
363 363
 			    	}
364 364
 			    }
365 365
 		    }
366 366
 
367 367
 		    // Set the post terms for quiz-type
368
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
368
+		    wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type');
369 369
 		} // End If Statement
370 370
 
371 371
 		// Add default lesson order meta value
372
-		$course_id = get_post_meta( $post_id, '_lesson_course', true );
373
-		if( $course_id ) {
374
-			if( ! get_post_meta( $post_id, '_order_' . $course_id, true ) ) {
375
-				update_post_meta( $post_id, '_order_' . $course_id, 0 );
372
+		$course_id = get_post_meta($post_id, '_lesson_course', true);
373
+		if ($course_id) {
374
+			if ( ! get_post_meta($post_id, '_order_'.$course_id, true)) {
375
+				update_post_meta($post_id, '_order_'.$course_id, 0);
376 376
 			}
377 377
 		}
378 378
 		// Add reference back to the Quiz
379
-		update_post_meta( $post_id, '_lesson_quiz', $quiz_id );
379
+		update_post_meta($post_id, '_lesson_quiz', $quiz_id);
380 380
 		// Mark if the Lesson Quiz has questions
381
-		$quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
382
-		if( 0 < count( $quiz_questions ) ) {
383
-			update_post_meta( $post_id, '_quiz_has_questions', '1' );
381
+		$quiz_questions = Sensei()->lesson->lesson_quiz_questions($quiz_id);
382
+		if (0 < count($quiz_questions)) {
383
+			update_post_meta($post_id, '_quiz_has_questions', '1');
384 384
 		}
385 385
 		else {
386
-			delete_post_meta( $post_id, '_quiz_has_questions' );
386
+			delete_post_meta($post_id, '_quiz_has_questions');
387 387
 		}
388 388
 
389 389
 		// Restore the previously disabled filter
390
-        add_action( 'save_post', array( $this, 'quiz_update' ) );
390
+        add_action('save_post', array($this, 'quiz_update'));
391 391
 
392 392
 	} // End post_updated()
393 393
 
394
-	public function get_submitted_setting_value( $field = false ) {
394
+	public function get_submitted_setting_value($field = false) {
395 395
 
396
-		if( ! $field ) return;
396
+		if ( ! $field) return;
397 397
 
398 398
 		$value = false;
399 399
 
400
-		if( 'quiz_grade_type' == $field['id'] ) {
401
-			if( isset( $_POST[ $field['id'] ] ) && 'on' == $_POST[ $field['id'] ] ) {
400
+		if ('quiz_grade_type' == $field['id']) {
401
+			if (isset($_POST[$field['id']]) && 'on' == $_POST[$field['id']]) {
402 402
 				$value = 'auto';
403 403
 			} else {
404 404
 				$value = 'manual';
@@ -406,8 +406,8 @@  discard block
 block discarded – undo
406 406
 			return $value;
407 407
 		}
408 408
 
409
-		if ( isset( $_POST[ $field['id'] ] ) ) {
410
-			$value = $_POST[ $field['id'] ];
409
+		if (isset($_POST[$field['id']])) {
410
+			$value = $_POST[$field['id']];
411 411
 		} else {
412 412
 			$value = $field['default'];
413 413
 		}
@@ -423,18 +423,18 @@  discard block
 block discarded – undo
423 423
 	 * @param int $post_id (default: 0)
424 424
 	 * @return int|bool meta id or saved status
425 425
 	 */
426
-	private function save_post_meta( $post_key = '', $post_id = 0 ) {
426
+	private function save_post_meta($post_key = '', $post_id = 0) {
427 427
 		// Get the meta key.
428
-		$meta_key = '_' . $post_key;
428
+		$meta_key = '_'.$post_key;
429 429
 
430 430
         //ignore fields are not posted
431 431
 
432
-        if( !isset( $_POST[ $post_key ] ) ){
432
+        if ( ! isset($_POST[$post_key])) {
433 433
 
434 434
             // except for lesson preview checkbox field
435
-            if( 'lesson_preview' == $post_key ){
435
+            if ('lesson_preview' == $post_key) {
436 436
 
437
-                $_POST[ $post_key ] = '';
437
+                $_POST[$post_key] = '';
438 438
 
439 439
             } else {
440 440
 
@@ -445,15 +445,15 @@  discard block
 block discarded – undo
445 445
         }
446 446
 
447 447
 		// Get the posted data and sanitize it for use as an HTML class.
448
-		if ( 'lesson_video_embed' == $post_key) {
449
-			$new_meta_value = esc_html( $_POST[$post_key] );
448
+		if ('lesson_video_embed' == $post_key) {
449
+			$new_meta_value = esc_html($_POST[$post_key]);
450 450
 		} else {
451
-			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
451
+			$new_meta_value = (isset($_POST[$post_key]) ? sanitize_html_class($_POST[$post_key]) : '');
452 452
 		} // End If Statement
453 453
 
454 454
         // update field with the new value
455
-        if( -1 != $new_meta_value  ){
456
-            return update_post_meta( $post_id, $meta_key, $new_meta_value );
455
+        if ( -1 != $new_meta_value  ) {
456
+            return update_post_meta($post_id, $meta_key, $new_meta_value);
457 457
         }
458 458
 
459 459
 	} // End save_post_meta()
@@ -464,30 +464,30 @@  discard block
 block discarded – undo
464 464
 	 * @access public
465 465
 	 * @return void
466 466
 	 */
467
-	public function lesson_course_meta_box_content () {
467
+	public function lesson_course_meta_box_content() {
468 468
 		global $post;
469 469
 		// Setup Lesson Meta Data
470 470
 		$selected_lesson_course = 0;
471
-		if ( 0 < $post->ID ) {
472
-			$selected_lesson_course = get_post_meta( $post->ID, '_lesson_course', true );
471
+		if (0 < $post->ID) {
472
+			$selected_lesson_course = get_post_meta($post->ID, '_lesson_course', true);
473 473
 		} // End If Statement
474 474
 		// Handle preselected course
475
-		if ( isset( $_GET[ 'course_id' ] ) && ( 0 < absint( $_GET[ 'course_id' ] ) ) ) {
476
-			$selected_lesson_course = absint( $_GET[ 'course_id' ] );
475
+		if (isset($_GET['course_id']) && (0 < absint($_GET['course_id']))) {
476
+			$selected_lesson_course = absint($_GET['course_id']);
477 477
 		} // End If Statement
478 478
 		// Get the Lesson Posts
479
-		$post_args = array(	'post_type' 		=> 'course',
479
+		$post_args = array('post_type' 		=> 'course',
480 480
 							'posts_per_page' 		=> -1,
481 481
 							'orderby'         	=> 'title',
482 482
     						'order'           	=> 'ASC',
483 483
     						'post_status'      	=> 'any',
484 484
     						'suppress_filters' 	=> 0,
485 485
 							);
486
-		$posts_array = get_posts( $post_args );
486
+		$posts_array = get_posts($post_args);
487 487
 		// Buid the HTML to Output
488 488
 		$html = '';
489 489
 		// Nonce
490
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
490
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
491 491
 
492 492
         // Select the course for the lesson
493 493
         $drop_down_args = array(
@@ -497,67 +497,67 @@  discard block
 block discarded – undo
497 497
 
498 498
         $courses = WooThemes_Sensei_Course::get_all_courses();
499 499
         $courses_options = array();
500
-        foreach( $courses as $course ){
501
-            $courses_options[ $course->ID ] = get_the_title( $course ) ;
500
+        foreach ($courses as $course) {
501
+            $courses_options[$course->ID] = get_the_title($course);
502 502
         }
503
-        $html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args );
503
+        $html .= Sensei_Utils::generate_drop_down($selected_lesson_course, $courses_options, $drop_down_args);
504 504
 
505 505
         // Course Actions Panel
506
-		if ( current_user_can( 'publish_courses' )) {
506
+		if (current_user_can('publish_courses')) {
507 507
 				$html .= '<div id="lesson-course-actions">';
508 508
 					$html .= '<p>';
509 509
 						// Add a course action link
510
-						$html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ ' . __('Add New Course', 'woothemes-sensei' ) . '</a>';
510
+						$html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ '.__('Add New Course', 'woothemes-sensei').'</a>';
511 511
 					$html .= '</p>';
512 512
 				$html .= '</div>';
513 513
 				// Add a course input fields
514 514
 				$html .= '<div id="lesson-course-details" class="hidden">';
515 515
 					$html .= '<p>';
516 516
 						// Course Title input
517
-						$html .= '<label>' . __( 'Course Title' , 'woothemes-sensei' ) . '</label> ';
517
+						$html .= '<label>'.__('Course Title', 'woothemes-sensei').'</label> ';
518 518
 	  					$html .= '<input type="text" id="course-title" name="course_title" value="" size="25" class="widefat" />';
519 519
 	  					// Course Description input
520
-	  					$html .= '<label>' . __( 'Description' , 'woothemes-sensei' ) . '</label> ';
520
+	  					$html .= '<label>'.__('Description', 'woothemes-sensei').'</label> ';
521 521
 	  					$html .= '<textarea rows="10" cols="40" id="course-content" name="course_content" value="" size="300" class="widefat"></textarea>';
522 522
 	  					// Course Prerequisite
523
-	  					$html .= '<label>' . __( 'Course Prerequisite' , 'woothemes-sensei' ) . '</label> ';
524
-	  					$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n";
525
-							$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
526
-							foreach ($posts_array as $post_item){
527
-								$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '">' . esc_html( $post_item->post_title ) . '</option>' . "\n";
523
+	  					$html .= '<label>'.__('Course Prerequisite', 'woothemes-sensei').'</label> ';
524
+	  					$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">'."\n";
525
+							$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
526
+							foreach ($posts_array as $post_item) {
527
+								$html .= '<option value="'.esc_attr(absint($post_item->ID)).'">'.esc_html($post_item->post_title).'</option>'."\n";
528 528
 							} // End For Loop
529
-						$html .= '</select>' . "\n";
529
+						$html .= '</select>'."\n";
530 530
 						// Course Product
531
-                        if ( Sensei_WC::is_woocommerce_active() ) {
531
+                        if (Sensei_WC::is_woocommerce_active()) {
532 532
 	  						// Get the Products
533
-							$select_course_woocommerce_product = get_post_meta( $post_item->ID, '_course_woocommerce_product', true );
533
+							$select_course_woocommerce_product = get_post_meta($post_item->ID, '_course_woocommerce_product', true);
534 534
 
535
-							$product_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
535
+							$product_args = array('post_type' 		=> array('product', 'product_variation'),
536 536
 													'posts_per_page' 		=> -1,
537 537
 													'orderby'         	=> 'title',
538 538
 	    											'order'           	=> 'DESC',
539
-	    											'post_status'		=> array( 'publish', 'private', 'draft' ),
539
+	    											'post_status'		=> array('publish', 'private', 'draft'),
540 540
 	    											'tax_query'			=> array(
541 541
 														array(
542 542
 															'taxonomy'	=> 'product_type',
543 543
 															'field'		=> 'slug',
544
-															'terms'		=> array( 'variable', 'grouped' ),
544
+															'terms'		=> array('variable', 'grouped'),
545 545
 															'operator'	=> 'NOT IN'
546 546
 														)
547 547
 													),
548 548
 	    											'suppress_filters' 	=> 0
549 549
 													);
550
-							$products_array = get_posts( $product_args );
551
-							$html .= '<label>' . __( 'WooCommerce Product' , 'woothemes-sensei' ) . '</label> ';
552
-	  						$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n";
553
-								$html .= '<option value="-">' . __( 'None', 'woothemes-sensei' ) . '</option>';
550
+							$products_array = get_posts($product_args);
551
+							$html .= '<label>'.__('WooCommerce Product', 'woothemes-sensei').'</label> ';
552
+	  						$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">'."\n";
553
+								$html .= '<option value="-">'.__('None', 'woothemes-sensei').'</option>';
554 554
 								$prev_parent_id = 0;
555
-								foreach ($products_array as $products_item){
555
+								foreach ($products_array as $products_item) {
556 556
 
557
-									if ( 'product_variation' == $products_item->post_type ) {
558
-										$product_object = get_product( $products_item->ID );
559
-										$parent_id = wp_get_post_parent_id( $products_item->ID );
560
-										$product_name = ucwords( woocommerce_get_formatted_variation( $product_object->variation_data, true ) );
557
+									if ('product_variation' == $products_item->post_type) {
558
+										$product_object = get_product($products_item->ID);
559
+										$parent_id = wp_get_post_parent_id($products_item->ID);
560
+										$product_name = ucwords(woocommerce_get_formatted_variation($product_object->variation_data, true));
561 561
 									} else {
562 562
 										$parent_id = false;
563 563
 										$prev_parent_id = 0;
@@ -565,32 +565,32 @@  discard block
 block discarded – undo
565 565
 									}
566 566
 
567 567
 									// Show variations in groups
568
-									if( $parent_id && $parent_id != $prev_parent_id ) {
569
-										if( 0 != $prev_parent_id ) {
568
+									if ($parent_id && $parent_id != $prev_parent_id) {
569
+										if (0 != $prev_parent_id) {
570 570
 											$html .= '</optgroup>';
571 571
 										}
572
-										$html .= '<optgroup label="' . get_the_title( $parent_id ) . '">';
572
+										$html .= '<optgroup label="'.get_the_title($parent_id).'">';
573 573
 										$prev_parent_id = $parent_id;
574
-									} elseif( ! $parent_id && 0 == $prev_parent_id ) {
574
+									} elseif ( ! $parent_id && 0 == $prev_parent_id) {
575 575
 										$html .= '</optgroup>';
576 576
 									}
577 577
 
578
-									$html .= '<option value="' . esc_attr( absint( $products_item->ID ) ) . '">' . esc_html( $products_item->post_title ) . '</option>' . "\n";
578
+									$html .= '<option value="'.esc_attr(absint($products_item->ID)).'">'.esc_html($products_item->post_title).'</option>'."\n";
579 579
 								} // End For Loop
580
-							$html .= '</select>' . "\n";
580
+							$html .= '</select>'."\n";
581 581
 						} else {
582 582
 							// Default
583 583
 							$html .= '<input type="hidden" name="course_woocommerce_product" id="course-woocommerce-product-options" value="-" />';
584 584
 						}
585 585
 						// Course Category
586
-	  					$html .= '<label>' . __( 'Course Category' , 'woothemes-sensei' ) . '</label> ';
587
-	  					$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' );
588
-						$html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args)) . "\n";
586
+	  					$html .= '<label>'.__('Course Category', 'woothemes-sensei').'</label> ';
587
+	  					$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');
588
+						$html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args))."\n";
589 589
 	  					// Save the course action button
590
-	  					$html .= '<a title="' . esc_attr( __( 'Save Course', 'woothemes-sensei' ) ) . '" href="#add-course-metadata" class="lesson_course_save button button-highlighted">' . esc_html( __( 'Add Course', 'woothemes-sensei' ) ) . '</a>';
590
+	  					$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>';
591 591
 						$html .= '&nbsp;&nbsp;&nbsp;';
592 592
 						// Cancel action link
593
-						$html .= '<a href="#course-add-cancel" class="lesson_course_cancel">' . __( 'Cancel', 'woothemes-sensei' ) . '</a>';
593
+						$html .= '<a href="#course-add-cancel" class="lesson_course_cancel">'.__('Cancel', 'woothemes-sensei').'</a>';
594 594
 					$html .= '</p>';
595 595
 				$html .= '</div>';
596 596
 			} // End If Statement
@@ -599,20 +599,20 @@  discard block
 block discarded – undo
599 599
 		echo $html;
600 600
 	} // End lesson_course_meta_box_content()
601 601
 
602
-	public function quiz_panel( $quiz_id = 0 ) {
602
+	public function quiz_panel($quiz_id = 0) {
603 603
 
604
-		$html = wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
604
+		$html = wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
605 605
 		$html .= '<div id="add-quiz-main">';
606
-			if ( 0 == $quiz_id ) {
606
+			if (0 == $quiz_id) {
607 607
 				$html .= '<p>';
608 608
 					// Default message and Add a Quiz button
609
-					$html .= esc_html( __( 'Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei' ) );
609
+					$html .= esc_html(__('Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei'));
610 610
 				$html .= '</p>';
611 611
 			}
612 612
 
613 613
 			// Quiz Panel CSS Class
614 614
 			$quiz_class = '';
615
-			if ( 0 == $quiz_id ) {
615
+			if (0 == $quiz_id) {
616 616
 				$quiz_class = ' class="hidden"';
617 617
 			} // End If Statement
618 618
 			// Build the HTML to Output
@@ -620,15 +620,15 @@  discard block
 block discarded – undo
620 620
 
621 621
 			// Setup Questions Query
622 622
 			$questions = array();
623
-			if ( 0 < $quiz_id ) {
624
-				$questions = $this->lesson_quiz_questions( $quiz_id );
623
+			if (0 < $quiz_id) {
624
+				$questions = $this->lesson_quiz_questions($quiz_id);
625 625
 			} // End If Statement
626 626
 
627 627
 			$question_count = 0;
628
-			foreach( $questions as $question ) {
628
+			foreach ($questions as $question) {
629 629
 
630
-				if( $question->post_type == 'multiple_question' ) {
631
-					$question_number = get_post_meta( $question->ID, 'number', true );
630
+				if ($question->post_type == 'multiple_question') {
631
+					$question_number = get_post_meta($question->ID, 'number', true);
632 632
 					$question_count += $question_number;
633 633
 				} else {
634 634
 					++$question_count;
@@ -637,68 +637,68 @@  discard block
 block discarded – undo
637 637
 			}
638 638
 
639 639
 			// Inner DIV
640
-			$html .= '<div id="add-quiz-metadata"' . $quiz_class . '>';
640
+			$html .= '<div id="add-quiz-metadata"'.$quiz_class.'>';
641 641
 
642 642
 				// Quiz ID
643
-				$html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="' . esc_attr( $quiz_id ) . '" />';
643
+				$html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="'.esc_attr($quiz_id).'" />';
644 644
 
645 645
 				// Default Message
646
-				if ( 0 == $quiz_id ) {
646
+				if (0 == $quiz_id) {
647 647
 					$html .= '<p class="save-note">';
648
-						$html .= esc_html( __( 'Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei' ) );
648
+						$html .= esc_html(__('Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei'));
649 649
 					$html .= '</p>';
650 650
 				} // End If Statement
651 651
 
652 652
 			$html .= '</div>';
653 653
 
654 654
 			// Question Container DIV
655
-			$html .= '<div id="add-question-main"' . $quiz_class . '>';
655
+			$html .= '<div id="add-question-main"'.$quiz_class.'>';
656 656
 				// Inner DIV
657 657
 				$html .= '<div id="add-question-metadata">';
658 658
 
659 659
 					// Count of questions
660
-					$html .= '<input type="hidden" name="question_counter" id="question_counter" value="' . esc_attr( $question_count ) . '" />';
660
+					$html .= '<input type="hidden" name="question_counter" id="question_counter" value="'.esc_attr($question_count).'" />';
661 661
 					// Table headers
662 662
 					$html .= '<table class="widefat" id="sortable-questions">
663 663
 								<thead>
664 664
 								    <tr>
665 665
 								        <th class="question-count-column">#</th>
666
-								        <th>' . __( 'Question', 'woothemes-sensei' ) . '</th>
667
-								        <th style="width:45px;">' . __( 'Grade', 'woothemes-sensei' ) . '</th>
668
-								        <th style="width:125px;">' . __( 'Type', 'woothemes-sensei' ) . '</th>
669
-								        <th style="width:125px;">' . __( 'Action', 'woothemes-sensei' ) . '</th>
666
+								        <th>' . __('Question', 'woothemes-sensei').'</th>
667
+								        <th style="width:45px;">' . __('Grade', 'woothemes-sensei').'</th>
668
+								        <th style="width:125px;">' . __('Type', 'woothemes-sensei').'</th>
669
+								        <th style="width:125px;">' . __('Action', 'woothemes-sensei').'</th>
670 670
 								    </tr>
671 671
 								</thead>
672 672
 								<tfoot>
673 673
 								    <tr>
674 674
 									    <th class="question-count-column">#</th>
675
-									    <th>' . __( 'Question', 'woothemes-sensei' ) . '</th>
676
-									    <th>' . __( 'Grade', 'woothemes-sensei' ) . '</th>
677
-									    <th>' . __( 'Type', 'woothemes-sensei' ) . '</th>
678
-									    <th>' . __( 'Action', 'woothemes-sensei' ) . '</th>
675
+									    <th>' . __('Question', 'woothemes-sensei').'</th>
676
+									    <th>' . __('Grade', 'woothemes-sensei').'</th>
677
+									    <th>' . __('Type', 'woothemes-sensei').'</th>
678
+									    <th>' . __('Action', 'woothemes-sensei').'</th>
679 679
 								    </tr>
680 680
 								</tfoot>';
681 681
 
682 682
 					$message_class = '';
683
-					if ( 0 < $question_count ) { $message_class = 'hidden'; }
683
+					if (0 < $question_count) { $message_class = 'hidden'; }
684 684
 
685
-					$html .= '<tbody id="no-questions-message" class="' . esc_attr( $message_class ) . '">';
685
+					$html .= '<tbody id="no-questions-message" class="'.esc_attr($message_class).'">';
686 686
 						$html .= '<tr>';
687
-							$html .= '<td colspan="5">' . __( 'There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei' ) . '</td>';
687
+							$html .= '<td colspan="5">'.__('There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei').'</td>';
688 688
 						$html .= '</tr>';
689 689
 					$html .= '</tbody>';
690 690
 
691
-					if( 0 < $question_count ) {
692
-						$html .= $this->quiz_panel_questions( $questions );
691
+					if (0 < $question_count) {
692
+						$html .= $this->quiz_panel_questions($questions);
693 693
 					}
694 694
 
695 695
 					$html .= '</table>';
696 696
 
697
-					if( ! isset( $this->question_order ) ) {
697
+					if ( ! isset($this->question_order)) {
698 698
 						$this->question_order = '';
699 699
 					}
700 700
 
701
-					$html .= '<input type="hidden" id="question-order" name="question-order" value="' . $this->question_order . '" />';
701
+					$html .= '<input type="hidden" id="question-order" name="question-order" value="'.$this->question_order.'" />';
702 702
 
703 703
 				$html .= '</div>';
704 704
 
@@ -717,47 +717,47 @@  discard block
 block discarded – undo
717 717
 
718 718
 	}
719 719
 
720
-	public function quiz_panel_questions( $questions = array() ) {
720
+	public function quiz_panel_questions($questions = array()) {
721 721
 		global $quiz_questions;
722 722
 
723 723
 		$quiz_questions = $questions;
724 724
 
725 725
 		$html = '';
726 726
 
727
-		if( count( $questions ) > 0 ) {
727
+		if (count($questions) > 0) {
728 728
 
729 729
 			$question_class = '';
730 730
 			$question_counter = 1;
731 731
 
732
-			foreach ( $questions as $question ) {
732
+			foreach ($questions as $question) {
733 733
 
734 734
 				$question_id = $question->ID;
735 735
 
736
-				$question_type = Sensei()->question->get_question_type( $question_id );
736
+				$question_type = Sensei()->question->get_question_type($question_id);
737 737
 
738 738
 				$multiple_data = array();
739 739
 				$question_increment = 1;
740
-				if( 'multiple_question' == $question->post_type ) {
740
+				if ('multiple_question' == $question->post_type) {
741 741
 					$question_type = 'category';
742 742
 
743
-					$question_category = get_post_meta( $question->ID, 'category', true );
744
-					$question_cat = get_term( $question_category, 'question-category' );
743
+					$question_category = get_post_meta($question->ID, 'category', true);
744
+					$question_cat = get_term($question_category, 'question-category');
745 745
 
746
-					$question_number = get_post_meta( $question->ID, 'number', true );
746
+					$question_number = get_post_meta($question->ID, 'number', true);
747 747
 					$question_increment = $question_number;
748 748
 
749
-					$multiple_data = array( $question_cat->name, $question_number );
749
+					$multiple_data = array($question_cat->name, $question_number);
750 750
 				}
751 751
 
752
-				if( ! $question_type ) {
752
+				if ( ! $question_type) {
753 753
 					$question_type = 'multiple-choice';
754 754
 				}
755 755
 
756 756
 				// Row with question and actions
757
-				$html .= $this->quiz_panel_question( $question_type, $question_counter, $question_id, 'quiz', $multiple_data );
757
+				$html .= $this->quiz_panel_question($question_type, $question_counter, $question_id, 'quiz', $multiple_data);
758 758
 				$question_counter += $question_increment;
759 759
 
760
-				if( isset( $this->question_order ) && strlen( $this->question_order ) > 0 ) { $this->question_order .= ','; }
760
+				if (isset($this->question_order) && strlen($this->question_order) > 0) { $this->question_order .= ','; }
761 761
 				$this->question_order .= $question_id;
762 762
 			} // End For Loop
763 763
 		}
@@ -766,161 +766,161 @@  discard block
 block discarded – undo
766 766
 
767 767
 	}
768 768
 
769
-	public function quiz_panel_question( $question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array() ) {
770
-		global $row_counter,  $quiz_questions;
769
+	public function quiz_panel_question($question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array()) {
770
+		global $row_counter, $quiz_questions;
771 771
 
772 772
 		$html = '';
773 773
 
774 774
 		$question_class = '';
775
-		if( 'quiz' == $context ) {
776
-			if( ! $row_counter || ! isset( $row_counter ) ) {
775
+		if ('quiz' == $context) {
776
+			if ( ! $row_counter || ! isset($row_counter)) {
777 777
 				$row_counter = 1;
778 778
 			}
779
-			if( $row_counter % 2 ) { $question_class = 'alternate'; }
779
+			if ($row_counter % 2) { $question_class = 'alternate'; }
780 780
 			++$row_counter;
781 781
 		}
782 782
 
783
-		if( $question_id ) {
783
+		if ($question_id) {
784 784
 
785
-			if( $question_type != 'category' ) {
785
+			if ($question_type != 'category') {
786 786
 
787
-				$question_grade = Sensei()->question->get_question_grade( $question_id );
787
+				$question_grade = Sensei()->question->get_question_grade($question_id);
788 788
 
789
-				$question_media = get_post_meta( $question_id, '_question_media', true );
789
+				$question_media = get_post_meta($question_id, '_question_media', true);
790 790
 				$question_media_type = $question_media_thumb = $question_media_link = $question_media_title = '';
791 791
 				$question_media_thumb_class = $question_media_link_class = $question_media_delete_class = 'hidden';
792
-				$question_media_add_button = __( 'Add file', 'woothemes-sensei' );
793
-				if( 0 < intval( $question_media ) ) {
794
-					$mimetype = get_post_mime_type( $question_media );
795
-					if( $mimetype ) {
796
-						$mimetype_array = explode( '/', $mimetype);
797
-						if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) {
792
+				$question_media_add_button = __('Add file', 'woothemes-sensei');
793
+				if (0 < intval($question_media)) {
794
+					$mimetype = get_post_mime_type($question_media);
795
+					if ($mimetype) {
796
+						$mimetype_array = explode('/', $mimetype);
797
+						if (isset($mimetype_array[0]) && $mimetype_array[0]) {
798 798
 							$question_media_delete_class = '';
799 799
 							$question_media_type = $mimetype_array[0];
800
-							if( 'image' == $question_media_type ) {
801
-								$question_media_thumb = wp_get_attachment_thumb_url( $question_media );
802
-								if( $question_media_thumb ) {
800
+							if ('image' == $question_media_type) {
801
+								$question_media_thumb = wp_get_attachment_thumb_url($question_media);
802
+								if ($question_media_thumb) {
803 803
 									$question_media_thumb_class = '';
804 804
 								}
805 805
 							}
806
-							$question_media_url = wp_get_attachment_url( $question_media );
807
-							if( $question_media_url ) {
808
-								$attachment = get_post( $question_media );
806
+							$question_media_url = wp_get_attachment_url($question_media);
807
+							if ($question_media_url) {
808
+								$attachment = get_post($question_media);
809 809
 								$question_media_title = $attachment->post_title;
810 810
 
811
-								if( ! $question_media_title ) {
812
-									$question_media_filename = basename( $question_media_url );
811
+								if ( ! $question_media_title) {
812
+									$question_media_filename = basename($question_media_url);
813 813
 									$question_media_title = $question_media_filename;
814 814
 								}
815
-								$question_media_link = '<a class="' . $question_media_type . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_title . '</a>';
815
+								$question_media_link = '<a class="'.$question_media_type.'" href="'.esc_url($question_media_url).'" target="_blank">'.$question_media_title.'</a>';
816 816
 								$question_media_link_class = '';
817 817
 							}
818 818
 
819
-							$question_media_add_button = __( 'Change file', 'woothemes-sensei' );
819
+							$question_media_add_button = __('Change file', 'woothemes-sensei');
820 820
 						}
821 821
 					}
822 822
 				}
823 823
 
824
-				$random_order = get_post_meta( $question_id, '_random_order', true );
825
-				if( ! $random_order ) {
824
+				$random_order = get_post_meta($question_id, '_random_order', true);
825
+				if ( ! $random_order) {
826 826
 					$random_order = 'yes';
827 827
 				}
828 828
 
829
-				if( ! $question_type ) { $question_type = 'multiple-choice'; }
829
+				if ( ! $question_type) { $question_type = 'multiple-choice'; }
830 830
 			}
831 831
 
832
-			$html .= '<tbody class="' . $question_class . '">';
832
+			$html .= '<tbody class="'.$question_class.'">';
833 833
 
834
-				if( 'quiz' == $context ) {
834
+				if ('quiz' == $context) {
835 835
 					$html .= '<tr>';
836
-						if( $question_type != 'category' ) {
837
-							$question = get_post( $question_id );
838
-							$html .= '<td class="table-count question-number question-count-column"><span class="number">' . $question_counter . '</span></td>';
839
-							$html .= '<td>' . esc_html( $question->post_title ) . '</td>';
840
-							$html .= '<td class="question-grade-column">' . esc_html( $question_grade ) . '</td>';
841
-							$question_types_filtered = ucwords( str_replace( array( '-', 'boolean' ), array( ' ', __( 'True/False', 'woothemes-sensei' ) ), $question_type ) );
842
-							$html .= '<td>' . esc_html( $question_types_filtered ) . '</td>';
843
-							$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>';
836
+						if ($question_type != 'category') {
837
+							$question = get_post($question_id);
838
+							$html .= '<td class="table-count question-number question-count-column"><span class="number">'.$question_counter.'</span></td>';
839
+							$html .= '<td>'.esc_html($question->post_title).'</td>';
840
+							$html .= '<td class="question-grade-column">'.esc_html($question_grade).'</td>';
841
+							$question_types_filtered = ucwords(str_replace(array('-', 'boolean'), array(' ', __('True/False', 'woothemes-sensei')), $question_type));
842
+							$html .= '<td>'.esc_html($question_types_filtered).'</td>';
843
+							$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 844
 
845 845
 						} else {
846 846
 
847
-							$end_number = intval( $question_counter ) + intval( $multiple_data[1] ) - 1;
848
-							if( $question_counter == $end_number ) {
847
+							$end_number = intval($question_counter) + intval($multiple_data[1]) - 1;
848
+							if ($question_counter == $end_number) {
849 849
 								$row_numbers = $question_counter;
850 850
 							} else {
851
-								$row_numbers = $question_counter . ' - ' . $end_number;
851
+								$row_numbers = $question_counter.' - '.$end_number;
852 852
 							}
853
-							$row_title = sprintf( __( 'Selected from \'%1$s\' ', 'woothemes-sensei' ), $multiple_data[0] );
853
+							$row_title = sprintf(__('Selected from \'%1$s\' ', 'woothemes-sensei'), $multiple_data[0]);
854 854
 
855
-							$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>';
856
-							$html .= '<td>' . esc_html( $row_title ) . '</td>';
855
+							$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>';
856
+							$html .= '<td>'.esc_html($row_title).'</td>';
857 857
 							$html .= '<td class="question-grade-column"></td>';
858
-							$html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" /></td>';
859
-							$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>';
858
+							$html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" /></td>';
859
+							$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>';
860 860
 
861 861
 						}
862 862
 					$html .= '</tr>';
863 863
 				}
864 864
 
865
-				if( $question_type != 'category' ) {
865
+				if ($question_type != 'category') {
866 866
 
867 867
 					$edit_class = '';
868
-					if( 'quiz' == $context ) {
868
+					if ('quiz' == $context) {
869 869
 						$edit_class = 'hidden';
870 870
 					}
871 871
 
872
-					$question = get_post( $question_id );
873
-					$html .= '<tr class="question-quick-edit ' . esc_attr( $edit_class ) . '">';
872
+					$question = get_post($question_id);
873
+					$html .= '<tr class="question-quick-edit '.esc_attr($edit_class).'">';
874 874
 						$html .= '<td colspan="5">';
875
-							$html .= '<span class="hidden question_original_counter">' . $question_counter . '</span>';
875
+							$html .= '<span class="hidden question_original_counter">'.$question_counter.'</span>';
876 876
 					    	$html .= '<div class="question_required_fields">';
877 877
 
878 878
 						    	// Question title
879 879
 						    	$html .= '<div>';
880
-							    	$html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> ';
881
-							    	$html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />';
880
+							    	$html .= '<label for="question_'.$question_counter.'">'.__('Question:', 'woothemes-sensei').'</label> ';
881
+							    	$html .= '<input type="text" id="question_'.$question_counter.'" name="question" value="'.esc_attr(htmlspecialchars($question->post_title)).'" size="25" class="widefat" />';
882 882
 						    	$html .= '</div>';
883 883
 
884 884
 						    	// Question description
885 885
 						    	$html .= '<div>';
886
-							    	$html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
886
+							    	$html .= '<label for="question_'.$question_counter.'_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> ';
887 887
 						    	$html .= '</div>';
888
-							    	$html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>';
888
+							    	$html .= '<textarea id="question_'.$question_counter.'_desc" name="question_description" class="widefat" rows="4">'.esc_textarea($question->post_content).'</textarea>';
889 889
 
890 890
 						    	// Question grade
891 891
 						    	$html .= '<div>';
892
-							    	$html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> ';
893
-							    	$html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />';
892
+							    	$html .= '<label for="question_'.$question_counter.'_grade">'.__('Question grade:', 'woothemes-sensei').'</label> ';
893
+							    	$html .= '<input type="number" id="question_'.$question_counter.'_grade" class="question_grade small-text" name="question_grade" min="0" value="'.$question_grade.'" />';
894 894
 						    	$html .= '</div>';
895 895
 
896 896
 						    	// Random order
897
-						    	if( $question_type == 'multiple-choice' ) {
897
+						    	if ($question_type == 'multiple-choice') {
898 898
 						    		$html .= '<div>';
899
-						    			$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 .= '<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>';
900 900
 						    		$html .= '</div>';
901 901
 						    	}
902 902
 
903 903
 						    	// Question media
904 904
 						    	$html .= '<div>';
905
-							    	$html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
906
-							    	$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>';
907
-							    	$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/>';
908
-							    	$html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>';
909
-							    	$html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>';
910
-							    	$html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />';
905
+							    	$html .= '<label for="question_'.$question_counter.'_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>';
906
+							    	$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>';
907
+							    	$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/>';
908
+							    	$html .= '<span id="question_'.$question_counter.'_media_link" class="question_media_link '.$question_media_link_class.'">'.$question_media_link.'</span>';
909
+							    	$html .= '<br/><img id="question_'.$question_counter.'_media_preview" class="question_media_preview '.$question_media_thumb_class.'" src="'.$question_media_thumb.'" /><br/>';
910
+							    	$html .= '<input type="hidden" id="question_'.$question_counter.'_media" class="question_media" name="question_media" value="'.$question_media.'" />';
911 911
 						    	$html .= '</div>';
912 912
 
913 913
 						    $html .= '</div>';
914 914
 
915
-						    $html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter );
915
+						    $html .= $this->quiz_panel_question_field($question_type, $question_id, $question_counter);
916 916
 
917
-						    $html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />';
918
-							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" />';
917
+						    $html .= '<input type="hidden" id="question_'.$question_counter.'_question_type" class="question_type" name="question_type" value="'.$question_type.'" />';
918
+							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" />';
919 919
 
920
-							if( 'quiz' == $context ) {
920
+							if ('quiz' == $context) {
921 921
 					    		$html .= '<div class="update-question">';
922
-						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> ';
923
-						    		$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>';
922
+						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="'.esc_attr(__('Cancel', 'woothemes-sensei')).'">'.__('Cancel', 'woothemes-sensei').'</a> ';
923
+						    		$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>';
924 924
 					    		$html .= '</div>';
925 925
 					    	}
926 926
 
@@ -935,79 +935,79 @@  discard block
 block discarded – undo
935 935
 		return $html;
936 936
 	}
937 937
 
938
-	public function quiz_panel_add( $context = 'quiz' ) {
938
+	public function quiz_panel_add($context = 'quiz') {
939 939
 
940 940
 
941 941
 		$html = '<div id="add-new-question">';
942 942
 
943 943
 			$question_types = Sensei()->question->question_types();
944 944
 
945
-			$question_cats = get_terms( 'question-category', array( 'hide_empty' => false ) );
945
+			$question_cats = get_terms('question-category', array('hide_empty' => false));
946 946
 
947
-			if( 'quiz' == $context ) {
947
+			if ('quiz' == $context) {
948 948
 	    		$html .= '<h2 class="nav-tab-wrapper add-question-tabs">';
949
-	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question'  , 'woothemes-sensei' ) . '</a>';
950
-	    			$html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions'  , 'woothemes-sensei' ) . '</a>';
951
-                    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats )  && ! Sensei()->teacher->is_admin_teacher() ) {
952
-	    				$html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions'  , 'woothemes-sensei' ) . '</a>';
949
+	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">'.__('New Question', 'woothemes-sensei').'</a>';
950
+	    			$html .= '<a id="tab-existing" class="nav-tab">'.__('Existing Questions', 'woothemes-sensei').'</a>';
951
+                    if ( ! empty($question_cats) && ! is_wp_error($question_cats) && ! Sensei()->teacher->is_admin_teacher()) {
952
+	    				$html .= '<a id="tab-multiple" class="nav-tab">'.__('Category Questions', 'woothemes-sensei').'</a>';
953 953
 	    			}
954 954
 	    		$html .= '</h2>';
955 955
 	    	}
956 956
 
957 957
 	    	$html .= '<div class="tab-content" id="tab-new-content">';
958 958
 
959
-	    		if( 'quiz' == $context ) {
960
-	    			$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>';
959
+	    		if ('quiz' == $context) {
960
+	    			$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>';
961 961
 	    		}
962 962
 
963 963
 				$html .= '<div class="question">';
964 964
 					$html .= '<div class="question_required_fields">';
965 965
 
966 966
 						// Question title
967
-						$html .= '<p><label>' . __( 'Question:'  , 'woothemes-sensei' ) . '</label> ';
967
+						$html .= '<p><label>'.__('Question:', 'woothemes-sensei').'</label> ';
968 968
 	  					$html .= '<input type="text" id="add_question" name="question" value="" size="25" class="widefat" /></p>';
969 969
 
970 970
 						// Question description
971 971
 						$html .= '<p>';
972
-							$html .= '<label for="question_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
972
+							$html .= '<label for="question_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> ';
973 973
 						$html .= '</p>';
974 974
 						$html .= '<textarea id="question_desc" name="question_description" class="widefat" rows="4"></textarea>';
975 975
 
976 976
 	  					// Question type
977
-						$html .= '<p><label>' . __( 'Question Type:' , 'woothemes-sensei' ) . '</label> ';
978
-						$html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">' . "\n";
979
-							foreach ( $question_types as $type => $label ) {
980
-								$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>' . "\n";
977
+						$html .= '<p><label>'.__('Question Type:', 'woothemes-sensei').'</label> ';
978
+						$html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">'."\n";
979
+							foreach ($question_types as $type => $label) {
980
+								$html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>'."\n";
981 981
 							} // End For Loop
982
-						$html .= '</select></p>' . "\n";
982
+						$html .= '</select></p>'."\n";
983 983
 
984 984
 						// Question category
985
-						if( 'quiz' == $context ) {
986
-							if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
987
-								$html .= '<p><label>' . __( 'Question Category:' , 'woothemes-sensei' ) . '</label> ';
988
-								$html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">' . "\n";
989
-								$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>' . "\n";
990
-								foreach( $question_cats as $cat ) {
991
-									$html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>';
985
+						if ('quiz' == $context) {
986
+							if ( ! empty($question_cats) && ! is_wp_error($question_cats)) {
987
+								$html .= '<p><label>'.__('Question Category:', 'woothemes-sensei').'</label> ';
988
+								$html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">'."\n";
989
+								$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'."\n";
990
+								foreach ($question_cats as $cat) {
991
+									$html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>';
992 992
 								} // End For Loop
993
-								$html .= '</select></p>' . "\n";
993
+								$html .= '</select></p>'."\n";
994 994
 							}
995 995
 						}
996 996
 
997 997
 	  					// Question grade
998
-						$html .= '<p><label>' . __( 'Question Grade:'  , 'woothemes-sensei' ) . '</label> ';
999
-						$html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>' . "\n";
998
+						$html .= '<p><label>'.__('Question Grade:', 'woothemes-sensei').'</label> ';
999
+						$html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>'."\n";
1000 1000
 
1001 1001
 						// Random order
1002 1002
 						$html .= '<p class="add_question_random_order">';
1003
-			    			$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 .= '<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>';
1004 1004
 			    		$html .= '</p>';
1005 1005
 
1006 1006
 			    		// Question media
1007 1007
 						$html .= '<p>';
1008
-					    	$html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
1009
-					    	$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>';
1010
-					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
1008
+					    	$html .= '<label for="question_add_new_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>';
1009
+					    	$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>';
1010
+					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">'.__('Delete file', 'woothemes-sensei').'</button><br/>';
1011 1011
 					    	$html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>';
1012 1012
 					    	$html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>';
1013 1013
 					    	$html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />';
@@ -1016,44 +1016,44 @@  discard block
 block discarded – undo
1016 1016
 					$html .= '</div>';
1017 1017
 				$html .= '</div>';
1018 1018
 
1019
-				foreach ( $question_types as $type => $label ) {
1020
-					$html .= $this->quiz_panel_question_field( $type );
1019
+				foreach ($question_types as $type => $label) {
1020
+					$html .= $this->quiz_panel_question_field($type);
1021 1021
 				}
1022 1022
 
1023
-				if( 'quiz' == $context ) {
1023
+				if ('quiz' == $context) {
1024 1024
 					$html .= '<div class="add-question">';
1025
-			    		$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 .= '<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>';
1026 1026
 		    		$html .= '</div>';
1027 1027
 		    	}
1028 1028
 
1029 1029
 		    $html .= '</div>';
1030 1030
 
1031
-		    if( 'quiz' == $context ) {
1031
+		    if ('quiz' == $context) {
1032 1032
 
1033 1033
 			    $html .= '<div class="tab-content hidden" id="tab-existing-content">';
1034 1034
 
1035
-			    	$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
+			    	$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>';
1036 1036
 
1037 1037
 			    	$html .= '<div id="existing-filters" class="alignleft actions">
1038 1038
 			    				<select id="existing-status">
1039
-			    					<option value="all">' . __( 'All', 'woothemes-sensei' ) . '</option>
1040
-			    					<option value="unused">' . __( 'Unused', 'woothemes-sensei' ) . '</option>
1041
-			    					<option value="used">' . __( 'Used', 'woothemes-sensei' ) . '</option>
1039
+			    					<option value="all">' . __('All', 'woothemes-sensei').'</option>
1040
+			    					<option value="unused">' . __('Unused', 'woothemes-sensei').'</option>
1041
+			    					<option value="used">' . __('Used', 'woothemes-sensei').'</option>
1042 1042
 			    				</select>
1043 1043
 			    				<select id="existing-type">
1044
-			    					<option value="">' . __( 'All Types', 'woothemes-sensei' ) . '</option>';
1045
-							    	foreach ( $question_types as $type => $label ) {
1046
-										$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>';
1044
+			    					<option value="">' . __('All Types', 'woothemes-sensei').'</option>';
1045
+							    	foreach ($question_types as $type => $label) {
1046
+										$html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>';
1047 1047
 									}
1048 1048
     				$html .= '</select>
1049 1049
     							<select id="existing-category">
1050
-			    					<option value="">' . __( 'All Categories', 'woothemes-sensei' ) . '</option>';
1051
-				    				foreach( $question_cats as $cat ) {
1052
-										$html .= '<option value="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat->name ) . '</option>';
1050
+			    					<option value="">' . __('All Categories', 'woothemes-sensei').'</option>';
1051
+				    				foreach ($question_cats as $cat) {
1052
+										$html .= '<option value="'.esc_attr($cat->slug).'">'.esc_html($cat->name).'</option>';
1053 1053
 									}
1054 1054
     				$html .= '</select>
1055
-    							<input type="text" id="existing-search" placeholder="' . __( 'Search', 'woothemes-sensei' ) . '" />
1056
-    							<a class="button" id="existing-filter-button">' . __( 'Filter', 'woothemes-sensei' ) . '</a>
1055
+    							<input type="text" id="existing-search" placeholder="' . __('Search', 'woothemes-sensei').'" />
1056
+    							<a class="button" id="existing-filter-button">' . __('Filter', 'woothemes-sensei').'</a>
1057 1057
 			    			</div>';
1058 1058
 
1059 1059
 			    	$html .= '<table id="existing-table" class="widefat">';
@@ -1061,17 +1061,17 @@  discard block
 block discarded – undo
1061 1061
 			    		$html .= '<thead>
1062 1062
 									    <tr>
1063 1063
 									        <th scope="col" class="column-cb check-column"><input type="checkbox" /></th>
1064
-									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
1065
-									        <th scope="col">' . __( 'Type', 'woothemes-sensei' ) . '</th>
1066
-									        <th scope="col">' . __( 'Category', 'woothemes-sensei' ) . '</th>
1064
+									        <th scope="col">' . __('Question', 'woothemes-sensei').'</th>
1065
+									        <th scope="col">' . __('Type', 'woothemes-sensei').'</th>
1066
+									        <th scope="col">' . __('Category', 'woothemes-sensei').'</th>
1067 1067
 									    </tr>
1068 1068
 									</thead>
1069 1069
 									<tfoot>
1070 1070
 									    <tr>
1071 1071
 										    <th scope="col" class="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
 									</tfoot>';
1077 1077
 						$html .= '<tbody id="existing-questions">';
@@ -1079,8 +1079,8 @@  discard block
 block discarded – undo
1079 1079
 						$questions = $this->quiz_panel_get_existing_questions();
1080 1080
 
1081 1081
 						$row = 1;
1082
-						foreach( $questions['questions'] as $question ) {
1083
-							$html .= $this->quiz_panel_add_existing_question( $question->ID, $row );
1082
+						foreach ($questions['questions'] as $question) {
1083
+							$html .= $this->quiz_panel_add_existing_question($question->ID, $row);
1084 1084
 							++$row;
1085 1085
 						}
1086 1086
 
@@ -1089,36 +1089,36 @@  discard block
 block discarded – undo
1089 1089
 			    	$html .= '</table>';
1090 1090
 
1091 1091
 			    	$next_class = '';
1092
-			    	if( $questions['count'] <= 10 ) {
1092
+			    	if ($questions['count'] <= 10) {
1093 1093
 			    		$next_class = 'hidden';
1094 1094
 			    	}
1095 1095
 
1096 1096
 			    	$html .= '<div id="existing-pagination">';
1097 1097
 			    		$html .= '<input type="hidden" id="existing-page" value="1" />';
1098
-			    		$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 .= '<a class="prev no-paging">&larr; '.__('Previous', 'woothemes-sensei').'</a> <a class="next '.esc_attr($next_class).'">'.__('Next', 'woothemes-sensei').' &rarr;</a>';
1099 1099
 			    	$html .= '</div>';
1100 1100
 
1101 1101
 			    	$html .= '<div class="existing-actions">';
1102
-			    		$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 .= '<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>';
1103 1103
 			    	$html .= '</div>';
1104 1104
 
1105 1105
 			    $html .= '</div>';
1106 1106
 
1107
-			    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
1107
+			    if ( ! empty($question_cats) && ! is_wp_error($question_cats)) {
1108 1108
 				    $html .= '<div class="tab-content hidden" id="tab-multiple-content">';
1109 1109
 
1110
-				    	$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
+				    	$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>';
1111 1111
 
1112
-						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">' . "\n";
1113
-						$html .= '<option value="">' . __( 'Select a Question Category', 'woothemes-sensei' ) . '</option>' . "\n";
1114
-						foreach( $question_cats as $cat ) {
1115
-							$html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>';
1112
+						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">'."\n";
1113
+						$html .= '<option value="">'.__('Select a Question Category', 'woothemes-sensei').'</option>'."\n";
1114
+						foreach ($question_cats as $cat) {
1115
+							$html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>';
1116 1116
 						} // End For Loop
1117
-						$html .= '</select></p>' . "\n";
1117
+						$html .= '</select></p>'."\n";
1118 1118
 
1119
-						$html .= '<p>' . __( 'Number of questions:', 'woothemes-sensei' ) . ' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>';
1119
+						$html .= '<p>'.__('Number of questions:', 'woothemes-sensei').' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>';
1120 1120
 
1121
-						$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
+						$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>';
1122 1122
 
1123 1123
 				    $html .= '</div>';
1124 1124
 				}
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
 		return $html;
1130 1130
 	}
1131 1131
 
1132
-	public function quiz_panel_get_existing_questions( $question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1 ) {
1132
+	public function quiz_panel_get_existing_questions($question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1) {
1133 1133
 
1134 1134
 		$args = array(
1135 1135
 			'post_type' => 'question',
@@ -1138,14 +1138,14 @@  discard block
 block discarded – undo
1138 1138
 			'suppress_filters' => 0,
1139 1139
 		);
1140 1140
 
1141
-		switch( $question_status ) {
1141
+		switch ($question_status) {
1142 1142
 			case 'unused': $quiz_status = 'NOT EXISTS'; break;
1143 1143
 			case 'used': $quiz_status = 'EXISTS'; break;
1144 1144
 			default: $quiz_status = ''; break;
1145 1145
 		}
1146 1146
 
1147
-		if( $quiz_status ) {
1148
-			switch( $quiz_status ) {
1147
+		if ($quiz_status) {
1148
+			switch ($quiz_status) {
1149 1149
 				case 'EXISTS':
1150 1150
 					$args['meta_query'][] = array(
1151 1151
 						'key' => '_quiz_id',
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 			}
1164 1164
 		}
1165 1165
 
1166
-		if( $question_type ) {
1166
+		if ($question_type) {
1167 1167
 			$args['tax_query'][] = array(
1168 1168
 				'taxonomy' => 'question-type',
1169 1169
 				'field' => 'slug',
@@ -1171,7 +1171,7 @@  discard block
 block discarded – undo
1171 1171
 			);
1172 1172
 		}
1173 1173
 
1174
-		if( $question_category ) {
1174
+		if ($question_category) {
1175 1175
 			$args['tax_query'][] = array(
1176 1176
 				'taxonomy' => 'question-category',
1177 1177
 				'field' => 'slug',
@@ -1179,19 +1179,19 @@  discard block
 block discarded – undo
1179 1179
 			);
1180 1180
 		}
1181 1181
 
1182
-		if( $question_type && $question_category ) {
1182
+		if ($question_type && $question_category) {
1183 1183
 			$args['tax_query']['relation'] = 'AND';
1184 1184
 		}
1185 1185
 
1186
-		if( $question_search ) {
1186
+		if ($question_search) {
1187 1187
 			$args['s'] = $question_search;
1188 1188
 		}
1189 1189
 
1190
-		if( $page ) {
1190
+		if ($page) {
1191 1191
 			$args['paged'] = $page;
1192 1192
 		}
1193 1193
 
1194
-		$qry = new WP_Query( $args );
1194
+		$qry = new WP_Query($args);
1195 1195
 
1196 1196
         /**
1197 1197
          * Filter existing questions query
@@ -1200,39 +1200,39 @@  discard block
 block discarded – undo
1200 1200
          *
1201 1201
          * @param WP_Query $wp_query
1202 1202
          */
1203
-        $qry = apply_filters( 'sensei_existing_questions_query_results', $qry );
1203
+        $qry = apply_filters('sensei_existing_questions_query_results', $qry);
1204 1204
 
1205 1205
 		$questions['questions'] = $qry->posts;
1206
-		$questions['count'] = intval( $qry->found_posts );
1206
+		$questions['count'] = intval($qry->found_posts);
1207 1207
 		$questions['page'] = $page;
1208 1208
 
1209 1209
 		return $questions;
1210 1210
 	}
1211 1211
 
1212
-	public function quiz_panel_add_existing_question( $question_id = 0, $row = 1 ) {
1212
+	public function quiz_panel_add_existing_question($question_id = 0, $row = 1) {
1213 1213
 
1214 1214
 		$html = '';
1215 1215
 
1216
-		if( ! $question_id ) {
1216
+		if ( ! $question_id) {
1217 1217
 
1218 1218
             return;
1219 1219
 
1220 1220
         }
1221 1221
 
1222 1222
 		$existing_class = '';
1223
-		if( $row % 2 ) {
1223
+		if ($row % 2) {
1224 1224
             $existing_class = 'alternate';
1225 1225
         }
1226 1226
 
1227
-		$question_type = Sensei()->question->get_question_type( $question_id );
1227
+		$question_type = Sensei()->question->get_question_type($question_id);
1228 1228
 
1229
-		$question_cat_list = strip_tags( get_the_term_list( $question_id, 'question-category', '', ', ', '' ) );
1229
+		$question_cat_list = strip_tags(get_the_term_list($question_id, 'question-category', '', ', ', ''));
1230 1230
 
1231
-		$html .= '<tr class="' . esc_attr( $existing_class ) . '">
1232
-					<td class="cb"><input type="checkbox" value="' . $question_id . '" class="existing-item" /></td>
1233
-					<td>' . get_the_title( $question_id ) . '</td>
1234
-					<td>' . esc_html( $question_type ) . '</td>
1235
-					<td>' . esc_html( $question_cat_list ) . '</td>
1231
+		$html .= '<tr class="'.esc_attr($existing_class).'">
1232
+					<td class="cb"><input type="checkbox" value="' . $question_id.'" class="existing-item" /></td>
1233
+					<td>' . get_the_title($question_id).'</td>
1234
+					<td>' . esc_html($question_type).'</td>
1235
+					<td>' . esc_html($question_cat_list).'</td>
1236 1236
 				  </tr>';
1237 1237
 
1238 1238
 		return $html;
@@ -1245,58 +1245,58 @@  discard block
 block discarded – undo
1245 1245
 
1246 1246
 		//Add nonce security to the request
1247 1247
 		$nonce = '';
1248
-		if( isset( $_POST['filter_existing_questions_nonce'] ) ) {
1249
-			$nonce = esc_html( $_POST['filter_existing_questions_nonce'] );
1248
+		if (isset($_POST['filter_existing_questions_nonce'])) {
1249
+			$nonce = esc_html($_POST['filter_existing_questions_nonce']);
1250 1250
 		} // End If Statement
1251 1251
 
1252
-		if( ! wp_verify_nonce( $nonce, 'filter_existing_questions_nonce' ) ) {
1253
-			die( $return );
1252
+		if ( ! wp_verify_nonce($nonce, 'filter_existing_questions_nonce')) {
1253
+			die($return);
1254 1254
 		} // End If Statement
1255 1255
 
1256 1256
 		// Parse POST data
1257 1257
 		$data = $_POST['data'];
1258 1258
 		$question_data = array();
1259
-		parse_str( $data, $question_data );
1259
+		parse_str($data, $question_data);
1260 1260
 
1261
-		if( 0 < count( $question_data ) ) {
1261
+		if (0 < count($question_data)) {
1262 1262
 
1263 1263
 			$question_status = '';
1264
-			if( isset( $question_data['question_status'] ) ) {
1264
+			if (isset($question_data['question_status'])) {
1265 1265
 				$question_status = $question_data['question_status'];
1266 1266
 			}
1267 1267
 
1268 1268
 			$question_type = '';
1269
-			if( isset( $question_data['question_type'] ) ) {
1269
+			if (isset($question_data['question_type'])) {
1270 1270
 				$question_type = $question_data['question_type'];
1271 1271
 			}
1272 1272
 
1273 1273
 			$question_category = '';
1274
-			if( isset( $question_data['question_category'] ) ) {
1274
+			if (isset($question_data['question_category'])) {
1275 1275
 				$question_category = $question_data['question_category'];
1276 1276
 			}
1277 1277
 
1278 1278
 			$question_search = '';
1279
-			if( isset( $question_data['question_search'] ) ) {
1279
+			if (isset($question_data['question_search'])) {
1280 1280
 				$question_search = $question_data['question_search'];
1281 1281
 			}
1282 1282
 
1283 1283
 			$question_page = 1;
1284
-			if( isset( $question_data['question_page'] ) ) {
1285
-				$question_page = intval( $question_data['question_page'] );
1284
+			if (isset($question_data['question_page'])) {
1285
+				$question_page = intval($question_data['question_page']);
1286 1286
 			}
1287 1287
 
1288
-			$questions = $this->quiz_panel_get_existing_questions( $question_status, $question_type, $question_category, $question_search, $question_page );
1288
+			$questions = $this->quiz_panel_get_existing_questions($question_status, $question_type, $question_category, $question_search, $question_page);
1289 1289
 
1290 1290
 			$row = 1;
1291 1291
 			$html = '';
1292
-			foreach( $questions['questions'] as $question ) {
1293
-				$html .= $this->quiz_panel_add_existing_question( $question->ID, $row );
1292
+			foreach ($questions['questions'] as $question) {
1293
+				$html .= $this->quiz_panel_add_existing_question($question->ID, $row);
1294 1294
 				++$row;
1295 1295
 			}
1296 1296
 
1297
-			if( ! $html ) {
1297
+			if ( ! $html) {
1298 1298
 				$html = '<tr class="alternate">
1299
-								<td class="no-results" colspan="4"><em>' . __( 'There are no questions matching your search.', 'woothemes-sensei' ) . '</em></td>
1299
+								<td class="no-results" colspan="4"><em>' . __('There are no questions matching your search.', 'woothemes-sensei').'</em></td>
1300 1300
 							  </tr>';
1301 1301
 			}
1302 1302
 
@@ -1304,53 +1304,53 @@  discard block
 block discarded – undo
1304 1304
 			$return['count'] = $questions['count'];
1305 1305
 			$return['page'] = $questions['page'];
1306 1306
 
1307
-			wp_send_json( $return );
1307
+			wp_send_json($return);
1308 1308
 		}
1309 1309
 
1310
-		die( $return );
1310
+		die($return);
1311 1311
 	}
1312 1312
 
1313
-	public function quiz_panel_question_field( $question_type = '', $question_id = 0, $question_counter = 0 ) {
1313
+	public function quiz_panel_question_field($question_type = '', $question_id = 0, $question_counter = 0) {
1314 1314
 
1315 1315
 		$html = '';
1316 1316
 
1317
-		if( $question_type ) {
1317
+		if ($question_type) {
1318 1318
 
1319 1319
 			$right_answer = '';
1320 1320
 			$wrong_answers = array();
1321 1321
 			$answer_order_string = '';
1322 1322
 			$answer_order = array();
1323
-			if( $question_id ) {
1324
-				$right_answer = get_post_meta( $question_id, '_question_right_answer', true);
1325
-				$wrong_answers = get_post_meta( $question_id, '_question_wrong_answers', true);
1326
-				$answer_order_string = get_post_meta( $question_id, '_answer_order', true );
1327
-				$answer_order = array_filter( explode( ',', $answer_order_string ) );
1323
+			if ($question_id) {
1324
+				$right_answer = get_post_meta($question_id, '_question_right_answer', true);
1325
+				$wrong_answers = get_post_meta($question_id, '_question_wrong_answers', true);
1326
+				$answer_order_string = get_post_meta($question_id, '_answer_order', true);
1327
+				$answer_order = array_filter(explode(',', $answer_order_string));
1328 1328
 				$question_class = '';
1329 1329
 			} else {
1330 1330
 				$question_id = '';
1331 1331
 				$question_class = 'answer-fields question_required_fields hidden';
1332 1332
 			}
1333 1333
 
1334
-			switch ( $question_type ) {
1334
+			switch ($question_type) {
1335 1335
 				case 'multiple-choice':
1336
-					$html .= '<div class="question_default_fields multiple-choice-answers ' . str_replace( ' hidden', '', $question_class ) . '">';
1336
+					$html .= '<div class="question_default_fields multiple-choice-answers '.str_replace(' hidden', '', $question_class).'">';
1337 1337
 
1338 1338
 						$right_answers = (array) $right_answer;
1339 1339
 						// Calculate total right answers available (defaults to 1)
1340 1340
 						$total_right = 0;
1341
-						if( $question_id ) {
1342
-							$total_right = get_post_meta( $question_id, '_right_answer_count', true );
1341
+						if ($question_id) {
1342
+							$total_right = get_post_meta($question_id, '_right_answer_count', true);
1343 1343
 						}
1344
-						if( 0 == intval( $total_right ) ) {
1344
+						if (0 == intval($total_right)) {
1345 1345
 							$total_right = 1;
1346 1346
 						}
1347
-						for ( $i = 0; $i < $total_right; $i++ ) {
1348
-							if ( !isset( $right_answers[ $i ] ) ) { $right_answers[ $i ] = ''; }
1349
-							$right_answer_id = $this->get_answer_id( $right_answers[ $i ] );
1347
+						for ($i = 0; $i < $total_right; $i++) {
1348
+							if ( ! isset($right_answers[$i])) { $right_answers[$i] = ''; }
1349
+							$right_answer_id = $this->get_answer_id($right_answers[$i]);
1350 1350
 							// Right Answer
1351
-							$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>';
1352
-							if( $question_id ) {
1353
-								$answers[ $right_answer_id ] = $right_answer;
1351
+							$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>';
1352
+							if ($question_id) {
1353
+								$answers[$right_answer_id] = $right_answer;
1354 1354
 							} else {
1355 1355
 								$answers[] = $right_answer;
1356 1356
 							}
@@ -1358,23 +1358,23 @@  discard block
 block discarded – undo
1358 1358
 
1359 1359
 				    	// Calculate total wrong answers available (defaults to 4)
1360 1360
 				    	$total_wrong = 0;
1361
-				    	if( $question_id ) {
1362
-				    		$total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true );
1361
+				    	if ($question_id) {
1362
+				    		$total_wrong = get_post_meta($question_id, '_wrong_answer_count', true);
1363 1363
 				    	}
1364
-				    	if( 0 == intval( $total_wrong ) ) {
1364
+				    	if (0 == intval($total_wrong)) {
1365 1365
 				    		$total_wrong = 1;
1366 1366
 				    	}
1367 1367
 
1368 1368
                         // Setup Wrong Answer HTML
1369
-                        foreach ( $wrong_answers as $i => $answer ){
1369
+                        foreach ($wrong_answers as $i => $answer) {
1370 1370
 
1371
-                            $answer_id = $this->get_answer_id( $answer );
1372
-                            $wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
1373
-                            $wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
1374
-                            $wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1375
-                            if( $question_id ) {
1371
+                            $answer_id = $this->get_answer_id($answer);
1372
+                            $wrong_answer = '<label class="answer" for="question_'.$question_counter.'_wrong_answer_'.$i.'"><span>'.__('Wrong:', 'woothemes-sensei');
1373
+                            $wrong_answer .= '</span> <input rel="'.esc_attr($answer_id).'" type="text" id="question_'.$question_counter.'_wrong_answer_'.$i;
1374
+                            $wrong_answer .= '" name="question_wrong_answers[]" value="'.esc_attr($answer).'" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1375
+                            if ($question_id) {
1376 1376
 
1377
-                                $answers[ $answer_id ] = $wrong_answer;
1377
+                                $answers[$answer_id] = $wrong_answer;
1378 1378
 
1379 1379
                             } else {
1380 1380
 
@@ -1385,115 +1385,115 @@  discard block
 block discarded – undo
1385 1385
                         } // end for each
1386 1386
 
1387 1387
 				    	$answers_sorted = $answers;
1388
-				    	if( $question_id && count( $answer_order ) > 0 ) {
1388
+				    	if ($question_id && count($answer_order) > 0) {
1389 1389
 				    		$answers_sorted = array();
1390
-				    		foreach( $answer_order as $answer_id ) {
1391
-				    			if( isset( $answers[ $answer_id ] ) ) {
1392
-				    				$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1393
-				    				unset( $answers[ $answer_id ] );
1390
+				    		foreach ($answer_order as $answer_id) {
1391
+				    			if (isset($answers[$answer_id])) {
1392
+				    				$answers_sorted[$answer_id] = $answers[$answer_id];
1393
+				    				unset($answers[$answer_id]);
1394 1394
 				    			}
1395 1395
 				    		}
1396 1396
 
1397
-				    		if( count( $answers ) > 0 ) {
1398
-						    	foreach( $answers as $id => $answer ) {
1399
-						    		$answers_sorted[ $id ] = $answer;
1397
+				    		if (count($answers) > 0) {
1398
+						    	foreach ($answers as $id => $answer) {
1399
+						    		$answers_sorted[$id] = $answer;
1400 1400
 						    	}
1401 1401
 						    }
1402 1402
 				    	}
1403 1403
 
1404
-						foreach( $answers_sorted as $id => $answer ) {
1404
+						foreach ($answers_sorted as $id => $answer) {
1405 1405
 				    		$html .= $answer;
1406 1406
 				    	}
1407 1407
 
1408
-				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />';
1409
-				    	$html .= '<span class="hidden right_answer_count">' . $total_right . '</span>';
1410
-				    	$html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>';
1408
+				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="'.$answer_order_string.'" />';
1409
+				    	$html .= '<span class="hidden right_answer_count">'.$total_right.'</span>';
1410
+				    	$html .= '<span class="hidden wrong_answer_count">'.$total_wrong.'</span>';
1411 1411
 
1412 1412
 				    	$html .= '<div class="add_answer_options">';
1413
-					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>';
1414
-					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>';
1413
+					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add right answer', 'woothemes-sensei').'</a>';
1414
+					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add wrong answer', 'woothemes-sensei').'</a>';
1415 1415
 				    	$html .= '</div>';
1416 1416
 
1417
-                        $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' );
1417
+                        $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'multiple-choice');
1418 1418
 
1419 1419
 			    	$html .= '</div>';
1420 1420
 				break;
1421 1421
 				case 'boolean':
1422
-					$html .= '<div class="question_boolean_fields ' . $question_class . '">';
1423
-						if( $question_id ) {
1424
-							$field_name = 'question_' . $question_id . '_right_answer_boolean';
1422
+					$html .= '<div class="question_boolean_fields '.$question_class.'">';
1423
+						if ($question_id) {
1424
+							$field_name = 'question_'.$question_id.'_right_answer_boolean';
1425 1425
 						} else {
1426 1426
 							$field_name = 'question_right_answer_boolean';
1427 1427
 							$right_answer = 'true';
1428 1428
 						}
1429
-						$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>';
1430
-						$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>';
1429
+						$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>';
1430
+						$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>';
1431 1431
 
1432
-                    $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' );
1432
+                    $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'boolean');
1433 1433
 
1434 1434
 					$html .= '</div>';
1435 1435
 				break;
1436 1436
 				case 'gap-fill':
1437
-					$gapfill_array = explode( '||', $right_answer );
1438
-					if ( isset( $gapfill_array[0] ) ) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; }
1439
-					if ( isset( $gapfill_array[1] ) ) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; }
1440
-					if ( isset( $gapfill_array[2] ) ) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; }
1441
-					$html .= '<div class="question_gapfill_fields ' . $question_class . '">';
1437
+					$gapfill_array = explode('||', $right_answer);
1438
+					if (isset($gapfill_array[0])) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; }
1439
+					if (isset($gapfill_array[1])) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; }
1440
+					if (isset($gapfill_array[2])) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; }
1441
+					$html .= '<div class="question_gapfill_fields '.$question_class.'">';
1442 1442
 						// Fill in the Gaps
1443
-						$html .= '<label>' . __( 'Text before the Gap:' , 'woothemes-sensei' ) . '</label> ';
1444
-						$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" />';
1445
-	  					$html .= '<label>' . __( 'The Gap:' , 'woothemes-sensei' ) . '</label> ';
1446
-	  					$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" />';
1447
-	  					$html .= '<label>' . __( 'Text after the Gap:' , 'woothemes-sensei' ) . '</label> ';
1448
-	  					$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" />';
1449
-	  					$html .= '<label>' . __( 'Preview:' , 'woothemes-sensei' ) . '</label> ';
1450
-	  					$html .= '<p class="gapfill-preview">' . $gapfill_pre . '&nbsp;<u>' . $gapfill_gap . '</u>&nbsp;' . $gapfill_post . '</p>';
1443
+						$html .= '<label>'.__('Text before the Gap:', 'woothemes-sensei').'</label> ';
1444
+						$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" />';
1445
+	  					$html .= '<label>'.__('The Gap:', 'woothemes-sensei').'</label> ';
1446
+	  					$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" />';
1447
+	  					$html .= '<label>'.__('Text after the Gap:', 'woothemes-sensei').'</label> ';
1448
+	  					$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" />';
1449
+	  					$html .= '<label>'.__('Preview:', 'woothemes-sensei').'</label> ';
1450
+	  					$html .= '<p class="gapfill-preview">'.$gapfill_pre.'&nbsp;<u>'.$gapfill_gap.'</u>&nbsp;'.$gapfill_post.'</p>';
1451 1451
 	  				$html .= '</div>';
1452 1452
 				break;
1453 1453
 				case 'multi-line':
1454
-					$html .= '<div class="question_multiline_fields ' . $question_class . '">';
1454
+					$html .= '<div class="question_multiline_fields '.$question_class.'">';
1455 1455
 						// Guides for grading
1456
-						if( $question_counter ) {
1457
-							$field_id = 'question_' . $question_counter . '_add_question_right_answer_multiline';
1456
+						if ($question_counter) {
1457
+							$field_id = 'question_'.$question_counter.'_add_question_right_answer_multiline';
1458 1458
 						} else {
1459 1459
 							$field_id = 'add_question_right_answer_multiline';
1460 1460
 						}
1461
-						$html .= '<label>' . __( 'Guide/Teacher Notes for grading the answer' , 'woothemes-sensei' ) . '</label> ';
1462
-						$html .= '<textarea id="' . $field_id . '" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>';
1461
+						$html .= '<label>'.__('Guide/Teacher Notes for grading the answer', 'woothemes-sensei').'</label> ';
1462
+						$html .= '<textarea id="'.$field_id.'" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>';
1463 1463
 					$html .= '</div>';
1464 1464
 				break;
1465 1465
 				case 'single-line':
1466
-					$html .= '<div class="question_singleline_fields ' . $question_class . '">';
1466
+					$html .= '<div class="question_singleline_fields '.$question_class.'">';
1467 1467
 						// Recommended Answer
1468
-						if( $question_counter ) {
1469
-							$field_id = 'question_' . $question_counter . '_add_question_right_answer_singleline';
1468
+						if ($question_counter) {
1469
+							$field_id = 'question_'.$question_counter.'_add_question_right_answer_singleline';
1470 1470
 						} else {
1471 1471
 							$field_id = 'add_question_right_answer_singleline';
1472 1472
 						}
1473
-						$html .= '<label>' . __( 'Recommended Answer' , 'woothemes-sensei' ) . '</label> ';
1474
-						$html .= '<input type="text" id="' . $field_id . '" name="add_question_right_answer_singleline" value="' . $right_answer . '" size="25" class="widefat" />';
1473
+						$html .= '<label>'.__('Recommended Answer', 'woothemes-sensei').'</label> ';
1474
+						$html .= '<input type="text" id="'.$field_id.'" name="add_question_right_answer_singleline" value="'.$right_answer.'" size="25" class="widefat" />';
1475 1475
 					$html .= '</div>';
1476 1476
 				break;
1477 1477
 				case 'file-upload':
1478
-					$html .= '<div class="question_fileupload_fields ' . $question_class . '">';
1479
-						if( $question_counter ) {
1480
-							$right_field_id = 'question_' . $question_counter . '_add_question_right_answer_fileupload';
1481
-							$wrong_field_id = 'question_' . $question_counter . '_add_question_wrong_answer_fileupload';
1478
+					$html .= '<div class="question_fileupload_fields '.$question_class.'">';
1479
+						if ($question_counter) {
1480
+							$right_field_id = 'question_'.$question_counter.'_add_question_right_answer_fileupload';
1481
+							$wrong_field_id = 'question_'.$question_counter.'_add_question_wrong_answer_fileupload';
1482 1482
 						} else {
1483 1483
 							$right_field_id = 'add_question_right_answer_fileupload';
1484 1484
 							$wrong_field_id = 'add_question_wrong_answer_fileupload';
1485 1485
 						}
1486 1486
 
1487 1487
 						$wrong_answer = '';
1488
-						if( isset( $wrong_answers[0] ) ) {
1488
+						if (isset($wrong_answers[0])) {
1489 1489
 							$wrong_answer = $wrong_answers[0];
1490 1490
 						}
1491
-						$html .= '<label>' . __( 'Description for student explaining what needs to be uploaded' , 'woothemes-sensei' ) . '</label> ';
1492
-						$html .= '<textarea id="' . $wrong_field_id . '" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">' . $wrong_answer . '</textarea>';
1491
+						$html .= '<label>'.__('Description for student explaining what needs to be uploaded', 'woothemes-sensei').'</label> ';
1492
+						$html .= '<textarea id="'.$wrong_field_id.'" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">'.$wrong_answer.'</textarea>';
1493 1493
 
1494 1494
 						// Guides for grading
1495
-						$html .= '<label>' . __( 'Guide/Teacher Notes for grading the upload' , 'woothemes-sensei' ) . '</label> ';
1496
-						$html .= '<textarea id="' . $right_field_id . '" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>';
1495
+						$html .= '<label>'.__('Guide/Teacher Notes for grading the upload', 'woothemes-sensei').'</label> ';
1496
+						$html .= '<textarea id="'.$right_field_id.'" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>';
1497 1497
 					$html .= '</div>';
1498 1498
 				break;
1499 1499
 			}
@@ -1502,32 +1502,32 @@  discard block
 block discarded – undo
1502 1502
 		return $html;
1503 1503
 	}
1504 1504
 
1505
-	public function quiz_panel_question_feedback( $question_counter = 0, $question_id = 0, $question_type = '' ) {
1505
+	public function quiz_panel_question_feedback($question_counter = 0, $question_id = 0, $question_type = '') {
1506 1506
 
1507 1507
         // default field name
1508 1508
         $field_name = 'answer_feedback';
1509
-        if( 'boolean' == $question_type ){
1509
+        if ('boolean' == $question_type) {
1510 1510
 
1511 1511
             $field_name = 'answer_feedback_boolean';
1512 1512
 
1513
-        }elseif( 'multiple-choice' == $question_type ){
1513
+        }elseif ('multiple-choice' == $question_type) {
1514 1514
 
1515 1515
             $field_name = 'answer_feedback_multiple_choice';
1516 1516
 
1517 1517
         }// end if
1518 1518
 
1519
-		if( $question_counter ) {
1520
-			$field_name = 'answer_' . $question_counter . '_feedback';
1519
+		if ($question_counter) {
1520
+			$field_name = 'answer_'.$question_counter.'_feedback';
1521 1521
 		}
1522 1522
 
1523 1523
 		$feedback = '';
1524
-		if( $question_id ) {
1525
-			$feedback = get_post_meta( $question_id, '_answer_feedback', true );
1524
+		if ($question_id) {
1525
+			$feedback = get_post_meta($question_id, '_answer_feedback', true);
1526 1526
 		}
1527 1527
 
1528
-		$html = '<p title="' . __( 'This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei' ) . '">';
1529
-		$html .= '<label for="' . $field_name . '">' . __( 'Answer Feedback' , 'woothemes-sensei' ) . ':</label>';
1530
-		$html .= '<textarea id="' . $field_name . '" name="' . $field_name . '" rows="4" cols="40" class="answer_feedback widefat">' . $feedback . '</textarea>';
1528
+		$html = '<p title="'.__('This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei').'">';
1529
+		$html .= '<label for="'.$field_name.'">'.__('Answer Feedback', 'woothemes-sensei').':</label>';
1530
+		$html .= '<textarea id="'.$field_name.'" name="'.$field_name.'" rows="4" cols="40" class="answer_feedback widefat">'.$feedback.'</textarea>';
1531 1531
 		$html .= '</p>';
1532 1532
 
1533 1533
 		return $html;
@@ -1536,19 +1536,19 @@  discard block
 block discarded – undo
1536 1536
 	public function question_get_answer_id() {
1537 1537
 		$data = $_POST['data'];
1538 1538
 		$answer_data = array();
1539
-		parse_str( $data, $answer_data );
1539
+		parse_str($data, $answer_data);
1540 1540
 		$answer = $answer_data['answer_value'];
1541
-		$answer_id = $this->get_answer_id( $answer );
1541
+		$answer_id = $this->get_answer_id($answer);
1542 1542
 		echo $answer_id;
1543 1543
 		die();
1544 1544
 	}
1545 1545
 
1546
-	public function get_answer_id( $answer = '' ) {
1546
+	public function get_answer_id($answer = '') {
1547 1547
 
1548 1548
 		$answer_id = '';
1549 1549
 
1550
-		if( $answer ) {
1551
-			$answer_id = md5( $answer );
1550
+		if ($answer) {
1551
+			$answer_id = md5($answer);
1552 1552
 		}
1553 1553
 
1554 1554
 		return $answer_id;
@@ -1561,17 +1561,17 @@  discard block
 block discarded – undo
1561 1561
 	 * @access public
1562 1562
 	 * @return void
1563 1563
 	 */
1564
-	public function lesson_quiz_meta_box_content () {
1564
+	public function lesson_quiz_meta_box_content() {
1565 1565
 		global $post;
1566 1566
 
1567 1567
 		// Get quiz panel
1568 1568
 		$quiz_id = 0;
1569 1569
 		$quizzes = array();
1570
-		if ( 0 < $post->ID ) {
1571
-			$quiz_id = $this->lesson_quizzes( $post->ID, 'any' );
1570
+		if (0 < $post->ID) {
1571
+			$quiz_id = $this->lesson_quizzes($post->ID, 'any');
1572 1572
 		}
1573 1573
 
1574
-		echo $this->quiz_panel( $quiz_id );
1574
+		echo $this->quiz_panel($quiz_id);
1575 1575
 
1576 1576
 	} // End lesson_quiz_meta_box_content()
1577 1577
 
@@ -1588,53 +1588,53 @@  discard block
 block discarded – undo
1588 1588
 		$quiz_id = 0;
1589 1589
 		$lesson_id = $post->ID;
1590 1590
 		$quizzes = array();
1591
-		if ( 0 < $lesson_id ) {
1592
-			$quiz_id = $this->lesson_quizzes( $lesson_id, 'any' );
1591
+		if (0 < $lesson_id) {
1592
+			$quiz_id = $this->lesson_quizzes($lesson_id, 'any');
1593 1593
 		}
1594 1594
 
1595
-		if( $quiz_id ) {
1596
-			$html .= $this->quiz_settings_panel( $lesson_id, $quiz_id );
1595
+		if ($quiz_id) {
1596
+			$html .= $this->quiz_settings_panel($lesson_id, $quiz_id);
1597 1597
 		} else {
1598
-			$html .= '<p><em>' . __( 'There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei' ) . '</em></p>';
1598
+			$html .= '<p><em>'.__('There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei').'</em></p>';
1599 1599
 		}
1600 1600
 
1601 1601
 		echo $html;
1602 1602
 	}
1603 1603
 
1604
-	public function quiz_settings_panel( $lesson_id = 0, $quiz_id = 0 ) {
1604
+	public function quiz_settings_panel($lesson_id = 0, $quiz_id = 0) {
1605 1605
 
1606 1606
 
1607 1607
 		$html = '';
1608 1608
 
1609
-		if( ! $lesson_id && ! $quiz_id ) return $html;
1609
+		if ( ! $lesson_id && ! $quiz_id) return $html;
1610 1610
 
1611
-		$settings = $this->get_quiz_settings( $quiz_id );
1611
+		$settings = $this->get_quiz_settings($quiz_id);
1612 1612
 
1613
-		$html = Sensei()->admin->render_settings( $settings, $quiz_id, 'quiz-settings' );
1613
+		$html = Sensei()->admin->render_settings($settings, $quiz_id, 'quiz-settings');
1614 1614
 
1615 1615
 		return $html;
1616 1616
 
1617 1617
 	}
1618 1618
 
1619
-	public function get_quiz_settings( $quiz_id = 0 ) {
1619
+	public function get_quiz_settings($quiz_id = 0) {
1620 1620
 
1621 1621
 		$disable_passmark = '';
1622
-		$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
1623
-		if( ! $pass_required ) {
1622
+		$pass_required = get_post_meta($quiz_id, '_pass_required', true);
1623
+		if ( ! $pass_required) {
1624 1624
 			$disable_passmark = 'hidden';
1625 1625
 		}
1626 1626
 
1627 1627
 		// Setup Questions Query
1628 1628
 		$questions = array();
1629
-		if ( 0 < $quiz_id ) {
1630
-			$questions = $this->lesson_quiz_questions( $quiz_id );
1629
+		if (0 < $quiz_id) {
1630
+			$questions = $this->lesson_quiz_questions($quiz_id);
1631 1631
 		}
1632 1632
 
1633 1633
 		// Count questions
1634 1634
 		$question_count = 0;
1635
-		foreach( $questions as $question ) {
1636
-			if( $question->post_type == 'multiple_question' ) {
1637
-				$question_number = get_post_meta( $question->ID, 'number', true );
1635
+		foreach ($questions as $question) {
1636
+			if ($question->post_type == 'multiple_question') {
1637
+				$question_number = get_post_meta($question->ID, 'number', true);
1638 1638
 				$question_count += $question_number;
1639 1639
 			} else {
1640 1640
 				++$question_count;
@@ -1644,15 +1644,15 @@  discard block
 block discarded – undo
1644 1644
 		$settings = array(
1645 1645
 			array(
1646 1646
 				'id' 			=> 'pass_required',
1647
-				'label'			=> __( 'Pass required to complete lesson', 'woothemes-sensei' ),
1648
-				'description'	=> __( 'The passmark must be achieved before the lesson is complete.', 'woothemes-sensei' ),
1647
+				'label'			=> __('Pass required to complete lesson', 'woothemes-sensei'),
1648
+				'description'	=> __('The passmark must be achieved before the lesson is complete.', 'woothemes-sensei'),
1649 1649
 				'type'			=> 'checkbox',
1650 1650
 				'default'		=> '',
1651 1651
 				'checked'		=> 'on',
1652 1652
 			),
1653 1653
 			array(
1654 1654
 				'id' 			=> 'quiz_passmark',
1655
-				'label'			=> __( 'Quiz passmark percentage', 'woothemes-sensei' ),
1655
+				'label'			=> __('Quiz passmark percentage', 'woothemes-sensei'),
1656 1656
 				'description'	=> '',
1657 1657
 				'type'			=> 'number',
1658 1658
 				'default'		=> 0,
@@ -1663,17 +1663,17 @@  discard block
 block discarded – undo
1663 1663
 			),
1664 1664
 			array(
1665 1665
 				'id' 			=> 'show_questions',
1666
-				'label'			=> __( 'Number of questions to show', 'woothemes-sensei' ),
1667
-				'description'	=> __( 'Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei' ),
1666
+				'label'			=> __('Number of questions to show', 'woothemes-sensei'),
1667
+				'description'	=> __('Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei'),
1668 1668
 				'type'			=> 'number',
1669 1669
 				'default'		=> '',
1670
-				'placeholder'	=> __( 'All', 'woothemes-sensei' ),
1670
+				'placeholder'	=> __('All', 'woothemes-sensei'),
1671 1671
 				'min'			=> 1,
1672 1672
 				'max'			=> $question_count,
1673 1673
 			),
1674 1674
 			array(
1675 1675
 				'id' 			=> 'random_question_order',
1676
-				'label'			=> __( 'Randomise question order', 'woothemes-sensei' ),
1676
+				'label'			=> __('Randomise question order', 'woothemes-sensei'),
1677 1677
 				'description'	=> '',
1678 1678
 				'type'			=> 'checkbox',
1679 1679
 				'default'		=> 'no',
@@ -1681,23 +1681,23 @@  discard block
 block discarded – undo
1681 1681
 			),
1682 1682
 			array(
1683 1683
 				'id' 			=> 'quiz_grade_type',
1684
-				'label'			=> __( 'Grade quiz automatically', 'woothemes-sensei' ),
1685
-				'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' ),
1684
+				'label'			=> __('Grade quiz automatically', 'woothemes-sensei'),
1685
+				'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'),
1686 1686
 				'type'			=> 'checkbox',
1687 1687
 				'default'		=> 'auto',
1688 1688
 				'checked'		=> 'auto',
1689 1689
 			),
1690 1690
 			array(
1691 1691
 				'id' 			=> 'enable_quiz_reset',
1692
-				'label'			=> __( 'Allow user to retake the quiz', 'woothemes-sensei' ),
1693
-				'description'	=> __( 'Enables the quiz reset button.', 'woothemes-sensei' ),
1692
+				'label'			=> __('Allow user to retake the quiz', 'woothemes-sensei'),
1693
+				'description'	=> __('Enables the quiz reset button.', 'woothemes-sensei'),
1694 1694
 				'type'			=> 'checkbox',
1695 1695
 				'default'		=> '',
1696 1696
 				'checked'		=> 'on',
1697 1697
 			),
1698 1698
 		);
1699 1699
 
1700
-		return apply_filters( 'sensei_quiz_settings', $settings );
1700
+		return apply_filters('sensei_quiz_settings', $settings);
1701 1701
 	}
1702 1702
 
1703 1703
 	/**
@@ -1706,38 +1706,38 @@  discard block
 block discarded – undo
1706 1706
 	 * @access public
1707 1707
 	 * @return void
1708 1708
 	 */
1709
-	public function enqueue_scripts( $hook ) {
1709
+	public function enqueue_scripts($hook) {
1710 1710
 		global  $post_type;
1711 1711
 
1712
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) );
1713
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
1714
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order' ) );
1712
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question'));
1713
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
1714
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order'));
1715 1715
 
1716 1716
 		// Test for Write Panel Pages
1717
-		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
1717
+		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))) {
1718 1718
 
1719
-			$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
1719
+			$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
1720 1720
 
1721 1721
 			// Load the lessons script
1722 1722
             wp_enqueue_media();
1723
-			wp_enqueue_script( 'sensei-lesson-metadata', Sensei()->plugin_url . 'assets/js/lesson-metadata' . $suffix . '.js', array( 'jquery', 'select2' ,'jquery-ui-sortable' ), Sensei()->version, true );
1724
-			wp_enqueue_script( 'sensei-lesson-chosen', Sensei()->plugin_url . 'assets/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1725
-			wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'sensei-lesson-chosen' ), Sensei()->version, true );
1723
+			wp_enqueue_script('sensei-lesson-metadata', Sensei()->plugin_url.'assets/js/lesson-metadata'.$suffix.'.js', array('jquery', 'select2', 'jquery-ui-sortable'), Sensei()->version, true);
1724
+			wp_enqueue_script('sensei-lesson-chosen', Sensei()->plugin_url.'assets/chosen/chosen.jquery'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1725
+			wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery'.$suffix.'.js', array('jquery', 'sensei-lesson-chosen'), Sensei()->version, true);
1726 1726
 
1727 1727
             // Load the bulk edit screen script
1728
-            if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) {
1729
-                wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true);
1728
+            if ('edit.php' == $hook && 'lesson' == $_GET['post_type']) {
1729
+                wp_enqueue_script('sensei-lessons-bulk-edit', Sensei()->plugin_url.'assets/js/admin/lesson-bulk-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1730 1730
             }
1731 1731
 
1732 1732
 			// Localise script
1733
-			$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' ) );
1734
-			$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' ) );
1735
-			$data = array_merge( $translation_strings, $ajax_vars );
1736
-			wp_localize_script( 'sensei-lesson-metadata', 'woo_localized_data', $data );
1733
+			$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'));
1734
+			$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'));
1735
+			$data = array_merge($translation_strings, $ajax_vars);
1736
+			wp_localize_script('sensei-lesson-metadata', 'woo_localized_data', $data);
1737 1737
 
1738 1738
 			// Chosen RTL
1739
-			if ( is_rtl() ) {
1740
-				wp_enqueue_script( 'sensei-chosen-rtl', Sensei()->plugin_url . 'assets/chosen/chosen-rtl' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1739
+			if (is_rtl()) {
1740
+				wp_enqueue_script('sensei-chosen-rtl', Sensei()->plugin_url.'assets/chosen/chosen-rtl'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1741 1741
 			}
1742 1742
 
1743 1743
 		}
@@ -1751,16 +1751,16 @@  discard block
 block discarded – undo
1751 1751
 	 * @since  1.4.0
1752 1752
 	 * @return void
1753 1753
 	 */
1754
-	public function enqueue_styles ( $hook ) {
1754
+	public function enqueue_styles($hook) {
1755 1755
 		global  $post_type;
1756 1756
 
1757
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question', 'sensei_message' ) );
1758
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
1759
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings' ) );
1757
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question', 'sensei_message'));
1758
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
1759
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings'));
1760 1760
 
1761 1761
 		// Test for Write Panel Pages
1762
-		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 ) ) ) {
1763
-			wp_enqueue_style( 'woothemes-sensei-settings-api', esc_url( Sensei()->plugin_url . 'assets/css/settings.css' ), '', Sensei()->version );
1762
+		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))) {
1763
+			wp_enqueue_style('woothemes-sensei-settings-api', esc_url(Sensei()->plugin_url.'assets/css/settings.css'), '', Sensei()->version);
1764 1764
 		}
1765 1765
 
1766 1766
 	} // End enqueue_styles()
@@ -1772,12 +1772,12 @@  discard block
 block discarded – undo
1772 1772
 	 * @param  array $defaults
1773 1773
 	 * @return array $new_columns
1774 1774
 	 */
1775
-	public function add_column_headings ( $defaults ) {
1775
+	public function add_column_headings($defaults) {
1776 1776
 		$new_columns['cb'] = '<input type="checkbox" />';
1777
-		$new_columns['title'] = _x( 'Lesson Title', 'column name', 'woothemes-sensei' );
1778
-		$new_columns['lesson-course'] = _x( 'Course', 'column name', 'woothemes-sensei' );
1779
-		$new_columns['lesson-prerequisite'] = _x( 'Pre-requisite Lesson', 'column name', 'woothemes-sensei' );
1780
-		if ( isset( $defaults['date'] ) ) {
1777
+		$new_columns['title'] = _x('Lesson Title', 'column name', 'woothemes-sensei');
1778
+		$new_columns['lesson-course'] = _x('Course', 'column name', 'woothemes-sensei');
1779
+		$new_columns['lesson-prerequisite'] = _x('Pre-requisite Lesson', 'column name', 'woothemes-sensei');
1780
+		if (isset($defaults['date'])) {
1781 1781
 			$new_columns['date'] = $defaults['date'];
1782 1782
 		}
1783 1783
 		return $new_columns;
@@ -1791,23 +1791,23 @@  discard block
 block discarded – undo
1791 1791
 	 * @param  int $id
1792 1792
 	 * @return void
1793 1793
 	 */
1794
-	public function add_column_data ( $column_name, $id ) {
1794
+	public function add_column_data($column_name, $id) {
1795 1795
 		global $wpdb, $post;
1796 1796
 
1797
-		switch ( $column_name ) {
1797
+		switch ($column_name) {
1798 1798
 			case 'id':
1799 1799
 				echo $id;
1800 1800
 			break;
1801 1801
 			case 'lesson-course':
1802
-				$lesson_course_id = get_post_meta( $id, '_lesson_course', true);
1803
-				if ( 0 < absint( $lesson_course_id ) ) {
1804
-					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>';
1802
+				$lesson_course_id = get_post_meta($id, '_lesson_course', true);
1803
+				if (0 < absint($lesson_course_id)) {
1804
+					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>';
1805 1805
 				} // End If Statement
1806 1806
 			break;
1807 1807
 			case 'lesson-prerequisite':
1808
-				$lesson_prerequisite_id = get_post_meta( $id, '_lesson_prerequisite', true);
1809
-				if ( 0 < absint( $lesson_prerequisite_id ) ) {
1810
-					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>';
1808
+				$lesson_prerequisite_id = get_post_meta($id, '_lesson_prerequisite', true);
1809
+				if (0 < absint($lesson_prerequisite_id)) {
1810
+					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>';
1811 1811
 				} // End If Statement
1812 1812
 			break;
1813 1813
 			default:
@@ -1821,13 +1821,13 @@  discard block
 block discarded – undo
1821 1821
 	 * @access public
1822 1822
 	 * @return void
1823 1823
 	 */
1824
-	public function lesson_add_course () {
1824
+	public function lesson_add_course() {
1825 1825
 		global $current_user;
1826 1826
 		//Add nonce security to the request
1827
-		if ( isset($_POST['lesson_add_course_nonce']) ) {
1828
-			$nonce = esc_html( $_POST['lesson_add_course_nonce'] );
1827
+		if (isset($_POST['lesson_add_course_nonce'])) {
1828
+			$nonce = esc_html($_POST['lesson_add_course_nonce']);
1829 1829
 		} // End If Statement
1830
-		if ( ! wp_verify_nonce( $nonce, 'lesson_add_course_nonce' ) ) {
1830
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_course_nonce')) {
1831 1831
 			die('');
1832 1832
 		} // End If Statement
1833 1833
 		// Parse POST data
@@ -1849,43 +1849,43 @@  discard block
 block discarded – undo
1849 1849
 	 * @access public
1850 1850
 	 * @return void
1851 1851
 	 */
1852
-	public function lesson_update_question () {
1852
+	public function lesson_update_question() {
1853 1853
 		global $current_user;
1854 1854
 		//Add nonce security to the request
1855
-		if ( isset($_POST['lesson_update_question_nonce']) ) {
1856
-			$nonce = esc_html( $_POST['lesson_update_question_nonce'] );
1855
+		if (isset($_POST['lesson_update_question_nonce'])) {
1856
+			$nonce = esc_html($_POST['lesson_update_question_nonce']);
1857 1857
 		} // End If Statement
1858
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_nonce' ) ) {
1858
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_nonce')) {
1859 1859
 			die('');
1860 1860
 		} // End If Statement
1861 1861
 		// Parse POST data
1862 1862
 		// WP slashes all incoming data regardless of Magic Quotes setting (see wp_magic_quotes()), which means that
1863 1863
 		// even the $_POST['data'] encoded with encodeURIComponent has it's apostrophes slashed.
1864 1864
 		// So first restore the original unslashed apostrophes by removing those slashes
1865
-		$data = wp_unslash( $_POST['data'] );
1865
+		$data = wp_unslash($_POST['data']);
1866 1866
 		// Then parse the string to an array (note that parse_str automatically urldecodes all the variables)
1867 1867
 		$question_data = array();
1868 1868
 		parse_str($data, $question_data);
1869 1869
 		// Finally re-slash all elements to ensure consistancy for lesson_save_question()
1870
-		$question_data = wp_slash( $question_data );
1870
+		$question_data = wp_slash($question_data);
1871 1871
 		// Save the question
1872 1872
 		$return = false;
1873 1873
 		// Question Save and Delete logic
1874
-		if ( isset( $question_data['action'] ) && ( $question_data['action'] == 'delete' ) ) {
1874
+		if (isset($question_data['action']) && ($question_data['action'] == 'delete')) {
1875 1875
 			// Delete the Question
1876 1876
 			$return = $this->lesson_delete_question($question_data);
1877 1877
 		} else {
1878 1878
 			// Save the Question
1879
-			if ( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) {
1879
+			if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) {
1880 1880
 				$current_user = wp_get_current_user();
1881 1881
 				$question_data['post_author'] = $current_user->ID;
1882
-				$question_id = $this->lesson_save_question( $question_data );
1883
-				$question_type = Sensei()->question->get_question_type( $question_id );
1882
+				$question_id = $this->lesson_save_question($question_data);
1883
+				$question_type = Sensei()->question->get_question_type($question_id);
1884 1884
 
1885
-				$question_count = intval( $question_data['question_count'] );
1885
+				$question_count = intval($question_data['question_count']);
1886 1886
 				++$question_count;
1887 1887
 
1888
-				$return = $this->quiz_panel_question( $question_type, $question_count, $question_id );
1888
+				$return = $this->quiz_panel_question($question_type, $question_count, $question_id);
1889 1889
 			} // End If Statement
1890 1890
 		} // End If Statement
1891 1891
 
@@ -1900,48 +1900,48 @@  discard block
 block discarded – undo
1900 1900
 
1901 1901
 		//Add nonce security to the request
1902 1902
 		$nonce = '';
1903
-		if( isset( $_POST['lesson_add_multiple_questions_nonce'] ) ) {
1904
-			$nonce = esc_html( $_POST['lesson_add_multiple_questions_nonce'] );
1903
+		if (isset($_POST['lesson_add_multiple_questions_nonce'])) {
1904
+			$nonce = esc_html($_POST['lesson_add_multiple_questions_nonce']);
1905 1905
 		} // End If Statement
1906 1906
 
1907
-		if( ! wp_verify_nonce( $nonce, 'lesson_add_multiple_questions_nonce' ) ) {
1908
-			die( $return );
1907
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_multiple_questions_nonce')) {
1908
+			die($return);
1909 1909
 		} // End If Statement
1910 1910
 
1911 1911
 		// Parse POST data
1912 1912
 		$data = $_POST['data'];
1913 1913
 		$question_data = array();
1914
-		parse_str( $data, $question_data );
1914
+		parse_str($data, $question_data);
1915 1915
 
1916
-		if( is_array( $question_data ) ) {
1917
-			if( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) {
1916
+		if (is_array($question_data)) {
1917
+			if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) {
1918 1918
 
1919
-				$quiz_id = intval( $question_data['quiz_id'] );
1920
-				$question_number = intval( $question_data['question_number'] );
1921
-				$question_category = intval( $question_data['question_category'] );
1919
+				$quiz_id = intval($question_data['quiz_id']);
1920
+				$question_number = intval($question_data['question_number']);
1921
+				$question_category = intval($question_data['question_category']);
1922 1922
 
1923
-				$question_counter = intval( $question_data['question_count'] );
1923
+				$question_counter = intval($question_data['question_count']);
1924 1924
 				++$question_counter;
1925 1925
 
1926
-				$cat = get_term( $question_category, 'question-category' );
1926
+				$cat = get_term($question_category, 'question-category');
1927 1927
 
1928 1928
 				$post_data = array(
1929 1929
 					'post_content' => '',
1930 1930
 					'post_status' => 'publish',
1931
-					'post_title' => sprintf( __( '%1$s Question(s) from %2$s', 'woothemes-sensei' ), $question_number, $cat->name ),
1931
+					'post_title' => sprintf(__('%1$s Question(s) from %2$s', 'woothemes-sensei'), $question_number, $cat->name),
1932 1932
 					'post_type' => 'multiple_question'
1933 1933
 				);
1934 1934
 
1935
-				$multiple_id = wp_insert_post( $post_data );
1935
+				$multiple_id = wp_insert_post($post_data);
1936 1936
 
1937
-				if( $multiple_id && ! is_wp_error( $multiple_id ) ) {
1938
-					add_post_meta( $multiple_id, 'category', $question_category );
1939
-					add_post_meta( $multiple_id, 'number', $question_number );
1940
-					add_post_meta( $multiple_id, '_quiz_id', $quiz_id, false );
1941
-					add_post_meta( $multiple_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_counter );
1942
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
1943
-					update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
1944
-					$return = $this->quiz_panel_question( 'category', $question_counter, $multiple_id, 'quiz', array( $cat->name, $question_number ) );
1937
+				if ($multiple_id && ! is_wp_error($multiple_id)) {
1938
+					add_post_meta($multiple_id, 'category', $question_category);
1939
+					add_post_meta($multiple_id, 'number', $question_number);
1940
+					add_post_meta($multiple_id, '_quiz_id', $quiz_id, false);
1941
+					add_post_meta($multiple_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_counter);
1942
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
1943
+					update_post_meta($lesson_id, '_quiz_has_questions', '1');
1944
+					$return = $this->quiz_panel_question('category', $question_counter, $multiple_id, 'quiz', array($cat->name, $question_number));
1945 1945
 				}
1946 1946
 			}
1947 1947
 		}
@@ -1955,24 +1955,24 @@  discard block
 block discarded – undo
1955 1955
 
1956 1956
 		//Add nonce security to the request
1957 1957
 		$nonce = '';
1958
-		if( isset( $_POST['lesson_remove_multiple_questions_nonce'] ) ) {
1959
-			$nonce = esc_html( $_POST['lesson_remove_multiple_questions_nonce'] );
1958
+		if (isset($_POST['lesson_remove_multiple_questions_nonce'])) {
1959
+			$nonce = esc_html($_POST['lesson_remove_multiple_questions_nonce']);
1960 1960
 		} // End If Statement
1961 1961
 
1962
-		if( ! wp_verify_nonce( $nonce, 'lesson_remove_multiple_questions_nonce' ) ) {
1962
+		if ( ! wp_verify_nonce($nonce, 'lesson_remove_multiple_questions_nonce')) {
1963 1963
 			die('');
1964 1964
 		} // End If Statement
1965 1965
 
1966 1966
 		// Parse POST data
1967 1967
 		$data = $_POST['data'];
1968 1968
 		$question_data = array();
1969
-		parse_str( $data, $question_data );
1969
+		parse_str($data, $question_data);
1970 1970
 
1971
-		if( is_array( $question_data ) ) {
1972
-			wp_delete_post( $question_data['question_id'], true );
1971
+		if (is_array($question_data)) {
1972
+			wp_delete_post($question_data['question_id'], true);
1973 1973
 		}
1974 1974
 
1975
-		die( 'Deleted' );
1975
+		die('Deleted');
1976 1976
 	}
1977 1977
 
1978 1978
 	public function get_question_category_limit() {
@@ -1983,11 +1983,11 @@  discard block
 block discarded – undo
1983 1983
 		// Parse POST data
1984 1984
 		$data = $_POST['data'];
1985 1985
 		$cat_data = array();
1986
-		parse_str( $data, $cat_data );
1986
+		parse_str($data, $cat_data);
1987 1987
 
1988
-		if( isset( $cat_data['cat'] ) && '' != $cat_data['cat'] ) {
1989
-			$cat = get_term( $cat_data['cat'], 'question-category' );
1990
-			if( isset( $cat->count ) ) {
1988
+		if (isset($cat_data['cat']) && '' != $cat_data['cat']) {
1989
+			$cat = get_term($cat_data['cat'], 'question-category');
1990
+			if (isset($cat->count)) {
1991 1991
 				$return = $cat->count;
1992 1992
 			}
1993 1993
 		}
@@ -2001,44 +2001,44 @@  discard block
 block discarded – undo
2001 2001
 
2002 2002
 		//Add nonce security to the request
2003 2003
 		$nonce = '';
2004
-		if( isset( $_POST['lesson_add_existing_questions_nonce'] ) ) {
2005
-			$nonce = esc_html( $_POST['lesson_add_existing_questions_nonce'] );
2004
+		if (isset($_POST['lesson_add_existing_questions_nonce'])) {
2005
+			$nonce = esc_html($_POST['lesson_add_existing_questions_nonce']);
2006 2006
 		} // End If Statement
2007 2007
 
2008
-		if( ! wp_verify_nonce( $nonce, 'lesson_add_existing_questions_nonce' ) ) {
2008
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_existing_questions_nonce')) {
2009 2009
 			die('');
2010 2010
 		} // End If Statement
2011 2011
 
2012 2012
 		// Parse POST data
2013 2013
 		$data = $_POST['data'];
2014 2014
 		$question_data = array();
2015
-		parse_str( $data, $question_data );
2015
+		parse_str($data, $question_data);
2016 2016
 
2017 2017
 		$return = '';
2018 2018
 
2019
-		if( is_array( $question_data ) ) {
2019
+		if (is_array($question_data)) {
2020 2020
 
2021
-			if( isset( $question_data['questions'] ) && '' != $question_data['questions'] ) {
2021
+			if (isset($question_data['questions']) && '' != $question_data['questions']) {
2022 2022
 
2023
-				$questions = explode( ',', trim( $question_data['questions'], ',' ) );
2023
+				$questions = explode(',', trim($question_data['questions'], ','));
2024 2024
 				$quiz_id = $question_data['quiz_id'];
2025
-				$question_count = intval( $question_data['question_count'] );
2025
+				$question_count = intval($question_data['question_count']);
2026 2026
 
2027
-				foreach( $questions as $question_id ) {
2027
+				foreach ($questions as $question_id) {
2028 2028
 
2029 2029
 					++$question_count;
2030 2030
 
2031
-					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2032
-					if( ! in_array( $quiz_id, $quizzes ) ) {
2033
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2034
-						$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2035
-						update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2031
+					$quizzes = get_post_meta($question_id, '_quiz_id', false);
2032
+					if ( ! in_array($quiz_id, $quizzes)) {
2033
+			    		add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2034
+						$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
2035
+						update_post_meta($lesson_id, '_quiz_has_questions', '1');
2036 2036
 			    	}
2037 2037
 
2038
-			    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2039
-					$question_type = Sensei()->question->get_question_type( $question_id );
2038
+			    	add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count);
2039
+					$question_type = Sensei()->question->get_question_type($question_id);
2040 2040
 
2041
-					$return .= $this->quiz_panel_question( $question_type, $question_count, $question_id );
2041
+					$return .= $this->quiz_panel_question($question_type, $question_count, $question_id);
2042 2042
 				}
2043 2043
 			}
2044 2044
 		}
@@ -2050,57 +2050,57 @@  discard block
 block discarded – undo
2050 2050
 
2051 2051
 	public function lesson_update_grade_type() {
2052 2052
 		//Add nonce security to the request
2053
-		if ( isset($_POST['lesson_update_grade_type_nonce']) ) {
2054
-			$nonce = esc_html( $_POST['lesson_update_grade_type_nonce'] );
2053
+		if (isset($_POST['lesson_update_grade_type_nonce'])) {
2054
+			$nonce = esc_html($_POST['lesson_update_grade_type_nonce']);
2055 2055
 		} // End If Statement
2056
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_grade_type_nonce' ) ) {
2056
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_grade_type_nonce')) {
2057 2057
 			die('');
2058 2058
 		} // End If Statement
2059 2059
 		// Parse POST data
2060 2060
 		$data = $_POST['data'];
2061 2061
 		$quiz_data = array();
2062 2062
 		parse_str($data, $quiz_data);
2063
-		update_post_meta( $quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type'] );
2063
+		update_post_meta($quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type']);
2064 2064
 		die();
2065 2065
 	}
2066 2066
 
2067 2067
 	public function lesson_update_question_order() {
2068 2068
 		// Add nonce security to the request
2069
-		if ( isset($_POST['lesson_update_question_order_nonce']) ) {
2070
-			$nonce = esc_html( $_POST['lesson_update_question_order_nonce'] );
2069
+		if (isset($_POST['lesson_update_question_order_nonce'])) {
2070
+			$nonce = esc_html($_POST['lesson_update_question_order_nonce']);
2071 2071
 		} // End If Statement
2072
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_nonce' ) ) {
2072
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_nonce')) {
2073 2073
 			die('');
2074 2074
 		} // End If Statement
2075 2075
 		// Parse POST data
2076 2076
 		$data = $_POST['data'];
2077 2077
 		$quiz_data = array();
2078 2078
 		parse_str($data, $quiz_data);
2079
-		if( strlen( $quiz_data['question_order'] ) > 0 ) {
2080
-			$questions = explode( ',', $quiz_data['question_order'] );
2079
+		if (strlen($quiz_data['question_order']) > 0) {
2080
+			$questions = explode(',', $quiz_data['question_order']);
2081 2081
 			$o = 1;
2082
-			foreach( $questions as $question_id ) {
2083
-				update_post_meta( $question_id, '_quiz_question_order' . $quiz_data['quiz_id'], $quiz_data['quiz_id'] . '000' . $o );
2082
+			foreach ($questions as $question_id) {
2083
+				update_post_meta($question_id, '_quiz_question_order'.$quiz_data['quiz_id'], $quiz_data['quiz_id'].'000'.$o);
2084 2084
 				++$o;
2085 2085
 			}
2086
-			update_post_meta( $quiz_data['quiz_id'], '_question_order', $questions );
2086
+			update_post_meta($quiz_data['quiz_id'], '_question_order', $questions);
2087 2087
 		}
2088 2088
 		die();
2089 2089
 	}
2090 2090
 
2091 2091
 	public function lesson_update_question_order_random() {
2092 2092
 		//Add nonce security to the request
2093
-		if ( isset($_POST['lesson_update_question_order_random_nonce']) ) {
2094
-			$nonce = esc_html( $_POST['lesson_update_question_order_random_nonce'] );
2093
+		if (isset($_POST['lesson_update_question_order_random_nonce'])) {
2094
+			$nonce = esc_html($_POST['lesson_update_question_order_random_nonce']);
2095 2095
 		} // End If Statement
2096
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_random_nonce' ) ) {
2096
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_random_nonce')) {
2097 2097
 			die('');
2098 2098
 		} // End If Statement
2099 2099
 		// Parse POST data
2100 2100
 		$data = $_POST['data'];
2101 2101
 		$quiz_data = array();
2102 2102
 		parse_str($data, $quiz_data);
2103
-		update_post_meta( $quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order'] );
2103
+		update_post_meta($quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order']);
2104 2104
 		die();
2105 2105
 	}
2106 2106
 
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
 	 * @param array $data (default: array())
2112 2112
 	 * @return void
2113 2113
 	 */
2114
-	private function lesson_save_course( $data = array() ) {
2114
+	private function lesson_save_course($data = array()) {
2115 2115
 		global $current_user;
2116 2116
 		$return = false;
2117 2117
 		// Setup the course data
@@ -2120,58 +2120,58 @@  discard block
 block discarded – undo
2120 2120
 		$course_title = '';
2121 2121
 		$course_prerequisite = 0;
2122 2122
 		$course_category = 0;
2123
-		if ( isset( $data[ 'course_id' ] ) && ( 0 < absint( $data[ 'course_id' ] ) ) ) {
2124
-			$course_id = absint( $data[ 'course_id' ] );
2123
+		if (isset($data['course_id']) && (0 < absint($data['course_id']))) {
2124
+			$course_id = absint($data['course_id']);
2125 2125
 		} // End If Statement
2126
-		if ( isset( $data[ 'course_title' ] ) && ( '' != $data[ 'course_title' ] ) ) {
2127
-			$course_title = $data[ 'course_title' ];
2126
+		if (isset($data['course_title']) && ('' != $data['course_title'])) {
2127
+			$course_title = $data['course_title'];
2128 2128
 		} // End If Statement
2129 2129
 		$post_title = $course_title;
2130
-		if ( isset($data[ 'post_author' ]) ) {
2131
-			$post_author = $data[ 'post_author' ];
2130
+		if (isset($data['post_author'])) {
2131
+			$post_author = $data['post_author'];
2132 2132
 		} else {
2133 2133
 			$current_user = wp_get_current_user();
2134 2134
 			$post_author = $current_user->ID;
2135 2135
 		} // End If Statement
2136 2136
 		$post_status = 'publish';
2137 2137
 		$post_type = 'course';
2138
-		if ( isset( $data[ 'course_content' ] ) && ( '' != $data[ 'course_content' ] ) ) {
2139
-			$course_content = $data[ 'course_content' ];
2138
+		if (isset($data['course_content']) && ('' != $data['course_content'])) {
2139
+			$course_content = $data['course_content'];
2140 2140
 		} // End If Statement
2141 2141
 		$post_content = $course_content;
2142 2142
 		// Course Query Arguments
2143
-		$post_type_args = array(	'post_content' => $post_content,
2143
+		$post_type_args = array('post_content' => $post_content,
2144 2144
   		    						'post_status' => $post_status,
2145 2145
   		    						'post_title' => $post_title,
2146 2146
   		    						'post_type' => $post_type
2147 2147
   		    						);
2148 2148
   		// Only save if there is a valid title
2149
-  		if ( $post_title != '' ) {
2149
+  		if ($post_title != '') {
2150 2150
   		    // Check for prerequisite courses & product id
2151
-  		    $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2152
-  		    $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2153
-  		    $course_category_id = absint( $data[ 'course_category' ] );
2154
-  		    if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2151
+  		    $course_prerequisite_id = absint($data['course_prerequisite']);
2152
+  		    $course_woocommerce_product_id = absint($data['course_woocommerce_product']);
2153
+  		    $course_category_id = absint($data['course_category']);
2154
+  		    if (0 == $course_woocommerce_product_id) { $course_woocommerce_product_id = '-'; }
2155 2155
   		    // Insert or Update the Lesson Quiz
2156
-		    if ( 0 < $course_id ) {
2157
-		    	$post_type_args[ 'ID' ] = $course_id;
2156
+		    if (0 < $course_id) {
2157
+		    	$post_type_args['ID'] = $course_id;
2158 2158
 		    	$course_id = wp_update_post($post_type_args);
2159
-		    	update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2160
-		    	update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2161
-		    	if ( 0 < $course_category_id ) {
2162
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2159
+		    	update_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id);
2160
+		    	update_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id);
2161
+		    	if (0 < $course_category_id) {
2162
+		    		wp_set_object_terms($course_id, $course_category_id, 'course-category');
2163 2163
 		    	} // End If Statement
2164 2164
 		    } else {
2165 2165
 		    	$course_id = wp_insert_post($post_type_args);
2166
-		    	add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2167
-		    	add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2168
-		    	if ( 0 < $course_category_id ) {
2169
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2166
+		    	add_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id);
2167
+		    	add_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id);
2168
+		    	if (0 < $course_category_id) {
2169
+		    		wp_set_object_terms($course_id, $course_category_id, 'course-category');
2170 2170
 		    	} // End If Statement
2171 2171
 		    } // End If Statement
2172 2172
 		} // End If Statement
2173 2173
   		// Check that the insert or update saved by testing the post id
2174
-  		if ( 0 < $course_id ) {
2174
+  		if (0 < $course_id) {
2175 2175
   			$return = $course_id;
2176 2176
   		} // End If Statement
2177 2177
   		return $return;
@@ -2185,7 +2185,7 @@  discard block
 block discarded – undo
2185 2185
 	 * @param array $data (default: array())
2186 2186
 	 * @return void
2187 2187
 	 */
2188
-	public function lesson_save_question( $data = array(), $context = 'quiz' ) {
2188
+	public function lesson_save_question($data = array(), $context = 'quiz') {
2189 2189
 		$return = false;
2190 2190
 		// Save the Questions
2191 2191
 		// Setup the Question data
@@ -2197,130 +2197,130 @@  discard block
 block discarded – undo
2197 2197
 		$question_category = '';
2198 2198
 
2199 2199
 		// Handle Question Type
2200
-		if ( isset( $data[ 'question_type' ] ) && ( '' != $data[ 'question_type' ] ) ) {
2201
-			$question_type = $data[ 'question_type' ];
2200
+		if (isset($data['question_type']) && ('' != $data['question_type'])) {
2201
+			$question_type = $data['question_type'];
2202 2202
 		} // End If Statement
2203 2203
 
2204
-		if ( isset( $data[ 'question_category' ] ) && ( '' != $data[ 'question_category' ] ) ) {
2205
-			$question_category = $data[ 'question_category' ];
2204
+		if (isset($data['question_category']) && ('' != $data['question_category'])) {
2205
+			$question_category = $data['question_category'];
2206 2206
 		} // End If Statement
2207 2207
 
2208
-		if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) {
2209
-			$question_id = absint( $data[ 'question_id' ] );
2208
+		if (isset($data['question_id']) && (0 < absint($data['question_id']))) {
2209
+			$question_id = absint($data['question_id']);
2210 2210
 		} // End If Statement
2211
-		if ( isset( $data[ 'question' ] ) && ( '' != $data[ 'question' ] ) ) {
2212
-			$question_text = $data[ 'question' ];
2211
+		if (isset($data['question']) && ('' != $data['question'])) {
2212
+			$question_text = $data['question'];
2213 2213
 		} // End If Statement
2214 2214
 		$post_title = $question_text;
2215 2215
 		// Handle Default Fields (multiple choice)
2216
-		if ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answers' ] ) && ( '' != $data[ 'question_right_answers' ] ) ) {
2217
-			$question_right_answers = $data[ 'question_right_answers' ];
2216
+		if ('multiple-choice' == $question_type && isset($data['question_right_answers']) && ('' != $data['question_right_answers'])) {
2217
+			$question_right_answers = $data['question_right_answers'];
2218 2218
 		} // End If Statement
2219
-		elseif ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answer' ] ) && ( '' != $data[ 'question_right_answer' ] ) ) {
2220
-			$question_right_answer = $data[ 'question_right_answer' ];
2219
+		elseif ('multiple-choice' == $question_type && isset($data['question_right_answer']) && ('' != $data['question_right_answer'])) {
2220
+			$question_right_answer = $data['question_right_answer'];
2221 2221
 		} // End If Statement
2222
-		if ( 'multiple-choice' == $question_type && isset( $data[ 'question_wrong_answers' ] ) && ( '' != $data[ 'question_wrong_answers' ] ) ) {
2223
-			$question_wrong_answers = $data[ 'question_wrong_answers' ];
2222
+		if ('multiple-choice' == $question_type && isset($data['question_wrong_answers']) && ('' != $data['question_wrong_answers'])) {
2223
+			$question_wrong_answers = $data['question_wrong_answers'];
2224 2224
 		} // End If Statement
2225 2225
 		// Handle Boolean Fields - Edit
2226
-		if ( 'boolean' == $question_type && isset( $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) && ( '' != $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) ) {
2227
-			$question_right_answer = $data[ 'question_' . $question_id . '_right_answer_boolean' ];
2226
+		if ('boolean' == $question_type && isset($data['question_'.$question_id.'_right_answer_boolean']) && ('' != $data['question_'.$question_id.'_right_answer_boolean'])) {
2227
+			$question_right_answer = $data['question_'.$question_id.'_right_answer_boolean'];
2228 2228
 		} // End If Statement
2229 2229
 		// Handle Boolean Fields - Add
2230
-		if ( 'boolean' == $question_type && isset( $data[ 'question_right_answer_boolean' ] ) && ( '' != $data[ 'question_right_answer_boolean' ] ) ) {
2231
-			$question_right_answer = $data[ 'question_right_answer_boolean' ];
2230
+		if ('boolean' == $question_type && isset($data['question_right_answer_boolean']) && ('' != $data['question_right_answer_boolean'])) {
2231
+			$question_right_answer = $data['question_right_answer_boolean'];
2232 2232
 		} // End If Statement
2233 2233
 		// Handle Gap Fill Fields
2234
-		if ( 'gap-fill' == $question_type && isset( $data[ 'add_question_right_answer_gapfill_gap' ] ) && '' != $data[ 'add_question_right_answer_gapfill_gap' ] ) {
2235
-			$question_right_answer = $data[ 'add_question_right_answer_gapfill_pre' ] . '||' . $data[ 'add_question_right_answer_gapfill_gap' ] . '||' . $data[ 'add_question_right_answer_gapfill_post' ];
2234
+		if ('gap-fill' == $question_type && isset($data['add_question_right_answer_gapfill_gap']) && '' != $data['add_question_right_answer_gapfill_gap']) {
2235
+			$question_right_answer = $data['add_question_right_answer_gapfill_pre'].'||'.$data['add_question_right_answer_gapfill_gap'].'||'.$data['add_question_right_answer_gapfill_post'];
2236 2236
 		} // End If Statement
2237 2237
 		// Handle Multi Line Fields
2238
-		if ( 'multi-line' == $question_type && isset( $data[ 'add_question_right_answer_multiline' ] ) && ( '' != $data[ 'add_question_right_answer_multiline' ] ) ) {
2239
-			$question_right_answer = $data[ 'add_question_right_answer_multiline' ];
2238
+		if ('multi-line' == $question_type && isset($data['add_question_right_answer_multiline']) && ('' != $data['add_question_right_answer_multiline'])) {
2239
+			$question_right_answer = $data['add_question_right_answer_multiline'];
2240 2240
 		} // End If Statement
2241 2241
 		// Handle Single Line Fields
2242
-		if ( 'single-line' == $question_type && isset( $data[ 'add_question_right_answer_singleline' ] ) && ( '' != $data[ 'add_question_right_answer_singleline' ] ) ) {
2243
-			$question_right_answer = $data[ 'add_question_right_answer_singleline' ];
2242
+		if ('single-line' == $question_type && isset($data['add_question_right_answer_singleline']) && ('' != $data['add_question_right_answer_singleline'])) {
2243
+			$question_right_answer = $data['add_question_right_answer_singleline'];
2244 2244
 		} // End If Statement
2245 2245
 		// Handle File Upload Fields
2246
-		if ( 'file-upload' == $question_type && isset( $data[ 'add_question_right_answer_fileupload' ] ) && ( '' != $data[ 'add_question_right_answer_fileupload' ] ) ) {
2247
-			$question_right_answer = $data[ 'add_question_right_answer_fileupload' ];
2246
+		if ('file-upload' == $question_type && isset($data['add_question_right_answer_fileupload']) && ('' != $data['add_question_right_answer_fileupload'])) {
2247
+			$question_right_answer = $data['add_question_right_answer_fileupload'];
2248 2248
 		} // End If Statement
2249
-		if ( 'file-upload' == $question_type && isset( $data[ 'add_question_wrong_answer_fileupload' ] ) && ( '' != $data[ 'add_question_wrong_answer_fileupload' ] ) ) {
2250
-			$question_wrong_answers = array( $data[ 'add_question_wrong_answer_fileupload' ] );
2249
+		if ('file-upload' == $question_type && isset($data['add_question_wrong_answer_fileupload']) && ('' != $data['add_question_wrong_answer_fileupload'])) {
2250
+			$question_wrong_answers = array($data['add_question_wrong_answer_fileupload']);
2251 2251
 		} // End If Statement
2252 2252
 
2253 2253
 		// Handle Question Grade
2254
-		if ( isset( $data[ 'question_grade' ] ) && ( '' != $data[ 'question_grade' ] ) ) {
2255
-			$question_grade = $data[ 'question_grade' ];
2254
+		if (isset($data['question_grade']) && ('' != $data['question_grade'])) {
2255
+			$question_grade = $data['question_grade'];
2256 2256
 		} // End If Statement
2257 2257
 
2258 2258
 		// Handle Answer Feedback
2259 2259
 		$answer_feedback = '';
2260
-		if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) {
2260
+		if (isset($data['answer_feedback_boolean']) && ! empty($data['answer_feedback_boolean'])) {
2261 2261
 
2262
-            $answer_feedback = $data[ 'answer_feedback_boolean' ];
2262
+            $answer_feedback = $data['answer_feedback_boolean'];
2263 2263
 
2264
-		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2264
+		}elseif (isset($data['answer_feedback_multiple_choice']) && ! empty($data['answer_feedback_multiple_choice'])) {
2265 2265
 
2266
-            $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2266
+            $answer_feedback = $data['answer_feedback_multiple_choice'];
2267 2267
 
2268
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2268
+        }elseif (isset($data['answer_feedback'])) {
2269 2269
 
2270
-            $answer_feedback = $data[ 'answer_feedback' ];
2270
+            $answer_feedback = $data['answer_feedback'];
2271 2271
 
2272 2272
         } // End If Statement
2273 2273
 
2274 2274
 		$post_title = $question_text;
2275
-		$post_author = $data[ 'post_author' ];
2275
+		$post_author = $data['post_author'];
2276 2276
 		$post_status = 'publish';
2277 2277
 		$post_type = 'question';
2278 2278
 		// Handle the extended question text
2279
-		if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) {
2280
-			$post_content = $data[ 'question_description' ];
2279
+		if (isset($data['question_description']) && ('' != $data['question_description'])) {
2280
+			$post_content = $data['question_description'];
2281 2281
 		}
2282 2282
 		else {
2283 2283
 			$post_content = '';
2284 2284
 		}
2285 2285
 		// Question Query Arguments
2286
-		$post_type_args = array(	'post_content' => $post_content,
2286
+		$post_type_args = array('post_content' => $post_content,
2287 2287
   		    						'post_status' => $post_status,
2288 2288
   		    						'post_title' => $post_title,
2289 2289
   		    						'post_type' => $post_type
2290 2290
   		    						);
2291 2291
 
2292 2292
   		// Remove empty values and reindex the array
2293
-  		if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) {
2294
-  			$question_right_answers_array = array_values( array_filter( $question_right_answers, 'strlen' ) );
2293
+  		if (is_array($question_right_answers) && 0 < count($question_right_answers)) {
2294
+  			$question_right_answers_array = array_values(array_filter($question_right_answers, 'strlen'));
2295 2295
   			$question_right_answers = array();
2296 2296
 
2297
-  			foreach( $question_right_answers_array as $answer ) {
2298
-  				if( ! in_array( $answer, $question_right_answers ) ) {
2297
+  			foreach ($question_right_answers_array as $answer) {
2298
+  				if ( ! in_array($answer, $question_right_answers)) {
2299 2299
   					$question_right_answers[] = $answer;
2300 2300
   				}
2301 2301
   			}
2302
-  			if ( 0 < count($question_right_answers) ) {
2302
+  			if (0 < count($question_right_answers)) {
2303 2303
   				$question_right_answer = $question_right_answers;
2304 2304
   			}
2305 2305
   		} // End If Statement
2306
-  		$right_answer_count = count( $question_right_answer );
2306
+  		$right_answer_count = count($question_right_answer);
2307 2307
 
2308 2308
 		// Remove empty values and reindex the array
2309
-  		if ( is_array( $question_wrong_answers ) ) {
2310
-  			$question_wrong_answers_array = array_values( array_filter( $question_wrong_answers, 'strlen' ) );
2309
+  		if (is_array($question_wrong_answers)) {
2310
+  			$question_wrong_answers_array = array_values(array_filter($question_wrong_answers, 'strlen'));
2311 2311
   			$question_wrong_answers = array();
2312 2312
   		} // End If Statement
2313 2313
 
2314
-  		foreach( $question_wrong_answers_array as $answer ) {
2315
-  			if( ! in_array( $answer, $question_wrong_answers ) ) {
2314
+  		foreach ($question_wrong_answers_array as $answer) {
2315
+  			if ( ! in_array($answer, $question_wrong_answers)) {
2316 2316
   				$question_wrong_answers[] = $answer;
2317 2317
   			}
2318 2318
   		}
2319 2319
 
2320
-  		$wrong_answer_count = count( $question_wrong_answers );
2320
+  		$wrong_answer_count = count($question_wrong_answers);
2321 2321
 
2322 2322
   		// Only save if there is a valid title
2323
-  		if ( $post_title != '' ) {
2323
+  		if ($post_title != '') {
2324 2324
 
2325 2325
   			// Get Quiz ID for the question
2326 2326
   		    $quiz_id = $data['quiz_id'];
@@ -2330,86 +2330,86 @@  discard block
 block discarded – undo
2330 2330
 
2331 2331
   		    // Get answer order
2332 2332
   		    $answer_order = '';
2333
-  		    if( isset( $data['answer_order'] ) ) {
2333
+  		    if (isset($data['answer_order'])) {
2334 2334
 				$answer_order = $data['answer_order'];
2335 2335
 			}
2336 2336
 
2337 2337
 			// Get random order selection
2338 2338
 			$random_order = 'no';
2339
-			if( isset( $data['random_order'] ) ) {
2339
+			if (isset($data['random_order'])) {
2340 2340
 				$random_order = $data['random_order'];
2341 2341
 			}
2342 2342
 
2343 2343
   		    // Insert or Update the question
2344
-  		    if ( 0 < $question_id ) {
2344
+  		    if (0 < $question_id) {
2345 2345
 
2346
-  		    	$post_type_args[ 'ID' ] = $question_id;
2347
-		    	$question_id = wp_update_post( $post_type_args );
2346
+  		    	$post_type_args['ID'] = $question_id;
2347
+		    	$question_id = wp_update_post($post_type_args);
2348 2348
 
2349 2349
 		    	// Update poast meta
2350
-		    	if( 'quiz' == $context ) {
2351
-		    		$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2352
-		    		if( ! in_array( $quiz_id, $quizzes ) ) {
2353
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2350
+		    	if ('quiz' == $context) {
2351
+		    		$quizzes = get_post_meta($question_id, '_quiz_id', false);
2352
+		    		if ( ! in_array($quiz_id, $quizzes)) {
2353
+			    		add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2354 2354
 			    	}
2355 2355
 		    	}
2356 2356
 
2357
-		    	update_post_meta( $question_id, '_question_grade', $question_grade );
2358
-		    	update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2359
-		    	update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2360
-		    	update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2361
-		    	update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2362
-		    	update_post_meta( $question_id, '_question_media', $question_media );
2363
-		    	update_post_meta( $question_id, '_answer_order', $answer_order );
2364
-		    	update_post_meta( $question_id, '_random_order', $random_order );
2365
-
2366
-		    	if( 'quiz' != $context ) {
2367
-		    		wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2357
+		    	update_post_meta($question_id, '_question_grade', $question_grade);
2358
+		    	update_post_meta($question_id, '_question_right_answer', $question_right_answer);
2359
+		    	update_post_meta($question_id, '_right_answer_count', $right_answer_count);
2360
+		    	update_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers);
2361
+		    	update_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count);
2362
+		    	update_post_meta($question_id, '_question_media', $question_media);
2363
+		    	update_post_meta($question_id, '_answer_order', $answer_order);
2364
+		    	update_post_meta($question_id, '_random_order', $random_order);
2365
+
2366
+		    	if ('quiz' != $context) {
2367
+		    		wp_set_post_terms($question_id, array($question_type), 'question-type', false);
2368 2368
 		    	}
2369 2369
 				// Don't store empty value, no point
2370
-				if ( !empty($answer_feedback) ) {
2371
-					update_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2370
+				if ( ! empty($answer_feedback)) {
2371
+					update_post_meta($question_id, '_answer_feedback', $answer_feedback);
2372 2372
 				}
2373 2373
 
2374 2374
 		    } else {
2375
-				$question_id = wp_insert_post( $post_type_args );
2376
-				$question_count = intval( $data['question_count'] );
2375
+				$question_id = wp_insert_post($post_type_args);
2376
+				$question_count = intval($data['question_count']);
2377 2377
 				++$question_count;
2378 2378
 
2379 2379
 				// Set post meta
2380
-				if( 'quiz' == $context ) {
2381
-					add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2382
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2383
-					update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2380
+				if ('quiz' == $context) {
2381
+					add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2382
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
2383
+					update_post_meta($lesson_id, '_quiz_has_questions', '1');
2384 2384
 				}
2385 2385
 
2386
-				if( isset( $question_grade ) ) {
2387
-		    		add_post_meta( $question_id, '_question_grade', $question_grade );
2386
+				if (isset($question_grade)) {
2387
+		    		add_post_meta($question_id, '_question_grade', $question_grade);
2388 2388
 		    	}
2389
-		    	add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2390
-		    	add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2391
-		    	add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2392
-		    	add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2393
-		    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2394
-		    	add_post_meta( $question_id, '_question_media', $question_media );
2395
-		    	add_post_meta( $question_id, '_answer_order', $answer_order );
2396
-		    	add_post_meta( $question_id, '_random_order', $random_order );
2389
+		    	add_post_meta($question_id, '_question_right_answer', $question_right_answer);
2390
+		    	add_post_meta($question_id, '_right_answer_count', $right_answer_count);
2391
+		    	add_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers);
2392
+		    	add_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count);
2393
+		    	add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count);
2394
+		    	add_post_meta($question_id, '_question_media', $question_media);
2395
+		    	add_post_meta($question_id, '_answer_order', $answer_order);
2396
+		    	add_post_meta($question_id, '_random_order', $random_order);
2397 2397
 				// Don't store empty value, no point
2398
-				if ( !empty($answer_feedback) ) {
2399
-					add_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2398
+				if ( ! empty($answer_feedback)) {
2399
+					add_post_meta($question_id, '_answer_feedback', $answer_feedback);
2400 2400
 				}
2401 2401
 
2402 2402
 		    	// Set the post terms for question-type
2403
-			    wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2403
+			    wp_set_post_terms($question_id, array($question_type), 'question-type');
2404 2404
 
2405
-			    if( $question_category ) {
2406
-	    			wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2405
+			    if ($question_category) {
2406
+	    			wp_set_post_terms($question_id, array($question_category), 'question-category');
2407 2407
 	    		}
2408 2408
 
2409 2409
 		    } // End If Statement
2410 2410
 		} // End If Statement
2411 2411
   		// Check that the insert or update saved by testing the post id
2412
-  		if ( 0 < $question_id ) {
2412
+  		if (0 < $question_id) {
2413 2413
   			$return = $question_id;
2414 2414
   		} // End If Statement
2415 2415
   		return $return;
@@ -2423,20 +2423,20 @@  discard block
 block discarded – undo
2423 2423
 	 * @param array $data (default: array())
2424 2424
 	 * @return void
2425 2425
 	 */
2426
-	private function lesson_delete_question( $data = array() ) {
2426
+	private function lesson_delete_question($data = array()) {
2427 2427
 
2428 2428
 		// Get which question to delete
2429 2429
 		$question_id = 0;
2430
-		if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) {
2431
-			$question_id = absint( $data[ 'question_id' ] );
2430
+		if (isset($data['question_id']) && (0 < absint($data['question_id']))) {
2431
+			$question_id = absint($data['question_id']);
2432 2432
 		} // End If Statement
2433 2433
 		// Delete the question
2434
-		if ( 0 < $question_id ) {
2435
-			$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2434
+		if (0 < $question_id) {
2435
+			$quizzes = get_post_meta($question_id, '_quiz_id', false);
2436 2436
 
2437
-			foreach( $quizzes as $quiz_id ) {
2438
-				if( $quiz_id == $data['quiz_id'] ) {
2439
-					delete_post_meta( $question_id, '_quiz_id', $quiz_id );
2437
+			foreach ($quizzes as $quiz_id) {
2438
+				if ($quiz_id == $data['quiz_id']) {
2439
+					delete_post_meta($question_id, '_quiz_id', $quiz_id);
2440 2440
 				}
2441 2441
 			}
2442 2442
 
@@ -2455,9 +2455,9 @@  discard block
 block discarded – undo
2455 2455
 	public function lesson_complexities() {
2456 2456
 
2457 2457
 		// V2 - make filter for this array
2458
-        $lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2459
-									'std' => __( 'Standard', 'woothemes-sensei' ),
2460
-									'hard' => __( 'Hard', 'woothemes-sensei' )
2458
+        $lesson_complexities = array('easy' => __('Easy', 'woothemes-sensei'),
2459
+									'std' => __('Standard', 'woothemes-sensei'),
2460
+									'hard' => __('Hard', 'woothemes-sensei')
2461 2461
 									);
2462 2462
 
2463 2463
 		return $lesson_complexities;
@@ -2472,9 +2472,9 @@  discard block
 block discarded – undo
2472 2472
 	 * @param string $post_status (default: 'publish')
2473 2473
 	 * @return int
2474 2474
 	 */
2475
-	public function lesson_count( $post_status = 'publish', $course_id = false ) {
2475
+	public function lesson_count($post_status = 'publish', $course_id = false) {
2476 2476
 
2477
-		$post_args = array(	'post_type'         => 'lesson',
2477
+		$post_args = array('post_type'         => 'lesson',
2478 2478
 							'posts_per_page'    => -1,
2479 2479
 //							'orderby'           => 'menu_order date',
2480 2480
 //							'order'             => 'ASC',
@@ -2482,7 +2482,7 @@  discard block
 block discarded – undo
2482 2482
 							'suppress_filters'  => 0,
2483 2483
 							'fields'            => 'ids',
2484 2484
 							);
2485
-		if( $course_id ) {
2485
+		if ($course_id) {
2486 2486
 			$post_args['meta_query'][] = array(
2487 2487
 				'key' => '_lesson_course',
2488 2488
 				'value' => $course_id,
@@ -2499,10 +2499,10 @@  discard block
 block discarded – undo
2499 2499
 
2500 2500
 		// Allow WP to generate the complex final query, just shortcut to only do an overall count
2501 2501
 //		add_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
2502
-		$lessons_query = new WP_Query( apply_filters( 'sensei_lesson_count', $post_args ) );
2502
+		$lessons_query = new WP_Query(apply_filters('sensei_lesson_count', $post_args));
2503 2503
 //		remove_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
2504 2504
 
2505
-		return count( $lessons_query->posts );
2505
+		return count($lessons_query->posts);
2506 2506
 	} // End lesson_count()
2507 2507
 
2508 2508
 
@@ -2515,11 +2515,11 @@  discard block
 block discarded – undo
2515 2515
 	 * @param string $fields (default: 'ids')
2516 2516
 	 * @return int $quiz_id
2517 2517
 	 */
2518
-	public function lesson_quizzes( $lesson_id = 0, $post_status = 'any', $fields = 'ids' ) {
2518
+	public function lesson_quizzes($lesson_id = 0, $post_status = 'any', $fields = 'ids') {
2519 2519
 
2520 2520
 		$posts_array = array();
2521 2521
 
2522
-		$post_args = array(	'post_type' 		=> 'quiz',
2522
+		$post_args = array('post_type' 		=> 'quiz',
2523 2523
 							'posts_per_page' 		=> 1,
2524 2524
 							'orderby'         	=> 'title',
2525 2525
     						'order'           	=> 'DESC',
@@ -2528,7 +2528,7 @@  discard block
 block discarded – undo
2528 2528
 							'suppress_filters' 	=> 0,
2529 2529
 							'fields'            => $fields
2530 2530
 							);
2531
-		$posts_array = get_posts( $post_args );
2531
+		$posts_array = get_posts($post_args);
2532 2532
         $quiz_id = array_shift($posts_array);
2533 2533
 
2534 2534
 		return $quiz_id;
@@ -2551,37 +2551,37 @@  discard block
 block discarded – undo
2551 2551
      *
2552 2552
 	 * @return array $questions { $question type WP_Post }
2553 2553
 	 */
2554
-	public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) {
2554
+	public function lesson_quiz_questions($quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC') {
2555 2555
 
2556 2556
 		$quiz_id = (string) $quiz_id;
2557
-        $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2557
+        $quiz_lesson_id = Sensei()->quiz->get_lesson_id($quiz_id);
2558 2558
 
2559 2559
         // setup the user id
2560
-        if( is_admin() ) {
2561
-            $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2560
+        if (is_admin()) {
2561
+            $user_id = isset($_GET['user']) ? $_GET['user'] : '';
2562 2562
         } else {
2563 2563
             $user_id = get_current_user_id();
2564 2564
         }
2565 2565
 
2566 2566
         // get the users current status on the lesson
2567
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2567
+        $user_lesson_status = Sensei_Utils::user_lesson_status($quiz_lesson_id, $user_id);
2568 2568
 
2569 2569
 		// Set the default question order if it has not already been set for this quiz
2570
-		$this->set_default_question_order( $quiz_id );
2570
+		$this->set_default_question_order($quiz_id);
2571 2571
 
2572 2572
 		// If viewing quiz on the frontend then show questions in random order if set
2573
-		if ( ! is_admin() ) {
2574
-			$random_order = get_post_meta( $quiz_id, '_random_question_order', true );
2575
-			if( $random_order && $random_order == 'yes' ) {
2573
+		if ( ! is_admin()) {
2574
+			$random_order = get_post_meta($quiz_id, '_random_question_order', true);
2575
+			if ($random_order && $random_order == 'yes') {
2576 2576
 				$orderby = 'rand';
2577 2577
 			}
2578 2578
 		}
2579 2579
 
2580 2580
 		// Get all questions and multiple questions
2581 2581
 		$question_query_args = array(
2582
-			'post_type' 		=> array( 'question', 'multiple_question' ),
2582
+			'post_type' 		=> array('question', 'multiple_question'),
2583 2583
 			'posts_per_page' 	=> -1,
2584
-			'meta_key'        	=> '_quiz_question_order' . $quiz_id,
2584
+			'meta_key'        	=> '_quiz_question_order'.$quiz_id,
2585 2585
 			'orderby'         	=> $orderby,
2586 2586
 			'order'           	=> $order,
2587 2587
 			'meta_query'		=> array(
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
 		);
2596 2596
 
2597 2597
         //query the questions
2598
-		$questions_query = new WP_Query( $question_query_args );
2598
+		$questions_query = new WP_Query($question_query_args);
2599 2599
 
2600 2600
         // Set return array to initially include all items
2601 2601
         $questions = $questions_query->posts;
@@ -2605,20 +2605,20 @@  discard block
 block discarded – undo
2605 2605
 
2606 2606
 		// If viewing quiz on frontend or in grading then only single questions must be shown
2607 2607
 		$selected_questions = false;
2608
-		if( ! is_admin() || ( is_admin() && isset( $_GET['page'] ) && 'sensei_grading' == $_GET['page'] && isset( $_GET['user'] ) && isset( $_GET['quiz_id'] ) ) ) {
2608
+		if ( ! is_admin() || (is_admin() && isset($_GET['page']) && 'sensei_grading' == $_GET['page'] && isset($_GET['user']) && isset($_GET['quiz_id']))) {
2609 2609
 
2610 2610
 			// Fetch the questions that the user was asked in their quiz if they have already completed it
2611
-			$questions_asked_string = !empty( $user_lesson_status->comment_ID) ? get_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', true ) : false;
2612
-			if( !empty($questions_asked_string) ) {
2611
+			$questions_asked_string = ! empty($user_lesson_status->comment_ID) ? get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true) : false;
2612
+			if ( ! empty($questions_asked_string)) {
2613 2613
 
2614
-				$selected_questions = explode( ',', $questions_asked_string );
2614
+				$selected_questions = explode(',', $questions_asked_string);
2615 2615
 
2616 2616
 				// Fetch each question in the order in which they were asked
2617 2617
 				$questions = array();
2618
-				foreach( $selected_questions as $question_id ) {
2619
-					if( ! $question_id ) continue;
2620
-					$question = get_post( $question_id );
2621
-					if( ! isset( $question ) || ! isset( $question->ID ) ) continue;
2618
+				foreach ($selected_questions as $question_id) {
2619
+					if ( ! $question_id) continue;
2620
+					$question = get_post($question_id);
2621
+					if ( ! isset($question) || ! isset($question->ID)) continue;
2622 2622
 					$questions[] = $question;
2623 2623
 				}
2624 2624
 
@@ -2630,24 +2630,24 @@  discard block
 block discarded – undo
2630 2630
 				$existing_questions = array();
2631 2631
 
2632 2632
 				// Set array of questions that already exist so we can prevent duplicates from appearing
2633
-				foreach( $questions_array as $question ) {
2634
-					if( 'question' != $question->post_type ) continue;
2633
+				foreach ($questions_array as $question) {
2634
+					if ('question' != $question->post_type) continue;
2635 2635
 					$existing_questions[] = $question->ID;
2636 2636
 				}
2637 2637
 
2638 2638
 				// Include only single questions in the return array
2639 2639
 				$questions_loop = $questions_array;
2640 2640
 				$questions_array = array();
2641
-				foreach( $questions_loop as $k => $question ) {
2641
+				foreach ($questions_loop as $k => $question) {
2642 2642
 
2643 2643
 					// If this is a single question then include it
2644
-					if( 'question' == $question->post_type ) {
2644
+					if ('question' == $question->post_type) {
2645 2645
 						$questions_array[] = $question;
2646 2646
 					} else {
2647 2647
 
2648 2648
 						// If this is a multiple question then get the specified amount of questions from the specified category
2649
-						$question_cat = intval( get_post_meta( $question->ID, 'category', true ) );
2650
-						$question_number = intval( get_post_meta( $question->ID, 'number', true ) );
2649
+						$question_cat = intval(get_post_meta($question->ID, 'category', true));
2650
+						$question_number = intval(get_post_meta($question->ID, 'number', true));
2651 2651
 
2652 2652
 						$qargs = array(
2653 2653
 							'post_type' 		=> 'question',
@@ -2664,14 +2664,14 @@  discard block
 block discarded – undo
2664 2664
 							'suppress_filters' 	=> 0,
2665 2665
 							'post__not_in'		=> $existing_questions,
2666 2666
 						);
2667
-						$cat_questions = get_posts( $qargs );
2667
+						$cat_questions = get_posts($qargs);
2668 2668
 
2669 2669
 						// Merge results into return array
2670
-						$questions_array = array_merge( $questions_array, $cat_questions );
2670
+						$questions_array = array_merge($questions_array, $cat_questions);
2671 2671
 
2672 2672
 						// Add selected questions to existing questions array to prevent duplicates from being added
2673
-						foreach( $questions_array as $cat_question ) {
2674
-							if( in_array( $cat_question->ID, $existing_questions ) ) continue;
2673
+						foreach ($questions_array as $cat_question) {
2674
+							if (in_array($cat_question->ID, $existing_questions)) continue;
2675 2675
 							$existing_questions[] = $cat_question->ID;
2676 2676
 						}
2677 2677
 					}
@@ -2683,29 +2683,29 @@  discard block
 block discarded – undo
2683 2683
 		}
2684 2684
 
2685 2685
 		// 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
2686
-		if( ! $selected_questions ) {
2686
+		if ( ! $selected_questions) {
2687 2687
 
2688 2688
 			// Only limit questions like this on the frontend
2689
-			if( ! is_admin() ) {
2689
+			if ( ! is_admin()) {
2690 2690
 
2691 2691
 				// Get number of questions to show
2692
-				$show_questions = intval( get_post_meta( $quiz_id, '_show_questions', true ) );
2693
-				if( $show_questions ) {
2692
+				$show_questions = intval(get_post_meta($quiz_id, '_show_questions', true));
2693
+				if ($show_questions) {
2694 2694
 
2695 2695
 					// Get random set of array keys from selected questions array
2696
-					$selected_questions = array_rand( $questions_array, $show_questions );
2696
+					$selected_questions = array_rand($questions_array, $show_questions);
2697 2697
 
2698 2698
 					// Loop through all questions and pick the the ones to be shown based on the random key selection
2699 2699
 					$questions = array();
2700
-					foreach( $questions_array as $k => $question ) {
2700
+					foreach ($questions_array as $k => $question) {
2701 2701
 
2702 2702
 						// Random keys will always be an array, unless only one question is to be shown
2703
-						if( is_array( $selected_questions ) ) {
2704
-							if( in_array( $k, $selected_questions ) ) {
2703
+						if (is_array($selected_questions)) {
2704
+							if (in_array($k, $selected_questions)) {
2705 2705
 								$questions[] = $question;
2706 2706
 							}
2707
-						} elseif( 1 == $show_questions ) {
2708
-							if ( $selected_questions == $k ) {
2707
+						} elseif (1 == $show_questions) {
2708
+							if ($selected_questions == $k) {
2709 2709
 								$questions[] = $question;
2710 2710
 							}
2711 2711
 						}
@@ -2716,12 +2716,12 @@  discard block
 block discarded – undo
2716 2716
 
2717 2717
         // Save the questions that will be asked for the current user
2718 2718
         // this happens only once per user/quiz, unless the user resets the quiz
2719
-        if( ! is_admin() ){
2719
+        if ( ! is_admin()) {
2720 2720
 
2721
-            if( $user_lesson_status ) {
2721
+            if ($user_lesson_status) {
2722 2722
 
2723 2723
                 $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2724
-                if ( empty($questions_asked) && $user_lesson_status) {
2724
+                if (empty($questions_asked) && $user_lesson_status) {
2725 2725
 
2726 2726
                     $questions_asked = array();
2727 2727
                     foreach ($questions as $question) {
@@ -2744,7 +2744,7 @@  discard block
 block discarded – undo
2744 2744
          * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2745 2745
          * @since 1.8.0
2746 2746
          */
2747
-		return apply_filters( 'sensei_lesson_quiz_questions', $questions,  $quiz_id  );
2747
+		return apply_filters('sensei_lesson_quiz_questions', $questions, $quiz_id);
2748 2748
 
2749 2749
 	} // End lesson_quiz_questions()
2750 2750
 
@@ -2752,13 +2752,13 @@  discard block
 block discarded – undo
2752 2752
 	 * Set the default quiz order
2753 2753
 	 * @param integer $quiz_id ID of quiz
2754 2754
 	 */
2755
-	public function set_default_question_order( $quiz_id = 0 ) {
2755
+	public function set_default_question_order($quiz_id = 0) {
2756 2756
 
2757
-		if( $quiz_id ) {
2757
+		if ($quiz_id) {
2758 2758
 
2759
-			$question_order = get_post_meta( $quiz_id, '_question_order', true );
2759
+			$question_order = get_post_meta($quiz_id, '_question_order', true);
2760 2760
 
2761
-			if( ! $question_order ) {
2761
+			if ( ! $question_order) {
2762 2762
 
2763 2763
 				$args = array(
2764 2764
 					'post_type' 		=> 'question',
@@ -2774,11 +2774,11 @@  discard block
 block discarded – undo
2774 2774
 					'post_status'		=> 'any',
2775 2775
 					'suppress_filters' 	=> 0
2776 2776
 				);
2777
-				$questions = get_posts( $args );
2777
+				$questions = get_posts($args);
2778 2778
 
2779 2779
 				$o = 1;
2780
-				foreach( $questions as $question ) {
2781
-					add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $o, true );
2780
+				foreach ($questions as $question) {
2781
+					add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$o, true);
2782 2782
 					$o++;
2783 2783
 				}
2784 2784
 			}
@@ -2797,36 +2797,36 @@  discard block
 block discarded – undo
2797 2797
 	 * @param string $height (default: '100')
2798 2798
 	 * @return string
2799 2799
 	 */
2800
-	public function lesson_image( $lesson_id = 0, $width = '100', $height = '100', $widget = false ) {
2800
+	public function lesson_image($lesson_id = 0, $width = '100', $height = '100', $widget = false) {
2801 2801
 
2802 2802
 		$html = '';
2803 2803
 
2804 2804
 		// Get Width and Height settings
2805
-		if ( ( $width == '100' ) && ( $height == '100' ) ) {
2805
+		if (($width == '100') && ($height == '100')) {
2806 2806
 
2807
-			if ( is_singular( 'lesson' ) ) {
2807
+			if (is_singular('lesson')) {
2808 2808
 
2809
-				if ( ! $widget && ! Sensei()->settings->settings[ 'lesson_single_image_enable' ] ) {
2809
+				if ( ! $widget && ! Sensei()->settings->settings['lesson_single_image_enable']) {
2810 2810
 
2811 2811
 					return '';
2812 2812
 
2813 2813
 				} // End If Statement
2814 2814
 
2815 2815
 				$image_thumb_size = 'lesson_single_image';
2816
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
2816
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
2817 2817
 				$width = $dimensions['width'];
2818 2818
 				$height = $dimensions['height'];
2819 2819
 				$crop = $dimensions['crop'];
2820 2820
 
2821 2821
 			} else {
2822 2822
 
2823
-				if ( ! $widget && ! Sensei()->settings->settings[ 'course_lesson_image_enable' ] ) {
2823
+				if ( ! $widget && ! Sensei()->settings->settings['course_lesson_image_enable']) {
2824 2824
 
2825 2825
 					return '';
2826 2826
 				} // End If Statement
2827 2827
 
2828 2828
 				$image_thumb_size = 'lesson_archive_image';
2829
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
2829
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
2830 2830
 				$width = $dimensions['width'];
2831 2831
 				$height = $dimensions['height'];
2832 2832
 				$crop = $dimensions['crop'];
@@ -2837,23 +2837,23 @@  discard block
 block discarded – undo
2837 2837
 
2838 2838
 		$img_url = '';
2839 2839
 
2840
-		if ( has_post_thumbnail( $lesson_id ) ) {
2840
+		if (has_post_thumbnail($lesson_id)) {
2841 2841
 
2842 2842
    			// Get Featured Image
2843
-   			$img_url = get_the_post_thumbnail( $lesson_id, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') );
2843
+   			$img_url = get_the_post_thumbnail($lesson_id, array($width, $height), array('class' => 'woo-image thumbnail alignleft'));
2844 2844
 
2845 2845
  		} else {
2846 2846
 
2847 2847
  			// Display Image Placeholder if none
2848
-			if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) {
2848
+			if (Sensei()->settings->settings['placeholder_images_enable']) {
2849 2849
 
2850
-                $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2850
+                $img_url = apply_filters('sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/'.$width.'x'.$height.'" class="woo-image thumbnail alignleft" />');
2851 2851
 
2852 2852
 			} // End If Statement
2853 2853
 
2854 2854
 		} // End If Statement
2855 2855
 
2856
-		$html .= '<a href="' . get_permalink( $lesson_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $lesson_id ) ) . '">' . $img_url . '</a>';
2856
+		$html .= '<a href="'.get_permalink($lesson_id).'" title="'.esc_attr(get_post_field('post_title', $lesson_id)).'">'.$img_url.'</a>';
2857 2857
 
2858 2858
 		return $html;
2859 2859
 
@@ -2865,9 +2865,9 @@  discard block
 block discarded – undo
2865 2865
      * @since 1.9.0
2866 2866
      * @param integer $lesson_id
2867 2867
      */
2868
-    public static function the_lesson_image( $lesson_id = 0 ){
2868
+    public static function the_lesson_image($lesson_id = 0) {
2869 2869
 
2870
-        echo Sensei()->lesson->lesson_image( $lesson_id );
2870
+        echo Sensei()->lesson->lesson_image($lesson_id);
2871 2871
 
2872 2872
     }
2873 2873
 
@@ -2878,17 +2878,17 @@  discard block
 block discarded – undo
2878 2878
      * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2879 2879
 	 * @return string
2880 2880
 	 */
2881
-	public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) {
2881
+	public static function lesson_excerpt($lesson = null, $add_p_tags = true) {
2882 2882
 		$html = '';
2883
-		if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) {
2883
+		if (is_a($lesson, 'WP_Post') && 'lesson' == $lesson->post_type) {
2884 2884
 
2885
-            $excerpt =  $lesson->post_excerpt;
2885
+            $excerpt = $lesson->post_excerpt;
2886 2886
 
2887 2887
             // if $add_p_tags true wrap with <p> else return the excerpt as is
2888
-            $html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2888
+            $html = $add_p_tags ? wpautop($excerpt) : $excerpt;
2889 2889
 
2890 2890
 		}
2891
-		return apply_filters( 'sensei_lesson_excerpt', $html );
2891
+		return apply_filters('sensei_lesson_excerpt', $html);
2892 2892
 
2893 2893
 	} // End lesson_excerpt()
2894 2894
 
@@ -2901,20 +2901,20 @@  discard block
 block discarded – undo
2901 2901
      * @param int $lesson_id
2902 2902
      * @return int|bool $course_id or bool when nothing is found.
2903 2903
      */
2904
-     public function get_course_id( $lesson_id ){
2904
+     public function get_course_id($lesson_id) {
2905 2905
 
2906
-         if( ! isset( $lesson_id ) || empty( $lesson_id )
2907
-         ||  'lesson' != get_post_type( $lesson_id ) ){
2906
+         if ( ! isset($lesson_id) || empty($lesson_id)
2907
+         ||  'lesson' != get_post_type($lesson_id)) {
2908 2908
              return false;
2909 2909
          }
2910 2910
 
2911
-         $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2911
+         $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
2912 2912
 
2913 2913
          // make sure the course id is valid
2914
-         if( empty( $lesson_course_id )
2915
-             || is_array( $lesson_course_id )
2916
-             || intval( $lesson_course_id ) < 1
2917
-             || 'course' != get_post_type( $lesson_course_id ) ){
2914
+         if (empty($lesson_course_id)
2915
+             || is_array($lesson_course_id)
2916
+             || intval($lesson_course_id) < 1
2917
+             || 'course' != get_post_type($lesson_course_id)) {
2918 2918
 
2919 2919
              return false;
2920 2920
 
@@ -2941,10 +2941,10 @@  discard block
 block discarded – undo
2941 2941
      * @param string $post_type
2942 2942
      * @return void
2943 2943
      */
2944
-    public function all_lessons_edit_fields( $column_name, $post_type ) {
2944
+    public function all_lessons_edit_fields($column_name, $post_type) {
2945 2945
 
2946 2946
         // only show these options ont he lesson post type edit screen
2947
-        if( 'lesson' != $post_type || 'lesson-course' != $column_name ){
2947
+        if ('lesson' != $post_type || 'lesson-course' != $column_name) {
2948 2948
             return;
2949 2949
         }
2950 2950
 
@@ -2952,41 +2952,41 @@  discard block
 block discarded – undo
2952 2952
         <fieldset class="sensei-edit-field-set inline-edit-lesson">
2953 2953
             <div class="sensei-inline-edit-col column-<?php echo $column_name ?>">
2954 2954
                     <?php
2955
-                    echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2955
+                    echo '<h4>'.__('Lesson Information', 'woothemes-sensei').'</h4>';
2956 2956
                     // create a nonce field to be  used as a security measure when saving the data
2957
-                    wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2958
-                    wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2957
+                    wp_nonce_field('bulk-edit-lessons', '_edit_lessons_nonce');
2958
+                    wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce');
2959 2959
 
2960 2960
                     // unchanged option - we need this in because
2961 2961
                     // the default option in bulk edit should not be empty. If it is
2962 2962
                     // the user will erase data they didn't want to touch.
2963
-                    $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2963
+                    $no_change_text = '-- '.__('No Change', 'woothemes-sensei').' --';
2964 2964
 
2965 2965
                     //
2966 2966
                     //course selection
2967 2967
                     //
2968
-                    $courses =  WooThemes_Sensei_Course::get_all_courses();
2968
+                    $courses = WooThemes_Sensei_Course::get_all_courses();
2969 2969
                     $course_options = array();
2970
-                    if ( count( $courses ) > 0 ) {
2971
-                        foreach ($courses as $course ){
2972
-                            $course_options[ $course->ID ] = get_the_title( $course->ID );
2970
+                    if (count($courses) > 0) {
2971
+                        foreach ($courses as $course) {
2972
+                            $course_options[$course->ID] = get_the_title($course->ID);
2973 2973
                         }
2974 2974
                     }
2975 2975
                     //pre-append the no change option
2976
-                    $course_options['-1']=  $no_change_text;
2977
-                    $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2978
-                    $course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
2979
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
2976
+                    $course_options['-1'] = $no_change_text;
2977
+                    $course_attributes = array('name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course', 'class'=>' ');
2978
+                    $course_field = Sensei_Utils::generate_drop_down('-1', $course_options, $course_attributes);
2979
+                    echo $this->generate_all_lessons_edit_field(__('Lesson Course', 'woothemes-sensei'), $course_field);
2980 2980
 
2981 2981
                     //
2982 2982
                     // lesson complexity selection
2983 2983
                     //
2984
-                    $lesson_complexities =  $this->lesson_complexities();
2984
+                    $lesson_complexities = $this->lesson_complexities();
2985 2985
                     //pre-append the no change option
2986
-                    $lesson_complexities['-1']=  $no_change_text;
2987
-                    $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
2988
-                    $complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
2989
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
2986
+                    $lesson_complexities['-1'] = $no_change_text;
2987
+                    $complexity_dropdown_attributes = array('name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity', 'class'=>' ');
2988
+                    $complexity_filed = Sensei_Utils::generate_drop_down('-1', $lesson_complexities, $complexity_dropdown_attributes);
2989
+                    echo $this->generate_all_lessons_edit_field(__('Lesson Complexity', 'woothemes-sensei'), $complexity_filed);
2990 2990
 
2991 2991
                     ?>
2992 2992
 
@@ -2999,34 +2999,34 @@  discard block
 block discarded – undo
2999 2999
                     //
3000 3000
                     $pass_required_options = array(
3001 3001
                         '-1' => $no_change_text,
3002
-                         '0' => __('No','woothemes'),
3003
-                         '1' => __('Yes','woothemes'),
3002
+                         '0' => __('No', 'woothemes'),
3003
+                         '1' => __('Yes', 'woothemes'),
3004 3004
                     );
3005 3005
 
3006
-                    $pass_required_select_attributes = array( 'name'=> 'pass_required',
3006
+                    $pass_required_select_attributes = array('name'=> 'pass_required',
3007 3007
                                                                 'id'=> 'sensei-edit-lesson-pass-required',
3008
-                                                                'class'=>' '   );
3009
-                    $require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3010
-                    echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3008
+                                                                'class'=>' ');
3009
+                    $require_pass_field = Sensei_Utils::generate_drop_down('-1', $pass_required_options, $pass_required_select_attributes, false);
3010
+                    echo $this->generate_all_lessons_edit_field(__('Pass required', 'woothemes-sensei'), $require_pass_field);
3011 3011
 
3012 3012
                     //
3013 3013
                     // Quiz pass percentage
3014 3014
                     //
3015 3015
                     $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3016
-                    echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3016
+                    echo $this->generate_all_lessons_edit_field(__('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field);
3017 3017
 
3018 3018
                     //
3019 3019
                     // Enable quiz reset button
3020 3020
                     //
3021 3021
                     $quiz_reset_select__options = array(
3022 3022
                         '-1' => $no_change_text,
3023
-                        '0' => __('No','woothemes'),
3024
-                        '1' => __('Yes','woothemes'),
3023
+                        '0' => __('No', 'woothemes'),
3024
+                        '1' => __('Yes', 'woothemes'),
3025 3025
                     );
3026 3026
                     $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3027
-                    $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3028
-                    $quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3029
-                    echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3027
+                    $quiz_reset_select_attributes = array('name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ');
3028
+                    $quiz_reset_field = Sensei_Utils::generate_drop_down('-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false);
3029
+                    echo $this->generate_all_lessons_edit_field(__('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field);
3030 3030
 
3031 3031
                     ?>
3032 3032
             </div>
@@ -3045,17 +3045,17 @@  discard block
 block discarded – undo
3045 3045
      * @param string $field type markup for the field that must be wrapped.
3046 3046
      * @return string $field_html
3047 3047
      */
3048
-    public function generate_all_lessons_edit_field( $title  ,$field ){
3048
+    public function generate_all_lessons_edit_field($title, $field) {
3049 3049
 
3050 3050
         $html = '';
3051 3051
         $html = '<div class="inline-edit-group" >';
3052
-        $html .=  '<span class="title">'. $title .'</span> ';
3052
+        $html .= '<span class="title">'.$title.'</span> ';
3053 3053
         $html .= '<span class="input-text-wrap">';
3054 3054
         $html .= $field;
3055 3055
         $html .= '</span>';
3056 3056
         $html .= '</label></div>';
3057 3057
 
3058
-        return $html ;
3058
+        return $html;
3059 3059
 
3060 3060
     }//end generate_all_lessons_edit_field
3061 3061
 
@@ -3069,48 +3069,48 @@  discard block
 block discarded – undo
3069 3069
     function save_all_lessons_edit_fields() {
3070 3070
 
3071 3071
         // verify all the data before attempting to save
3072
-        if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3073
-            ||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3072
+        if ( ! isset($_POST['security']) || ! check_ajax_referer('bulk-edit-lessons', 'security')
3073
+            ||  empty($_POST['post_ids']) || ! is_array($_POST['post_ids'])) {
3074 3074
             die();
3075 3075
         }
3076 3076
 
3077 3077
         // get our variables
3078
-        $new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3079
-        $new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3080
-        $new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3081
-        $new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3082
-        $new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3078
+        $new_course = sanitize_text_field($_POST['sensei_edit_lesson_course']);
3079
+        $new_complexity = sanitize_text_field($_POST['sensei_edit_complexity']);
3080
+        $new_pass_required = sanitize_text_field($_POST['sensei_edit_pass_required']);
3081
+        $new_pass_percentage = sanitize_text_field($_POST['sensei_edit_pass_percentage']);
3082
+        $new_enable_quiz_reset = sanitize_text_field($_POST['sensei_edit_enable_quiz_reset']);
3083 3083
         // store the values for all selected posts
3084
-        foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3084
+        foreach ($_POST['post_ids'] as $lesson_id) {
3085 3085
 
3086 3086
             // get the quiz id needed for the quiz meta
3087
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3087
+            $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
3088 3088
 
3089 3089
             // do not save the items if the value is -1 as this
3090 3090
             // means it was not changed
3091 3091
 
3092 3092
             // update lesson course
3093
-            if( -1 != $new_course ){
3094
-                update_post_meta( $lesson_id, '_lesson_course', $new_course );
3093
+            if ( -1 != $new_course ) {
3094
+                update_post_meta($lesson_id, '_lesson_course', $new_course);
3095 3095
             }
3096 3096
             // update lesson complexity
3097
-            if( -1 != $new_complexity ){
3098
-                update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3097
+            if ( -1 != $new_complexity ) {
3098
+                update_post_meta($lesson_id, '_lesson_complexity', $new_complexity);
3099 3099
             }
3100 3100
 
3101 3101
             // Quiz Related settings
3102
-            if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3102
+            if (isset($quiz_id) && 0 < intval($quiz_id)) {
3103 3103
 
3104 3104
                 // update pass required
3105 3105
                 if (-1 != $new_pass_required) {
3106 3106
 
3107
-                    $checked = $new_pass_required  ? 'on' : '';
3107
+                    $checked = $new_pass_required ? 'on' : '';
3108 3108
                     update_post_meta($quiz_id, '_pass_required', $checked);
3109
-                    unset( $checked );
3109
+                    unset($checked);
3110 3110
                 }
3111 3111
 
3112 3112
                 // update pass percentage
3113
-                if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3113
+                if ( ! empty($new_pass_percentage) && is_numeric($new_pass_percentage)) {
3114 3114
 
3115 3115
                         update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3116 3116
 
@@ -3121,9 +3121,9 @@  discard block
 block discarded – undo
3121 3121
                 //
3122 3122
                 if (-1 != $new_enable_quiz_reset ) {
3123 3123
 
3124
-                    $checked = $new_enable_quiz_reset ? 'on' : ''  ;
3124
+                    $checked = $new_enable_quiz_reset ? 'on' : '';
3125 3125
                     update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3126
-                    unset( $checked );
3126
+                    unset($checked);
3127 3127
 
3128 3128
                 }
3129 3129
 
@@ -3147,31 +3147,31 @@  discard block
 block discarded – undo
3147 3147
      * @since 1.8.0
3148 3148
      * @return void
3149 3149
      */
3150
-    public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3150
+    public function set_quick_edit_admin_defaults($column_name, $post_id) {
3151 3151
 
3152
-        if( 'lesson-course' != $column_name ){
3152
+        if ('lesson-course' != $column_name) {
3153 3153
             return;
3154 3154
         }
3155 3155
         // load the script
3156
-        $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3157
-        wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3156
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3157
+        wp_enqueue_script('sensei-lesson-quick-edit', Sensei()->plugin_url.'assets/js/admin/lesson-quick-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true);
3158 3158
 
3159 3159
         // setup the values for all meta fields
3160 3160
         $data = array();
3161
-        foreach( $this->meta_fields as $field ){
3161
+        foreach ($this->meta_fields as $field) {
3162 3162
 
3163
-            $data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3163
+            $data[$field] = get_post_meta($post_id, '_'.$field, true);
3164 3164
 
3165 3165
         }
3166 3166
         // add quiz meta fields
3167
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3168
-        foreach( Sensei()->quiz->meta_fields as $field ){
3167
+        $quiz_id = Sensei()->lesson->lesson_quizzes($post_id);
3168
+        foreach (Sensei()->quiz->meta_fields as $field) {
3169 3169
 
3170
-            $data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3170
+            $data[$field] = get_post_meta($quiz_id, '_'.$field, true);
3171 3171
 
3172 3172
         }
3173 3173
 
3174
-        wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3174
+        wp_localize_script('sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data);
3175 3175
 
3176 3176
     }// end quick edit admin defaults
3177 3177
 
@@ -3184,19 +3184,19 @@  discard block
 block discarded – undo
3184 3184
      * @param array $classes
3185 3185
      * @return array $classes
3186 3186
      */
3187
-    public static function single_course_lessons_classes( $classes ){
3187
+    public static function single_course_lessons_classes($classes) {
3188 3188
 
3189
-        if(  is_singular('course') ){
3189
+        if (is_singular('course')) {
3190 3190
 
3191 3191
             global $post;
3192 3192
             $course_id = $post->ID;
3193 3193
 
3194
-            $lesson_classes = array( 'course', 'post' );
3195
-            if ( is_user_logged_in() ) {
3194
+            $lesson_classes = array('course', 'post');
3195
+            if (is_user_logged_in()) {
3196 3196
 
3197 3197
                 // Check if Lesson is complete
3198
-                $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3199
-                if ( $single_lesson_complete ) {
3198
+                $single_lesson_complete = Sensei_Utils::user_completed_lesson(get_the_ID(), get_current_user_id());
3199
+                if ($single_lesson_complete) {
3200 3200
 
3201 3201
                     $lesson_classes[] = 'lesson-completed';
3202 3202
 
@@ -3204,14 +3204,14 @@  discard block
 block discarded – undo
3204 3204
 
3205 3205
             } // End If Statement
3206 3206
 
3207
-            $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3208
-            if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3207
+            $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
3208
+            if (Sensei_Utils::is_preview_lesson(get_the_ID()) && ! $is_user_taking_course) {
3209 3209
 
3210 3210
                 $lesson_classes[] = 'lesson-preview';
3211 3211
 
3212 3212
             }
3213 3213
 
3214
-            $classes = array_merge( $classes, $lesson_classes  );
3214
+            $classes = array_merge($classes, $lesson_classes);
3215 3215
 
3216 3216
         }
3217 3217
 
@@ -3225,56 +3225,56 @@  discard block
 block discarded – undo
3225 3225
      * @since 1.9.0
3226 3226
      * @param $lesson_id
3227 3227
      */
3228
-    public static function the_lesson_meta( $lesson_id ){
3228
+    public static function the_lesson_meta($lesson_id) {
3229 3229
 
3230 3230
         global $wp_query;
3231 3231
         $loop_lesson_number = $wp_query->current_post + 1;
3232 3232
 
3233
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
3233
+        $course_id = Sensei()->lesson->get_course_id($lesson_id);
3234 3234
         $single_lesson_complete = false;
3235
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3235
+        $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
3236 3236
 
3237 3237
         // Get Lesson data
3238 3238
         $complexity_array = Sensei()->lesson->lesson_complexities();
3239 3239
 
3240
-        $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3241
-        if ( '' != $lesson_complexity ) {
3240
+        $lesson_complexity = get_post_meta($lesson_id, '_lesson_complexity', true);
3241
+        if ('' != $lesson_complexity) {
3242 3242
 
3243 3243
             $lesson_complexity = $complexity_array[$lesson_complexity];
3244 3244
 
3245 3245
         }
3246
-        $user_info = get_userdata( absint( get_post()->post_author ) );
3247
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3246
+        $user_info = get_userdata(absint(get_post()->post_author));
3247
+        $is_preview = Sensei_Utils::is_preview_lesson($lesson_id);
3248 3248
         $preview_label = '';
3249
-        if ( $is_preview && !$is_user_taking_course ) {
3249
+        if ($is_preview && ! $is_user_taking_course) {
3250 3250
 
3251
-            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3252
-            $preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3251
+            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text($lesson_id);
3252
+            $preview_label = '<span class="preview-heading">'.$preview_label.'</span>';
3253 3253
 
3254 3254
         }
3255 3255
 
3256 3256
 
3257
-        $count_markup= '';
3257
+        $count_markup = '';
3258 3258
         /**
3259 3259
          * Filter for if you want the $lesson_count to show next to the lesson.
3260 3260
          *
3261 3261
          * @since 1.0
3262 3262
          * @param bool default false.
3263 3263
          */
3264
-        if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3264
+        if (apply_filters('sensei_show_lesson_numbers', false)) {
3265 3265
 
3266
-            $count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3266
+            $count_markup = '<span class="lesson-number">'.$loop_lesson_number.'</span>';
3267 3267
 
3268 3268
         }
3269 3269
 
3270
-        $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3270
+        $heading_link_title = sprintf(__('Start %s', 'woothemes-sensei'), get_the_title($lesson_id));
3271 3271
 
3272 3272
         ?>
3273 3273
         <header>
3274 3274
             <h2>
3275
-                <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>"
3276
-                   title="<?php esc_attr_e( $heading_link_title ) ?>" >
3277
-                    <?php echo $count_markup. get_the_title( $lesson_id ) . $preview_label; ?>
3275
+                <a href="<?php echo esc_url_raw(get_permalink($lesson_id)) ?>"
3276
+                   title="<?php esc_attr_e($heading_link_title) ?>" >
3277
+                    <?php echo $count_markup.get_the_title($lesson_id).$preview_label; ?>
3278 3278
                 </a>
3279 3279
             </h2>
3280 3280
 
@@ -3283,33 +3283,33 @@  discard block
 block discarded – undo
3283 3283
                 <?php
3284 3284
 
3285 3285
                 $meta_html = '';
3286
-                $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3286
+                $user_lesson_status = Sensei_Utils::user_lesson_status(get_the_ID(), get_current_user_id());
3287 3287
 
3288
-                $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3289
-                if ( '' != $lesson_length ) {
3288
+                $lesson_length = get_post_meta($lesson_id, '_lesson_length', true);
3289
+                if ('' != $lesson_length) {
3290 3290
 
3291
-                    $meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3291
+                    $meta_html .= '<span class="lesson-length">'.__('Length: ', 'woothemes-sensei').$lesson_length.__(' minutes', 'woothemes-sensei').'</span>';
3292 3292
 
3293 3293
                 }
3294 3294
 
3295
-                if ( Sensei()->settings->get( 'lesson_author' ) ) {
3295
+                if (Sensei()->settings->get('lesson_author')) {
3296 3296
 
3297
-                    $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>';
3297
+                    $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>';
3298 3298
 
3299 3299
                 } // End If Statement
3300
-                if ( '' != $lesson_complexity ) {
3300
+                if ('' != $lesson_complexity) {
3301 3301
 
3302
-                    $meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3302
+                    $meta_html .= '<span class="lesson-complexity">'.__('Complexity: ', 'woothemes-sensei').$lesson_complexity.'</span>';
3303 3303
 
3304 3304
                 }
3305 3305
 
3306
-                if ( $single_lesson_complete ) {
3306
+                if ($single_lesson_complete) {
3307 3307
 
3308
-                    $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3308
+                    $meta_html .= '<span class="lesson-status complete">'.__('Complete', 'woothemes-sensei').'</span>';
3309 3309
 
3310
-                } elseif ( $user_lesson_status ) {
3310
+                } elseif ($user_lesson_status) {
3311 3311
 
3312
-                    $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3312
+                    $meta_html .= '<span class="lesson-status in-progress">'.__('In Progress', 'woothemes-sensei').'</span>';
3313 3313
 
3314 3314
                 } // End If Statement
3315 3315
 
@@ -3332,19 +3332,19 @@  discard block
 block discarded – undo
3332 3332
      *
3333 3333
      * @param $lesson_id
3334 3334
      */
3335
-    public static function the_lesson_thumbnail( $lesson_id ){
3335
+    public static function the_lesson_thumbnail($lesson_id) {
3336 3336
 
3337
-        if( empty( $lesson_id ) ){
3337
+        if (empty($lesson_id)) {
3338 3338
 
3339 3339
             $lesson_id = get_the_ID();
3340 3340
 
3341 3341
         }
3342 3342
 
3343
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3343
+        if ('lesson' != get_post_type($lesson_id)) {
3344 3344
             return;
3345 3345
         }
3346 3346
 
3347
-        echo Sensei()->lesson->lesson_image( $lesson_id );
3347
+        echo Sensei()->lesson->lesson_image($lesson_id);
3348 3348
     }
3349 3349
 
3350 3350
 
@@ -3355,14 +3355,14 @@  discard block
 block discarded – undo
3355 3355
      * @param string $excerpt
3356 3356
      * @return string $excerpt
3357 3357
      */
3358
-    public static function alter_the_lesson_excerpt( $excerpt ) {
3358
+    public static function alter_the_lesson_excerpt($excerpt) {
3359 3359
 
3360
-        if ('lesson' == get_post_type(get_the_ID())){
3360
+        if ('lesson' == get_post_type(get_the_ID())) {
3361 3361
 
3362 3362
             // remove this hooks to avoid an infinite loop.
3363
-            remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3363
+            remove_filter('get_the_excerpt', array('WooThemes_Sensei_Lesson', 'alter_the_lesson_excerpt'));
3364 3364
 
3365
-            return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3365
+            return WooThemes_Sensei_Lesson::lesson_excerpt(get_post(get_the_ID()));
3366 3366
         }
3367 3367
 
3368 3368
         return $excerpt;
@@ -3377,20 +3377,20 @@  discard block
 block discarded – undo
3377 3377
      * @param $current_lesson_id
3378 3378
      * @return mixed | bool | int $prerequisite_lesson_id or false
3379 3379
      */
3380
-    public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3380
+    public static function get_lesson_prerequisite_id($current_lesson_id) {
3381 3381
 
3382
-        $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3382
+        $prerequisite_lesson_id = get_post_meta($current_lesson_id, '_lesson_prerequisite', true);
3383 3383
 
3384 3384
         // set ti to false if not a valid prerequisite lesson id
3385
-        if(  empty( $prerequisite_lesson_id )
3386
-            || 'lesson' != get_post_type( $prerequisite_lesson_id )
3387
-            || $prerequisite_lesson_id == $current_lesson_id  ) {
3385
+        if (empty($prerequisite_lesson_id)
3386
+            || 'lesson' != get_post_type($prerequisite_lesson_id)
3387
+            || $prerequisite_lesson_id == $current_lesson_id) {
3388 3388
 
3389 3389
             $prerequisite_lesson_id = false;
3390 3390
 
3391 3391
         }
3392 3392
 
3393
-        return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3393
+        return apply_filters('sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id);
3394 3394
 
3395 3395
     }
3396 3396
 
@@ -3405,27 +3405,27 @@  discard block
 block discarded – undo
3405 3405
      * @param $user_id
3406 3406
      * @return bool
3407 3407
      */
3408
-    public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3408
+    public  static function is_prerequisite_complete($lesson_id, $user_id) {
3409 3409
 
3410
-        if( empty( $lesson_id ) || empty( $user_id )
3411
-        || 'lesson' != get_post_type( $lesson_id )
3412
-        ||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3410
+        if (empty($lesson_id) || empty($user_id)
3411
+        || 'lesson' != get_post_type($lesson_id)
3412
+        ||  ! is_a(get_user_by('id', $user_id), 'WP_User')) {
3413 3413
 
3414 3414
             return false;
3415 3415
 
3416 3416
         }
3417 3417
 
3418
-        $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3418
+        $pre_requisite_id = (string) self::get_lesson_prerequisite_id($lesson_id);
3419 3419
 
3420 3420
         // not a valid pre-requisite so pre-requisite is completed
3421
-        if( 'lesson' != get_post_type( $pre_requisite_id )
3422
-            || ! is_numeric( $pre_requisite_id ) ){
3421
+        if ('lesson' != get_post_type($pre_requisite_id)
3422
+            || ! is_numeric($pre_requisite_id)) {
3423 3423
 
3424 3424
             return true;
3425 3425
 
3426 3426
         }
3427 3427
 
3428
-        return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3428
+        return  Sensei_Utils::user_completed_lesson($pre_requisite_id, $user_id);
3429 3429
 
3430 3430
     }// end is_prerequisite_complete
3431 3431
 
@@ -3434,20 +3434,20 @@  discard block
 block discarded – undo
3434 3434
      *
3435 3435
      * @since 1.9.0
3436 3436
      */
3437
-    public  static function user_not_taking_course_message(){
3437
+    public  static function user_not_taking_course_message() {
3438 3438
 
3439 3439
         $lesson_id = get_the_ID();
3440 3440
 
3441
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3441
+        if ('lesson' != get_post_type($lesson_id)) {
3442 3442
             return;
3443 3443
         }
3444 3444
 
3445
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3446
-        $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3447
-        $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3448
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3445
+        $is_preview = Sensei_Utils::is_preview_lesson($lesson_id);
3446
+        $pre_requisite_complete = self::is_prerequisite_complete($lesson_id, get_current_user_id());
3447
+        $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
3448
+        $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id());
3449 3449
 
3450
-        if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3450
+        if ($pre_requisite_complete && $is_preview && ! $user_taking_course) {
3451 3451
             ?>
3452 3452
 
3453 3453
             <div class="sensei-message alert">
@@ -3467,11 +3467,11 @@  discard block
 block discarded – undo
3467 3467
      *
3468 3468
      * @since 1.9.0
3469 3469
      */
3470
-    public static function course_signup_link( ){
3470
+    public static function course_signup_link( ) {
3471 3471
 
3472
-        $course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3472
+        $course_id = Sensei()->lesson->get_course_id(get_the_ID());
3473 3473
 
3474
-        if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3474
+        if (empty($course_id) || 'course' != get_post_type($course_id) || sensei_all_access()) {
3475 3475
 
3476 3476
             return;
3477 3477
 
@@ -3481,24 +3481,24 @@  discard block
 block discarded – undo
3481 3481
         <section class="course-signup lesson-meta">
3482 3482
 
3483 3483
             <?php
3484
-            $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3484
+            $wc_post_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true);
3485 3485
 
3486
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3486
+            if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) {
3487 3487
 
3488 3488
                 global $current_user;
3489
-                if( is_user_logged_in() ) {
3489
+                if (is_user_logged_in()) {
3490 3490
                     wp_get_current_user();
3491 3491
 
3492
-                    $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3492
+                    $course_purchased = Sensei_Utils::sensei_customer_bought_product($current_user->user_email, $current_user->ID, $wc_post_id);
3493 3493
 
3494
-                    if( $course_purchased ) {
3494
+                    if ($course_purchased) {
3495 3495
 
3496
-                        $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3497
-                        $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3496
+                        $prereq_course_id = get_post_meta($course_id, '_course_prerequisite', true);
3497
+                        $course_link = '<a href="'.esc_url(get_permalink($prereq_course_id)).'" title="'.esc_attr(get_the_title($prereq_course_id)).'">'.__('the previous course', 'woothemes-sensei').'</a>';
3498 3498
                         ?>
3499 3499
                             <div class="sensei-message info">
3500 3500
 
3501
-                                <?php  echo sprintf( __( 'Please complete %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); ?>
3501
+                                <?php  echo sprintf(__('Please complete %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); ?>
3502 3502
 
3503 3503
                             </div>
3504 3504
 
@@ -3507,12 +3507,12 @@  discard block
 block discarded – undo
3507 3507
                         <div class="sensei-message info">
3508 3508
 
3509 3509
                             <?php
3510
-                            $course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3511
-                                            . '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3512
-                                            . '">' . __( 'course', 'woothemes-sensei' )
3510
+                            $course_link = '<a href="'.esc_url(get_permalink($course_id))
3511
+                                            . '"title="'.__('Sign Up', 'woothemes-sensei')
3512
+                                            . '">'.__('course', 'woothemes-sensei')
3513 3513
                                             . '</a>';
3514 3514
 
3515
-                            echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3515
+                            echo  sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
3516 3516
 
3517 3517
                             ?>
3518 3518
 
@@ -3521,23 +3521,23 @@  discard block
 block discarded – undo
3521 3521
 
3522 3522
                 <?php } else { ?>
3523 3523
 
3524
-                    <div class="sensei-message info"><?php echo sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Sign Up', 'woothemes-sensei' )  . '">' . __( 'course', 'woothemes-sensei' ) . '</a>' ); ?></div>
3524
+                    <div class="sensei-message info"><?php echo sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Sign Up', 'woothemes-sensei').'">'.__('course', 'woothemes-sensei').'</a>'); ?></div>
3525 3525
 
3526 3526
                 <?php } ?>
3527 3527
 
3528 3528
             <?php } else { ?>
3529 3529
 
3530
-            <?php if( ! Sensei_Utils::user_started_course( $course_id, get_current_user_id() ) &&  sensei_is_login_required() )  : ?>
3530
+            <?php if ( ! Sensei_Utils::user_started_course($course_id, get_current_user_id()) && sensei_is_login_required())  : ?>
3531 3531
 
3532 3532
                 <div class="sensei-message info">
3533 3533
                     <?php
3534
-                    $course_link =  '<a href="'
3535
-                                        . esc_url( get_permalink( $course_id ) )
3536
-                                        . '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3537
-                                        . '">' . __( 'course', 'woothemes-sensei' )
3534
+                    $course_link = '<a href="'
3535
+                                        . esc_url(get_permalink($course_id))
3536
+                                        . '" title="'.__('Sign Up', 'woothemes-sensei')
3537
+                                        . '">'.__('course', 'woothemes-sensei')
3538 3538
                                     . '</a>';
3539 3539
 
3540
-                    echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3540
+                    echo sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
3541 3541
                     ?>
3542 3542
                 </div>
3543 3543
 
@@ -3555,14 +3555,14 @@  discard block
 block discarded – undo
3555 3555
      *
3556 3556
      * @since 1.9.0
3557 3557
      */
3558
-    public  static function prerequisite_complete_message(){
3558
+    public  static function prerequisite_complete_message() {
3559 3559
 
3560
-        $lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3560
+        $lesson_prerequisite = WooThemes_Sensei_Lesson::get_lesson_prerequisite_id(get_the_ID());
3561 3561
         $lesson_has_pre_requisite = $lesson_prerequisite > 0;
3562
-        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3562
+        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(get_the_ID(), get_current_user_id()) && $lesson_has_pre_requisite) {
3563 3563
 
3564
-            $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>';
3565
-            echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3564
+            $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>';
3565
+            echo sprintf(__('You must first complete %1$s before viewing this Lesson', 'woothemes-sensei'), $prerequisite_lesson_link);
3566 3566
 
3567 3567
         }
3568 3568
 
@@ -3574,7 +3574,7 @@  discard block
 block discarded – undo
3574 3574
      *
3575 3575
      * @deprecated since 1.9.0
3576 3576
      */
3577
-    public static function deprecate_sensei_lesson_archive_header_hook(){
3577
+    public static function deprecate_sensei_lesson_archive_header_hook() {
3578 3578
 
3579 3579
         sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3580 3580
 
@@ -3590,9 +3590,9 @@  discard block
 block discarded – undo
3590 3590
 
3591 3591
         $before_html = '<header class="archive-header"><h1>';
3592 3592
         $after_html = '</h1></header>';
3593
-        $html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3593
+        $html = $before_html.__('Lessons Archive', 'woothemes-sensei').$after_html;
3594 3594
 
3595
-        echo apply_filters( 'sensei_lesson_archive_title', $html );
3595
+        echo apply_filters('sensei_lesson_archive_title', $html);
3596 3596
 
3597 3597
     } // sensei_course_archive_header()
3598 3598
 
@@ -3602,7 +3602,7 @@  discard block
 block discarded – undo
3602 3602
      * @global $post
3603 3603
      * @since 1.9.0
3604 3604
      */
3605
-    public static function the_title(){
3605
+    public static function the_title() {
3606 3606
 
3607 3607
         global $post;
3608 3608
 
@@ -3615,7 +3615,7 @@  discard block
 block discarded – undo
3615 3615
                 /**
3616 3616
                  * Filter documented in class-sensei-messages.php the_title
3617 3617
                  */
3618
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3618
+                echo apply_filters('sensei_single_title', get_the_title($post), $post->post_type);
3619 3619
                 ?>
3620 3620
 
3621 3621
             </h1>
@@ -3633,16 +3633,16 @@  discard block
 block discarded – undo
3633 3633
      *
3634 3634
      * @param $post_id
3635 3635
      */
3636
-    public static function flush_rewrite_rules( $post_id ){
3636
+    public static function flush_rewrite_rules($post_id) {
3637 3637
 
3638
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3638
+        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3639 3639
 
3640 3640
             return;
3641 3641
 
3642 3642
         }
3643 3643
 
3644 3644
 
3645
-        if( 'lesson' == get_post_type( $post_id )  ){
3645
+        if ('lesson' == get_post_type($post_id)) {
3646 3646
 
3647 3647
             Sensei()->initiate_rewrite_rules_flush();
3648 3648
 
@@ -3659,21 +3659,21 @@  discard block
 block discarded – undo
3659 3659
      * @param int $lesson_id
3660 3660
      * @param int $user_id
3661 3661
      */
3662
-    public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3662
+    public static function footer_quiz_call_to_action($lesson_id = 0, $user_id = 0) {
3663 3663
 
3664 3664
 
3665
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3666
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3667
-        $lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3668
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3669
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3670
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3665
+        $lesson_id                 = empty($lesson_id) ? get_the_ID() : $lesson_id;
3666
+        $user_id                   = empty($lesson_id) ? get_current_user_id() : $user_id;
3667
+        $lesson_prerequisite       = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
3668
+        $lesson_course_id          = (int) get_post_meta($lesson_id, '_lesson_course', true);
3669
+        $quiz_id                   = Sensei()->lesson->lesson_quizzes($lesson_id);
3670
+        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id);
3671 3671
         $show_actions              = is_user_logged_in() ? true : false;
3672 3672
 
3673
-        if( intval( $lesson_prerequisite ) > 0 ) {
3673
+        if (intval($lesson_prerequisite) > 0) {
3674 3674
 
3675 3675
             // If the user hasn't completed the prereq then hide the current actions
3676
-            $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3676
+            $show_actions = Sensei_Utils::user_completed_lesson($lesson_prerequisite, $user_id);
3677 3677
 
3678 3678
         }
3679 3679
         ?>
@@ -3681,19 +3681,19 @@  discard block
 block discarded – undo
3681 3681
         <footer>
3682 3682
 
3683 3683
             <?php
3684
-            if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3684
+            if ($show_actions && $quiz_id && Sensei()->access_settings()) {
3685 3685
 
3686
-                $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3687
-                if( $has_quiz_questions ) {
3686
+                $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
3687
+                if ($has_quiz_questions) {
3688 3688
                     ?>
3689 3689
 
3690 3690
                     <p>
3691 3691
 
3692 3692
                         <a class="button"
3693
-                           href="<?php echo esc_url_raw( get_permalink( $quiz_id ) ); ?>"
3694
-                           title="<?php _e( 'View the Lesson Quiz', 'woothemes-sensei'  ); ?>">
3693
+                           href="<?php echo esc_url_raw(get_permalink($quiz_id)); ?>"
3694
+                           title="<?php _e('View the Lesson Quiz', 'woothemes-sensei'); ?>">
3695 3695
 
3696
-                            <?php  _e( 'View the Lesson Quiz', 'woothemes-sensei' ); ?>
3696
+                            <?php  _e('View the Lesson Quiz', 'woothemes-sensei'); ?>
3697 3697
 
3698 3698
                         </a>
3699 3699
 
@@ -3704,11 +3704,11 @@  discard block
 block discarded – undo
3704 3704
 
3705 3705
             } // End If Statement
3706 3706
 
3707
-            if ( $show_actions && ! $has_user_completed_lesson ) {
3707
+            if ($show_actions && ! $has_user_completed_lesson) {
3708 3708
 
3709 3709
                 sensei_complete_lesson_button();
3710 3710
 
3711
-            } elseif( $show_actions ) {
3711
+            } elseif ($show_actions) {
3712 3712
 
3713 3713
                 sensei_reset_lesson_button();
3714 3714
 
@@ -3725,20 +3725,20 @@  discard block
 block discarded – undo
3725 3725
      *
3726 3726
      * @since 1.9.0
3727 3727
      */
3728
-    public static function output_comments(){
3728
+    public static function output_comments() {
3729 3729
 
3730
-        if( ! is_user_logged_in() ){
3730
+        if ( ! is_user_logged_in()) {
3731 3731
             return;
3732 3732
         }
3733 3733
 
3734
-        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3735
-        $course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3736
-        $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3737
-        $user_taking_course = Sensei_Utils::user_started_course($course_id );
3734
+        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete(get_the_ID(), get_current_user_id());
3735
+        $course_id = Sensei()->lesson->get_course_id(get_the_ID());
3736
+        $allow_comments = Sensei()->settings->settings['lesson_comments'];
3737
+        $user_taking_course = Sensei_Utils::user_started_course($course_id);
3738 3738
 
3739
-        $lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3739
+        $lesson_allow_comments = $allow_comments && $pre_requisite_complete && $user_taking_course;
3740 3740
 
3741
-        if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3741
+        if ($lesson_allow_comments || is_singular('sensei_message')) {
3742 3742
 
3743 3743
             comments_template();
3744 3744
 
@@ -3754,26 +3754,26 @@  discard block
 block discarded – undo
3754 3754
      *
3755 3755
      * @since 1.9.0
3756 3756
      */
3757
-    public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3757
+    public static function user_lesson_quiz_status_message($lesson_id = 0, $user_id = 0) {
3758 3758
 
3759
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3760
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3761
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3762
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3763
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3759
+        $lesson_id                 = empty($lesson_id) ? get_the_ID() : $lesson_id;
3760
+        $user_id                   = empty($lesson_id) ? get_current_user_id() : $user_id;
3761
+        $lesson_course_id          = (int) get_post_meta($lesson_id, '_lesson_course', true);
3762
+        $quiz_id                   = Sensei()->lesson->lesson_quizzes($lesson_id);
3763
+        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id);
3764 3764
 
3765 3765
 
3766
-        if ( $quiz_id && is_user_logged_in()
3767
-            && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3766
+        if ($quiz_id && is_user_logged_in()
3767
+            && Sensei_Utils::user_started_course($lesson_course_id, $user_id)) {
3768 3768
 
3769 3769
             $no_quiz_count = 0;
3770
-            $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3770
+            $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
3771 3771
 
3772 3772
             // Display lesson quiz status message
3773
-            if ( $has_user_completed_lesson || $has_quiz_questions ) {
3774
-                $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3775
-                echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3776
-                if( $has_quiz_questions ) {
3773
+            if ($has_user_completed_lesson || $has_quiz_questions) {
3774
+                $status = Sensei_Utils::sensei_user_quiz_status_message($lesson_id, $user_id, true);
3775
+                echo '<div class="sensei-message '.$status['box_class'].'">'.$status['message'].'</div>';
3776
+                if ($has_quiz_questions) {
3777 3777
                    // echo $status['extra'];
3778 3778
                 } // End If Statement
3779 3779
             } // End If Statement
@@ -3789,4 +3789,4 @@  discard block
 block discarded – undo
3789 3789
  * for backward compatibility
3790 3790
  * @since 1.9.0
3791 3791
  */
3792
-class WooThemes_Sensei_Lesson extends Sensei_Lesson{}
3792
+class WooThemes_Sensei_Lesson extends Sensei_Lesson {}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2898,7 +2898,7 @@
 block discarded – undo
2898 2898
      * @access public
2899 2899
      *
2900 2900
      * @param int $lesson_id
2901
-     * @return int|bool $course_id or bool when nothing is found.
2901
+     * @return integer $course_id or bool when nothing is found.
2902 2902
      */
2903 2903
      public function get_course_id( $lesson_id ){
2904 2904
 
Please login to merge, or discard this patch.
Indentation   +1027 added lines, -1027 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', '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' ) );
@@ -2029,12 +2029,12 @@  discard block
 block discarded – undo
2029 2029
 
2030 2030
 					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2031 2031
 					if( ! in_array( $quiz_id, $quizzes ) ) {
2032
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2032
+						add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2033 2033
 						$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2034 2034
 						update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2035
-			    	}
2035
+					}
2036 2036
 
2037
-			    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2037
+					add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2038 2038
 					$question_type = Sensei()->question->get_question_type( $question_id );
2039 2039
 
2040 2040
 					$return .= $this->quiz_panel_question( $question_type, $question_count, $question_id );
@@ -2140,34 +2140,34 @@  discard block
 block discarded – undo
2140 2140
 		$post_content = $course_content;
2141 2141
 		// Course Query Arguments
2142 2142
 		$post_type_args = array(	'post_content' => $post_content,
2143
-  		    						'post_status' => $post_status,
2144
-  		    						'post_title' => $post_title,
2145
-  		    						'post_type' => $post_type
2146
-  		    						);
2143
+  									'post_status' => $post_status,
2144
+  									'post_title' => $post_title,
2145
+  									'post_type' => $post_type
2146
+  									);
2147 2147
   		// Only save if there is a valid title
2148 2148
   		if ( $post_title != '' ) {
2149
-  		    // Check for prerequisite courses & product id
2150
-  		    $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2151
-  		    $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2152
-  		    $course_category_id = absint( $data[ 'course_category' ] );
2153
-  		    if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2154
-  		    // Insert or Update the Lesson Quiz
2155
-		    if ( 0 < $course_id ) {
2156
-		    	$post_type_args[ 'ID' ] = $course_id;
2157
-		    	$course_id = wp_update_post($post_type_args);
2158
-		    	update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2159
-		    	update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2160
-		    	if ( 0 < $course_category_id ) {
2161
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2162
-		    	} // End If Statement
2163
-		    } else {
2164
-		    	$course_id = wp_insert_post($post_type_args);
2165
-		    	add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2166
-		    	add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2167
-		    	if ( 0 < $course_category_id ) {
2168
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2169
-		    	} // End If Statement
2170
-		    } // End If Statement
2149
+  			// Check for prerequisite courses & product id
2150
+  			$course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2151
+  			$course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2152
+  			$course_category_id = absint( $data[ 'course_category' ] );
2153
+  			if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2154
+  			// Insert or Update the Lesson Quiz
2155
+			if ( 0 < $course_id ) {
2156
+				$post_type_args[ 'ID' ] = $course_id;
2157
+				$course_id = wp_update_post($post_type_args);
2158
+				update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2159
+				update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2160
+				if ( 0 < $course_category_id ) {
2161
+					wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2162
+				} // End If Statement
2163
+			} else {
2164
+				$course_id = wp_insert_post($post_type_args);
2165
+				add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2166
+				add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2167
+				if ( 0 < $course_category_id ) {
2168
+					wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2169
+				} // End If Statement
2170
+			} // End If Statement
2171 2171
 		} // End If Statement
2172 2172
   		// Check that the insert or update saved by testing the post id
2173 2173
   		if ( 0 < $course_id ) {
@@ -2258,17 +2258,17 @@  discard block
 block discarded – undo
2258 2258
 		$answer_feedback = '';
2259 2259
 		if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) {
2260 2260
 
2261
-            $answer_feedback = $data[ 'answer_feedback_boolean' ];
2261
+			$answer_feedback = $data[ 'answer_feedback_boolean' ];
2262 2262
 
2263 2263
 		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2264 2264
 
2265
-            $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2265
+			$answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2266 2266
 
2267
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2267
+		}elseif( isset( $data[ 'answer_feedback' ] )  ){
2268 2268
 
2269
-            $answer_feedback = $data[ 'answer_feedback' ];
2269
+			$answer_feedback = $data[ 'answer_feedback' ];
2270 2270
 
2271
-        } // End If Statement
2271
+		} // End If Statement
2272 2272
 
2273 2273
 		$post_title = $question_text;
2274 2274
 		$post_author = $data[ 'post_author' ];
@@ -2283,10 +2283,10 @@  discard block
 block discarded – undo
2283 2283
 		}
2284 2284
 		// Question Query Arguments
2285 2285
 		$post_type_args = array(	'post_content' => $post_content,
2286
-  		    						'post_status' => $post_status,
2287
-  		    						'post_title' => $post_title,
2288
-  		    						'post_type' => $post_type
2289
-  		    						);
2286
+  									'post_status' => $post_status,
2287
+  									'post_title' => $post_title,
2288
+  									'post_type' => $post_type
2289
+  									);
2290 2290
 
2291 2291
   		// Remove empty values and reindex the array
2292 2292
   		if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) {
@@ -2322,14 +2322,14 @@  discard block
 block discarded – undo
2322 2322
   		if ( $post_title != '' ) {
2323 2323
 
2324 2324
   			// Get Quiz ID for the question
2325
-  		    $quiz_id = $data['quiz_id'];
2325
+  			$quiz_id = $data['quiz_id'];
2326 2326
 
2327
-  		    // Get question media
2327
+  			// Get question media
2328 2328
 			$question_media = $data['question_media'];
2329 2329
 
2330
-  		    // Get answer order
2331
-  		    $answer_order = '';
2332
-  		    if( isset( $data['answer_order'] ) ) {
2330
+  			// Get answer order
2331
+  			$answer_order = '';
2332
+  			if( isset( $data['answer_order'] ) ) {
2333 2333
 				$answer_order = $data['answer_order'];
2334 2334
 			}
2335 2335
 
@@ -2339,38 +2339,38 @@  discard block
 block discarded – undo
2339 2339
 				$random_order = $data['random_order'];
2340 2340
 			}
2341 2341
 
2342
-  		    // Insert or Update the question
2343
-  		    if ( 0 < $question_id ) {
2344
-
2345
-  		    	$post_type_args[ 'ID' ] = $question_id;
2346
-		    	$question_id = wp_update_post( $post_type_args );
2347
-
2348
-		    	// Update poast meta
2349
-		    	if( 'quiz' == $context ) {
2350
-		    		$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2351
-		    		if( ! in_array( $quiz_id, $quizzes ) ) {
2352
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2353
-			    	}
2354
-		    	}
2355
-
2356
-		    	update_post_meta( $question_id, '_question_grade', $question_grade );
2357
-		    	update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2358
-		    	update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2359
-		    	update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2360
-		    	update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2361
-		    	update_post_meta( $question_id, '_question_media', $question_media );
2362
-		    	update_post_meta( $question_id, '_answer_order', $answer_order );
2363
-		    	update_post_meta( $question_id, '_random_order', $random_order );
2364
-
2365
-		    	if( 'quiz' != $context ) {
2366
-		    		wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2367
-		    	}
2342
+  			// Insert or Update the question
2343
+  			if ( 0 < $question_id ) {
2344
+
2345
+  				$post_type_args[ 'ID' ] = $question_id;
2346
+				$question_id = wp_update_post( $post_type_args );
2347
+
2348
+				// Update poast meta
2349
+				if( 'quiz' == $context ) {
2350
+					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2351
+					if( ! in_array( $quiz_id, $quizzes ) ) {
2352
+						add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2353
+					}
2354
+				}
2355
+
2356
+				update_post_meta( $question_id, '_question_grade', $question_grade );
2357
+				update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2358
+				update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2359
+				update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2360
+				update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2361
+				update_post_meta( $question_id, '_question_media', $question_media );
2362
+				update_post_meta( $question_id, '_answer_order', $answer_order );
2363
+				update_post_meta( $question_id, '_random_order', $random_order );
2364
+
2365
+				if( 'quiz' != $context ) {
2366
+					wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2367
+				}
2368 2368
 				// Don't store empty value, no point
2369 2369
 				if ( !empty($answer_feedback) ) {
2370 2370
 					update_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2371 2371
 				}
2372 2372
 
2373
-		    } else {
2373
+			} else {
2374 2374
 				$question_id = wp_insert_post( $post_type_args );
2375 2375
 				$question_count = intval( $data['question_count'] );
2376 2376
 				++$question_count;
@@ -2383,29 +2383,29 @@  discard block
 block discarded – undo
2383 2383
 				}
2384 2384
 
2385 2385
 				if( isset( $question_grade ) ) {
2386
-		    		add_post_meta( $question_id, '_question_grade', $question_grade );
2387
-		    	}
2388
-		    	add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2389
-		    	add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2390
-		    	add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2391
-		    	add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2392
-		    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2393
-		    	add_post_meta( $question_id, '_question_media', $question_media );
2394
-		    	add_post_meta( $question_id, '_answer_order', $answer_order );
2395
-		    	add_post_meta( $question_id, '_random_order', $random_order );
2386
+					add_post_meta( $question_id, '_question_grade', $question_grade );
2387
+				}
2388
+				add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2389
+				add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2390
+				add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2391
+				add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2392
+				add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2393
+				add_post_meta( $question_id, '_question_media', $question_media );
2394
+				add_post_meta( $question_id, '_answer_order', $answer_order );
2395
+				add_post_meta( $question_id, '_random_order', $random_order );
2396 2396
 				// Don't store empty value, no point
2397 2397
 				if ( !empty($answer_feedback) ) {
2398 2398
 					add_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2399 2399
 				}
2400 2400
 
2401
-		    	// Set the post terms for question-type
2402
-			    wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2401
+				// Set the post terms for question-type
2402
+				wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2403 2403
 
2404
-			    if( $question_category ) {
2405
-	    			wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2406
-	    		}
2404
+				if( $question_category ) {
2405
+					wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2406
+				}
2407 2407
 
2408
-		    } // End If Statement
2408
+			} // End If Statement
2409 2409
 		} // End If Statement
2410 2410
   		// Check that the insert or update saved by testing the post id
2411 2411
   		if ( 0 < $question_id ) {
@@ -2454,7 +2454,7 @@  discard block
 block discarded – undo
2454 2454
 	public function lesson_complexities() {
2455 2455
 
2456 2456
 		// V2 - make filter for this array
2457
-        $lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2457
+		$lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2458 2458
 									'std' => __( 'Standard', 'woothemes-sensei' ),
2459 2459
 									'hard' => __( 'Hard', 'woothemes-sensei' )
2460 2460
 									);
@@ -2521,14 +2521,14 @@  discard block
 block discarded – undo
2521 2521
 		$post_args = array(	'post_type' 		=> 'quiz',
2522 2522
 							'posts_per_page' 		=> 1,
2523 2523
 							'orderby'         	=> 'title',
2524
-    						'order'           	=> 'DESC',
2525
-    						'post_parent'      	=> $lesson_id,
2526
-    						'post_status'		=> $post_status,
2524
+							'order'           	=> 'DESC',
2525
+							'post_parent'      	=> $lesson_id,
2526
+							'post_status'		=> $post_status,
2527 2527
 							'suppress_filters' 	=> 0,
2528 2528
 							'fields'            => $fields
2529 2529
 							);
2530 2530
 		$posts_array = get_posts( $post_args );
2531
-        $quiz_id = array_shift($posts_array);
2531
+		$quiz_id = array_shift($posts_array);
2532 2532
 
2533 2533
 		return $quiz_id;
2534 2534
 	} // End lesson_quizzes()
@@ -2536,34 +2536,34 @@  discard block
 block discarded – undo
2536 2536
 
2537 2537
 	/**
2538 2538
 	 * Fetches all the questions for a quiz depending on certain conditions.
2539
-     *
2540
-     * Determine which questions should be shown depending on:
2541
-     * - admin/teacher selected questions to be shown
2542
-     * - questions shown to a user previously (saved as asked questions)
2543
-     * - limit number of questions lesson setting
2544 2539
 	 *
2545
-     * @since 1.0
2540
+	 * Determine which questions should be shown depending on:
2541
+	 * - admin/teacher selected questions to be shown
2542
+	 * - questions shown to a user previously (saved as asked questions)
2543
+	 * - limit number of questions lesson setting
2544
+	 *
2545
+	 * @since 1.0
2546 2546
 	 * @param int $quiz_id (default: 0)
2547 2547
 	 * @param string $post_status (default: 'publish')
2548 2548
 	 * @param string $orderby (default: 'meta_value_num title')
2549 2549
 	 * @param string $order (default: 'ASC')
2550
-     *
2550
+	 *
2551 2551
 	 * @return array $questions { $question type WP_Post }
2552 2552
 	 */
2553 2553
 	public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) {
2554 2554
 
2555 2555
 		$quiz_id = (string) $quiz_id;
2556
-        $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2556
+		$quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2557 2557
 
2558
-        // setup the user id
2559
-        if( is_admin() ) {
2560
-            $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2561
-        } else {
2562
-            $user_id = get_current_user_id();
2563
-        }
2558
+		// setup the user id
2559
+		if( is_admin() ) {
2560
+			$user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2561
+		} else {
2562
+			$user_id = get_current_user_id();
2563
+		}
2564 2564
 
2565
-        // get the users current status on the lesson
2566
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2565
+		// get the users current status on the lesson
2566
+		$user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2567 2567
 
2568 2568
 		// Set the default question order if it has not already been set for this quiz
2569 2569
 		$this->set_default_question_order( $quiz_id );
@@ -2593,14 +2593,14 @@  discard block
 block discarded – undo
2593 2593
 			'suppress_filters' 	=> 0
2594 2594
 		);
2595 2595
 
2596
-        //query the questions
2596
+		//query the questions
2597 2597
 		$questions_query = new WP_Query( $question_query_args );
2598 2598
 
2599
-        // Set return array to initially include all items
2600
-        $questions = $questions_query->posts;
2599
+		// Set return array to initially include all items
2600
+		$questions = $questions_query->posts;
2601 2601
 
2602
-        // set the questions array that will be manipulated within this function
2603
-        $questions_array = $questions_query->posts;
2602
+		// set the questions array that will be manipulated within this function
2603
+		$questions_array = $questions_query->posts;
2604 2604
 
2605 2605
 		// If viewing quiz on frontend or in grading then only single questions must be shown
2606 2606
 		$selected_questions = false;
@@ -2713,36 +2713,36 @@  discard block
 block discarded – undo
2713 2713
 			}
2714 2714
 		}
2715 2715
 
2716
-        // Save the questions that will be asked for the current user
2717
-        // this happens only once per user/quiz, unless the user resets the quiz
2718
-        if( ! is_admin() ){
2716
+		// Save the questions that will be asked for the current user
2717
+		// this happens only once per user/quiz, unless the user resets the quiz
2718
+		if( ! is_admin() ){
2719 2719
 
2720
-            if( $user_lesson_status ) {
2720
+			if( $user_lesson_status ) {
2721 2721
 
2722
-                $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2723
-                if ( empty($questions_asked) && $user_lesson_status) {
2722
+				$questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2723
+				if ( empty($questions_asked) && $user_lesson_status) {
2724 2724
 
2725
-                    $questions_asked = array();
2726
-                    foreach ($questions as $question) {
2725
+					$questions_asked = array();
2726
+					foreach ($questions as $question) {
2727 2727
 
2728
-                        $questions_asked[] = $question->ID;
2728
+						$questions_asked[] = $question->ID;
2729 2729
 
2730
-                    }
2730
+					}
2731 2731
 
2732
-                    // save the questions asked id
2733
-                    $questions_asked_csv = implode(',', $questions_asked);
2734
-                    update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv);
2732
+					// save the questions asked id
2733
+					$questions_asked_csv = implode(',', $questions_asked);
2734
+					update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv);
2735 2735
 
2736
-                }
2737
-            }
2738
-        }
2736
+				}
2737
+			}
2738
+		}
2739 2739
 
2740
-        /**
2741
-         * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions
2742
-         *
2743
-         * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2744
-         * @since 1.8.0
2745
-         */
2740
+		/**
2741
+		 * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions
2742
+		 *
2743
+		 * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2744
+		 * @since 1.8.0
2745
+		 */
2746 2746
 		return apply_filters( 'sensei_lesson_quiz_questions', $questions,  $quiz_id  );
2747 2747
 
2748 2748
 	} // End lesson_quiz_questions()
@@ -2846,7 +2846,7 @@  discard block
 block discarded – undo
2846 2846
  			// Display Image Placeholder if none
2847 2847
 			if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) {
2848 2848
 
2849
-                $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2849
+				$img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2850 2850
 
2851 2851
 			} // End If Statement
2852 2852
 
@@ -2858,417 +2858,417 @@  discard block
 block discarded – undo
2858 2858
 
2859 2859
 	} // End lesson_image()
2860 2860
 
2861
-    /**
2862
-     * Ooutpu the lesson image
2863
-     *
2864
-     * @since 1.9.0
2865
-     * @param integer $lesson_id
2866
-     */
2867
-    public static function the_lesson_image( $lesson_id = 0 ){
2861
+	/**
2862
+	 * Ooutpu the lesson image
2863
+	 *
2864
+	 * @since 1.9.0
2865
+	 * @param integer $lesson_id
2866
+	 */
2867
+	public static function the_lesson_image( $lesson_id = 0 ){
2868 2868
 
2869
-        echo Sensei()->lesson->lesson_image( $lesson_id );
2869
+		echo Sensei()->lesson->lesson_image( $lesson_id );
2870 2870
 
2871
-    }
2871
+	}
2872 2872
 
2873 2873
 	/**
2874 2874
 	 * Returns the the lesson excerpt.
2875 2875
 	 *
2876 2876
 	 * @param WP_Post $lesson
2877
-     * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2877
+	 * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2878 2878
 	 * @return string
2879 2879
 	 */
2880 2880
 	public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) {
2881 2881
 		$html = '';
2882 2882
 		if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) {
2883 2883
 
2884
-            $excerpt =  $lesson->post_excerpt;
2884
+			$excerpt =  $lesson->post_excerpt;
2885 2885
 
2886
-            // if $add_p_tags true wrap with <p> else return the excerpt as is
2887
-            $html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2886
+			// if $add_p_tags true wrap with <p> else return the excerpt as is
2887
+			$html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2888 2888
 
2889 2889
 		}
2890 2890
 		return apply_filters( 'sensei_lesson_excerpt', $html );
2891 2891
 
2892 2892
 	} // End lesson_excerpt()
2893 2893
 
2894
-    /**
2895
-     * Returns the course for a given lesson
2896
-     *
2897
-     * @since 1.7.4
2898
-     * @access public
2899
-     *
2900
-     * @param int $lesson_id
2901
-     * @return int|bool $course_id or bool when nothing is found.
2902
-     */
2903
-     public function get_course_id( $lesson_id ){
2904
-
2905
-         if( ! isset( $lesson_id ) || empty( $lesson_id )
2906
-         ||  'lesson' != get_post_type( $lesson_id ) ){
2907
-             return false;
2908
-         }
2909
-
2910
-         $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2911
-
2912
-         // make sure the course id is valid
2913
-         if( empty( $lesson_course_id )
2914
-             || is_array( $lesson_course_id )
2915
-             || intval( $lesson_course_id ) < 1
2916
-             || 'course' != get_post_type( $lesson_course_id ) ){
2917
-
2918
-             return false;
2919
-
2920
-         }
2921
-
2922
-         return $lesson_course_id;
2923
-
2924
-     }// en get_course_id
2925
-
2926
-    /**
2927
-     * Add the admin all lessons screen edit options.
2928
-     *
2929
-     * The fields in this function work for both quick and bulk edit. The ID attributes is used
2930
-     * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then
2931
-     * name attribute is will be used by the quick edit and submitted via standard POST. This
2932
-     * will use this classes save_post_meta function to save the new field data.
2933
-     *
2934
-     * @hooked quick_edit_custom_box
2935
-     * @hooked bulk_edit_custom_box
2936
-     *
2937
-     * @since 1.8.0
2938
-     *
2939
-     * @param string $column_name
2940
-     * @param string $post_type
2941
-     * @return void
2942
-     */
2943
-    public function all_lessons_edit_fields( $column_name, $post_type ) {
2944
-
2945
-        // only show these options ont he lesson post type edit screen
2946
-        if( 'lesson' != $post_type || 'lesson-course' != $column_name ){
2947
-            return;
2948
-        }
2949
-
2950
-        ?>
2894
+	/**
2895
+	 * Returns the course for a given lesson
2896
+	 *
2897
+	 * @since 1.7.4
2898
+	 * @access public
2899
+	 *
2900
+	 * @param int $lesson_id
2901
+	 * @return int|bool $course_id or bool when nothing is found.
2902
+	 */
2903
+	 public function get_course_id( $lesson_id ){
2904
+
2905
+		 if( ! isset( $lesson_id ) || empty( $lesson_id )
2906
+		 ||  'lesson' != get_post_type( $lesson_id ) ){
2907
+			 return false;
2908
+		 }
2909
+
2910
+		 $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2911
+
2912
+		 // make sure the course id is valid
2913
+		 if( empty( $lesson_course_id )
2914
+			 || is_array( $lesson_course_id )
2915
+			 || intval( $lesson_course_id ) < 1
2916
+			 || 'course' != get_post_type( $lesson_course_id ) ){
2917
+
2918
+			 return false;
2919
+
2920
+		 }
2921
+
2922
+		 return $lesson_course_id;
2923
+
2924
+	 }// en get_course_id
2925
+
2926
+	/**
2927
+	 * Add the admin all lessons screen edit options.
2928
+	 *
2929
+	 * The fields in this function work for both quick and bulk edit. The ID attributes is used
2930
+	 * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then
2931
+	 * name attribute is will be used by the quick edit and submitted via standard POST. This
2932
+	 * will use this classes save_post_meta function to save the new field data.
2933
+	 *
2934
+	 * @hooked quick_edit_custom_box
2935
+	 * @hooked bulk_edit_custom_box
2936
+	 *
2937
+	 * @since 1.8.0
2938
+	 *
2939
+	 * @param string $column_name
2940
+	 * @param string $post_type
2941
+	 * @return void
2942
+	 */
2943
+	public function all_lessons_edit_fields( $column_name, $post_type ) {
2944
+
2945
+		// only show these options ont he lesson post type edit screen
2946
+		if( 'lesson' != $post_type || 'lesson-course' != $column_name ){
2947
+			return;
2948
+		}
2949
+
2950
+		?>
2951 2951
         <fieldset class="sensei-edit-field-set inline-edit-lesson">
2952 2952
             <div class="sensei-inline-edit-col column-<?php echo $column_name ?>">
2953 2953
                     <?php
2954
-                    echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2955
-                    // create a nonce field to be  used as a security measure when saving the data
2956
-                    wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2957
-                    wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2958
-
2959
-                    // unchanged option - we need this in because
2960
-                    // the default option in bulk edit should not be empty. If it is
2961
-                    // the user will erase data they didn't want to touch.
2962
-                    $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2963
-
2964
-                    //
2965
-                    //course selection
2966
-                    //
2967
-                    $courses =  WooThemes_Sensei_Course::get_all_courses();
2968
-                    $course_options = array();
2969
-                    if ( count( $courses ) > 0 ) {
2970
-                        foreach ($courses as $course ){
2971
-                            $course_options[ $course->ID ] = get_the_title( $course->ID );
2972
-                        }
2973
-                    }
2974
-                    //pre-append the no change option
2975
-                    $course_options['-1']=  $no_change_text;
2976
-                    $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2977
-                    $course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
2978
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
2979
-
2980
-                    //
2981
-                    // lesson complexity selection
2982
-                    //
2983
-                    $lesson_complexities =  $this->lesson_complexities();
2984
-                    //pre-append the no change option
2985
-                    $lesson_complexities['-1']=  $no_change_text;
2986
-                    $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
2987
-                    $complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
2988
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
2989
-
2990
-                    ?>
2954
+					echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2955
+					// create a nonce field to be  used as a security measure when saving the data
2956
+					wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2957
+					wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2958
+
2959
+					// unchanged option - we need this in because
2960
+					// the default option in bulk edit should not be empty. If it is
2961
+					// the user will erase data they didn't want to touch.
2962
+					$no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2963
+
2964
+					//
2965
+					//course selection
2966
+					//
2967
+					$courses =  WooThemes_Sensei_Course::get_all_courses();
2968
+					$course_options = array();
2969
+					if ( count( $courses ) > 0 ) {
2970
+						foreach ($courses as $course ){
2971
+							$course_options[ $course->ID ] = get_the_title( $course->ID );
2972
+						}
2973
+					}
2974
+					//pre-append the no change option
2975
+					$course_options['-1']=  $no_change_text;
2976
+					$course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2977
+					$course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
2978
+					echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
2979
+
2980
+					//
2981
+					// lesson complexity selection
2982
+					//
2983
+					$lesson_complexities =  $this->lesson_complexities();
2984
+					//pre-append the no change option
2985
+					$lesson_complexities['-1']=  $no_change_text;
2986
+					$complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
2987
+					$complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
2988
+					echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
2989
+
2990
+					?>
2991 2991
 
2992 2992
                     <h4><?php _e('Quiz Settings', 'woothemes-sensei'); ?> </h4>
2993 2993
 
2994 2994
                     <?php
2995 2995
 
2996
-                    //
2997
-                    // Lesson require pass to complete
2998
-                    //
2999
-                    $pass_required_options = array(
3000
-                        '-1' => $no_change_text,
3001
-                         '0' => __('No','woothemes'),
3002
-                         '1' => __('Yes','woothemes'),
3003
-                    );
3004
-
3005
-                    $pass_required_select_attributes = array( 'name'=> 'pass_required',
3006
-                                                                'id'=> 'sensei-edit-lesson-pass-required',
3007
-                                                                'class'=>' '   );
3008
-                    $require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3009
-                    echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3010
-
3011
-                    //
3012
-                    // Quiz pass percentage
3013
-                    //
3014
-                    $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3015
-                    echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3016
-
3017
-                    //
3018
-                    // Enable quiz reset button
3019
-                    //
3020
-                    $quiz_reset_select__options = array(
3021
-                        '-1' => $no_change_text,
3022
-                        '0' => __('No','woothemes'),
3023
-                        '1' => __('Yes','woothemes'),
3024
-                    );
3025
-                    $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3026
-                    $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3027
-                    $quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3028
-                    echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3029
-
3030
-                    ?>
2996
+					//
2997
+					// Lesson require pass to complete
2998
+					//
2999
+					$pass_required_options = array(
3000
+						'-1' => $no_change_text,
3001
+						 '0' => __('No','woothemes'),
3002
+						 '1' => __('Yes','woothemes'),
3003
+					);
3004
+
3005
+					$pass_required_select_attributes = array( 'name'=> 'pass_required',
3006
+																'id'=> 'sensei-edit-lesson-pass-required',
3007
+																'class'=>' '   );
3008
+					$require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3009
+					echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3010
+
3011
+					//
3012
+					// Quiz pass percentage
3013
+					//
3014
+					$quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3015
+					echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3016
+
3017
+					//
3018
+					// Enable quiz reset button
3019
+					//
3020
+					$quiz_reset_select__options = array(
3021
+						'-1' => $no_change_text,
3022
+						'0' => __('No','woothemes'),
3023
+						'1' => __('Yes','woothemes'),
3024
+					);
3025
+					$quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3026
+					$quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3027
+					$quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3028
+					echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3029
+
3030
+					?>
3031 3031
             </div>
3032 3032
         </fieldset>
3033 3033
     <?php
3034
-    }// all_lessons_edit_fields
3035
-
3036
-    /**
3037
-     * Create the html for the edit field
3038
-     *
3039
-     * Wraps the passed in field and title combination with the correct html.
3040
-     *
3041
-     * @since 1.8.0
3042
-     *
3043
-     * @param string $title that will stand to the left of the field.
3044
-     * @param string $field type markup for the field that must be wrapped.
3045
-     * @return string $field_html
3046
-     */
3047
-    public function generate_all_lessons_edit_field( $title  ,$field ){
3048
-
3049
-        $html = '';
3050
-        $html = '<div class="inline-edit-group" >';
3051
-        $html .=  '<span class="title">'. $title .'</span> ';
3052
-        $html .= '<span class="input-text-wrap">';
3053
-        $html .= $field;
3054
-        $html .= '</span>';
3055
-        $html .= '</label></div>';
3056
-
3057
-        return $html ;
3058
-
3059
-    }//end generate_all_lessons_edit_field
3060
-
3061
-    /**
3062
-     * Respond to the ajax call from the bulk edit save function. This comes
3063
-     * from the admin all lesson screen.
3064
-     *
3065
-     * @since 1.8.0
3066
-     * @return void
3067
-     */
3068
-    function save_all_lessons_edit_fields() {
3069
-
3070
-        // verify all the data before attempting to save
3071
-        if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3072
-            ||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3073
-            die();
3074
-        }
3075
-
3076
-        // get our variables
3077
-        $new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3078
-        $new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3079
-        $new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3080
-        $new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3081
-        $new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3082
-        // store the values for all selected posts
3083
-        foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3084
-
3085
-            // get the quiz id needed for the quiz meta
3086
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3087
-
3088
-            // do not save the items if the value is -1 as this
3089
-            // means it was not changed
3090
-
3091
-            // update lesson course
3092
-            if( -1 != $new_course ){
3093
-                update_post_meta( $lesson_id, '_lesson_course', $new_course );
3094
-            }
3095
-            // update lesson complexity
3096
-            if( -1 != $new_complexity ){
3097
-                update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3098
-            }
3099
-
3100
-            // Quiz Related settings
3101
-            if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3102
-
3103
-                // update pass required
3104
-                if (-1 != $new_pass_required) {
3105
-
3106
-                    $checked = $new_pass_required  ? 'on' : '';
3107
-                    update_post_meta($quiz_id, '_pass_required', $checked);
3108
-                    unset( $checked );
3109
-                }
3034
+	}// all_lessons_edit_fields
3110 3035
 
3111
-                // update pass percentage
3112
-                if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3036
+	/**
3037
+	 * Create the html for the edit field
3038
+	 *
3039
+	 * Wraps the passed in field and title combination with the correct html.
3040
+	 *
3041
+	 * @since 1.8.0
3042
+	 *
3043
+	 * @param string $title that will stand to the left of the field.
3044
+	 * @param string $field type markup for the field that must be wrapped.
3045
+	 * @return string $field_html
3046
+	 */
3047
+	public function generate_all_lessons_edit_field( $title  ,$field ){
3113 3048
 
3114
-                        update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3049
+		$html = '';
3050
+		$html = '<div class="inline-edit-group" >';
3051
+		$html .=  '<span class="title">'. $title .'</span> ';
3052
+		$html .= '<span class="input-text-wrap">';
3053
+		$html .= $field;
3054
+		$html .= '</span>';
3055
+		$html .= '</label></div>';
3115 3056
 
3116
-                }
3057
+		return $html ;
3117 3058
 
3118
-                //
3119
-                // update enable quiz reset
3120
-                //
3121
-                if (-1 != $new_enable_quiz_reset ) {
3059
+	}//end generate_all_lessons_edit_field
3122 3060
 
3123
-                    $checked = $new_enable_quiz_reset ? 'on' : ''  ;
3124
-                    update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3125
-                    unset( $checked );
3061
+	/**
3062
+	 * Respond to the ajax call from the bulk edit save function. This comes
3063
+	 * from the admin all lesson screen.
3064
+	 *
3065
+	 * @since 1.8.0
3066
+	 * @return void
3067
+	 */
3068
+	function save_all_lessons_edit_fields() {
3126 3069
 
3127
-                }
3070
+		// verify all the data before attempting to save
3071
+		if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3072
+			||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3073
+			die();
3074
+		}
3128 3075
 
3076
+		// get our variables
3077
+		$new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3078
+		$new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3079
+		$new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3080
+		$new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3081
+		$new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3082
+		// store the values for all selected posts
3083
+		foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3129 3084
 
3130
-            } // end if quiz
3085
+			// get the quiz id needed for the quiz meta
3086
+			$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3131 3087
 
3132
-        }// end for each
3088
+			// do not save the items if the value is -1 as this
3089
+			// means it was not changed
3133 3090
 
3134
-        die();
3091
+			// update lesson course
3092
+			if( -1 != $new_course ){
3093
+				update_post_meta( $lesson_id, '_lesson_course', $new_course );
3094
+			}
3095
+			// update lesson complexity
3096
+			if( -1 != $new_complexity ){
3097
+				update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3098
+			}
3135 3099
 
3136
-    } // end save_all_lessons_edit_fields
3100
+			// Quiz Related settings
3101
+			if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3137 3102
 
3138
-    /**
3139
-     * Loading the quick edit fields defaults.
3140
-     *
3141
-     * This function will localise the default values along with the script that will
3142
-     * add these values to the inputs.
3143
-     *
3144
-     * NOTE: this function runs for each row in the edit column
3145
-     *
3146
-     * @since 1.8.0
3147
-     * @return void
3148
-     */
3149
-    public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3103
+				// update pass required
3104
+				if (-1 != $new_pass_required) {
3150 3105
 
3151
-        if( 'lesson-course' != $column_name ){
3152
-            return;
3153
-        }
3154
-        // load the script
3155
-        $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3156
-        wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3106
+					$checked = $new_pass_required  ? 'on' : '';
3107
+					update_post_meta($quiz_id, '_pass_required', $checked);
3108
+					unset( $checked );
3109
+				}
3157 3110
 
3158
-        // setup the values for all meta fields
3159
-        $data = array();
3160
-        foreach( $this->meta_fields as $field ){
3111
+				// update pass percentage
3112
+				if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3161 3113
 
3162
-            $data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3114
+						update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3163 3115
 
3164
-        }
3165
-        // add quiz meta fields
3166
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3167
-        foreach( Sensei()->quiz->meta_fields as $field ){
3116
+				}
3168 3117
 
3169
-            $data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3118
+				//
3119
+				// update enable quiz reset
3120
+				//
3121
+				if (-1 != $new_enable_quiz_reset ) {
3170 3122
 
3171
-        }
3123
+					$checked = $new_enable_quiz_reset ? 'on' : ''  ;
3124
+					update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3125
+					unset( $checked );
3172 3126
 
3173
-        wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3127
+				}
3174 3128
 
3175
-    }// end quick edit admin defaults
3176 3129
 
3177
-    /**
3178
-     * Filter the classes for lessons on the single course page.
3179
-     *
3180
-     * Adds the nesecary classes depending on the user data
3181
-     *
3182
-     * @since 1.9.0
3183
-     * @param array $classes
3184
-     * @return array $classes
3185
-     */
3186
-    public static function single_course_lessons_classes( $classes ){
3130
+			} // end if quiz
3187 3131
 
3188
-        if(  is_singular('course') ){
3132
+		}// end for each
3189 3133
 
3190
-            global $post;
3191
-            $course_id = $post->ID;
3134
+		die();
3192 3135
 
3193
-            $lesson_classes = array( 'course', 'post' );
3194
-            if ( is_user_logged_in() ) {
3136
+	} // end save_all_lessons_edit_fields
3195 3137
 
3196
-                // Check if Lesson is complete
3197
-                $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3198
-                if ( $single_lesson_complete ) {
3138
+	/**
3139
+	 * Loading the quick edit fields defaults.
3140
+	 *
3141
+	 * This function will localise the default values along with the script that will
3142
+	 * add these values to the inputs.
3143
+	 *
3144
+	 * NOTE: this function runs for each row in the edit column
3145
+	 *
3146
+	 * @since 1.8.0
3147
+	 * @return void
3148
+	 */
3149
+	public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3199 3150
 
3200
-                    $lesson_classes[] = 'lesson-completed';
3151
+		if( 'lesson-course' != $column_name ){
3152
+			return;
3153
+		}
3154
+		// load the script
3155
+		$suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3156
+		wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3201 3157
 
3202
-                } // End If Statement
3158
+		// setup the values for all meta fields
3159
+		$data = array();
3160
+		foreach( $this->meta_fields as $field ){
3203 3161
 
3204
-            } // End If Statement
3162
+			$data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3205 3163
 
3206
-            $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3207
-            if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3164
+		}
3165
+		// add quiz meta fields
3166
+		$quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3167
+		foreach( Sensei()->quiz->meta_fields as $field ){
3208 3168
 
3209
-                $lesson_classes[] = 'lesson-preview';
3169
+			$data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3210 3170
 
3211
-            }
3171
+		}
3172
+
3173
+		wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3174
+
3175
+	}// end quick edit admin defaults
3176
+
3177
+	/**
3178
+	 * Filter the classes for lessons on the single course page.
3179
+	 *
3180
+	 * Adds the nesecary classes depending on the user data
3181
+	 *
3182
+	 * @since 1.9.0
3183
+	 * @param array $classes
3184
+	 * @return array $classes
3185
+	 */
3186
+	public static function single_course_lessons_classes( $classes ){
3212 3187
 
3213
-            $classes = array_merge( $classes, $lesson_classes  );
3188
+		if(  is_singular('course') ){
3214 3189
 
3215
-        }
3190
+			global $post;
3191
+			$course_id = $post->ID;
3216 3192
 
3217
-        return $classes;
3193
+			$lesson_classes = array( 'course', 'post' );
3194
+			if ( is_user_logged_in() ) {
3218 3195
 
3219
-    }// end single_course_lessons_classes
3196
+				// Check if Lesson is complete
3197
+				$single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3198
+				if ( $single_lesson_complete ) {
3220 3199
 
3221
-    /**
3222
-     * Output the lesson meta for the given lesson
3223
-     *
3224
-     * @since 1.9.0
3225
-     * @param $lesson_id
3226
-     */
3227
-    public static function the_lesson_meta( $lesson_id ){
3200
+					$lesson_classes[] = 'lesson-completed';
3228 3201
 
3229
-        global $wp_query;
3230
-        $loop_lesson_number = $wp_query->current_post + 1;
3202
+				} // End If Statement
3203
+
3204
+			} // End If Statement
3231 3205
 
3232
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
3233
-        $single_lesson_complete = false;
3234
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3206
+			$is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3207
+			if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3235 3208
 
3236
-        // Get Lesson data
3237
-        $complexity_array = Sensei()->lesson->lesson_complexities();
3209
+				$lesson_classes[] = 'lesson-preview';
3238 3210
 
3239
-        $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3240
-        if ( '' != $lesson_complexity ) {
3211
+			}
3241 3212
 
3242
-            $lesson_complexity = $complexity_array[$lesson_complexity];
3213
+			$classes = array_merge( $classes, $lesson_classes  );
3243 3214
 
3244
-        }
3245
-        $user_info = get_userdata( absint( get_post()->post_author ) );
3246
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3247
-        $preview_label = '';
3248
-        if ( $is_preview && !$is_user_taking_course ) {
3215
+		}
3249 3216
 
3250
-            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3251
-            $preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3217
+		return $classes;
3252 3218
 
3253
-        }
3219
+	}// end single_course_lessons_classes
3254 3220
 
3221
+	/**
3222
+	 * Output the lesson meta for the given lesson
3223
+	 *
3224
+	 * @since 1.9.0
3225
+	 * @param $lesson_id
3226
+	 */
3227
+	public static function the_lesson_meta( $lesson_id ){
3255 3228
 
3256
-        $count_markup= '';
3257
-        /**
3258
-         * Filter for if you want the $lesson_count to show next to the lesson.
3259
-         *
3260
-         * @since 1.0
3261
-         * @param bool default false.
3262
-         */
3263
-        if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3229
+		global $wp_query;
3230
+		$loop_lesson_number = $wp_query->current_post + 1;
3264 3231
 
3265
-            $count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3232
+		$course_id = Sensei()->lesson->get_course_id( $lesson_id );
3233
+		$single_lesson_complete = false;
3234
+		$is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3266 3235
 
3267
-        }
3236
+		// Get Lesson data
3237
+		$complexity_array = Sensei()->lesson->lesson_complexities();
3268 3238
 
3269
-        $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3239
+		$lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3240
+		if ( '' != $lesson_complexity ) {
3270 3241
 
3271
-        ?>
3242
+			$lesson_complexity = $complexity_array[$lesson_complexity];
3243
+
3244
+		}
3245
+		$user_info = get_userdata( absint( get_post()->post_author ) );
3246
+		$is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3247
+		$preview_label = '';
3248
+		if ( $is_preview && !$is_user_taking_course ) {
3249
+
3250
+			$preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3251
+			$preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3252
+
3253
+		}
3254
+
3255
+
3256
+		$count_markup= '';
3257
+		/**
3258
+		 * Filter for if you want the $lesson_count to show next to the lesson.
3259
+		 *
3260
+		 * @since 1.0
3261
+		 * @param bool default false.
3262
+		 */
3263
+		if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3264
+
3265
+			$count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3266
+
3267
+		}
3268
+
3269
+		$heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3270
+
3271
+		?>
3272 3272
         <header>
3273 3273
             <h2>
3274 3274
                 <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>"
@@ -3281,40 +3281,40 @@  discard block
 block discarded – undo
3281 3281
 
3282 3282
                 <?php
3283 3283
 
3284
-                $meta_html = '';
3285
-                $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3284
+				$meta_html = '';
3285
+				$user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3286 3286
 
3287
-                $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3288
-                if ( '' != $lesson_length ) {
3287
+				$lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3288
+				if ( '' != $lesson_length ) {
3289 3289
 
3290
-                    $meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3290
+					$meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3291 3291
 
3292
-                }
3292
+				}
3293 3293
 
3294
-                if ( Sensei()->settings->get( 'lesson_author' ) ) {
3294
+				if ( Sensei()->settings->get( 'lesson_author' ) ) {
3295 3295
 
3296
-                    $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>';
3296
+					$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>';
3297 3297
 
3298
-                } // End If Statement
3299
-                if ( '' != $lesson_complexity ) {
3298
+				} // End If Statement
3299
+				if ( '' != $lesson_complexity ) {
3300 3300
 
3301
-                    $meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3301
+					$meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3302 3302
 
3303
-                }
3303
+				}
3304 3304
 
3305
-                if ( $single_lesson_complete ) {
3305
+				if ( $single_lesson_complete ) {
3306 3306
 
3307
-                    $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3307
+					$meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3308 3308
 
3309
-                } elseif ( $user_lesson_status ) {
3309
+				} elseif ( $user_lesson_status ) {
3310 3310
 
3311
-                    $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3311
+					$meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3312 3312
 
3313
-                } // End If Statement
3313
+				} // End If Statement
3314 3314
 
3315
-                echo $meta_html;
3315
+				echo $meta_html;
3316 3316
 
3317
-                ?>
3317
+				?>
3318 3318
 
3319 3319
             </p> <!-- lesson meta -->
3320 3320
 
@@ -3322,132 +3322,132 @@  discard block
 block discarded – undo
3322 3322
 
3323 3323
     <?php
3324 3324
 
3325
-    } // end the_lesson_meta
3325
+	} // end the_lesson_meta
3326 3326
 
3327
-    /**
3328
-     * Output the lessons thumbnail
3329
-     *
3330
-     * 1.9.0
3331
-     *
3332
-     * @param $lesson_id
3333
-     */
3334
-    public static function the_lesson_thumbnail( $lesson_id ){
3327
+	/**
3328
+	 * Output the lessons thumbnail
3329
+	 *
3330
+	 * 1.9.0
3331
+	 *
3332
+	 * @param $lesson_id
3333
+	 */
3334
+	public static function the_lesson_thumbnail( $lesson_id ){
3335 3335
 
3336
-        if( empty( $lesson_id ) ){
3336
+		if( empty( $lesson_id ) ){
3337 3337
 
3338
-            $lesson_id = get_the_ID();
3338
+			$lesson_id = get_the_ID();
3339 3339
 
3340
-        }
3340
+		}
3341 3341
 
3342
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3343
-            return;
3344
-        }
3342
+		if( 'lesson' != get_post_type( $lesson_id ) ){
3343
+			return;
3344
+		}
3345 3345
 
3346
-        echo Sensei()->lesson->lesson_image( $lesson_id );
3347
-    }
3346
+		echo Sensei()->lesson->lesson_image( $lesson_id );
3347
+	}
3348 3348
 
3349 3349
 
3350
-    /**
3351
-     * Alter the sensei lesson excerpt.
3352
-     *
3353
-     * @since 1.9.0
3354
-     * @param string $excerpt
3355
-     * @return string $excerpt
3356
-     */
3357
-    public static function alter_the_lesson_excerpt( $excerpt ) {
3350
+	/**
3351
+	 * Alter the sensei lesson excerpt.
3352
+	 *
3353
+	 * @since 1.9.0
3354
+	 * @param string $excerpt
3355
+	 * @return string $excerpt
3356
+	 */
3357
+	public static function alter_the_lesson_excerpt( $excerpt ) {
3358 3358
 
3359
-        if ('lesson' == get_post_type(get_the_ID())){
3359
+		if ('lesson' == get_post_type(get_the_ID())){
3360 3360
 
3361
-            // remove this hooks to avoid an infinite loop.
3362
-            remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3361
+			// remove this hooks to avoid an infinite loop.
3362
+			remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3363 3363
 
3364
-            return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3365
-        }
3364
+			return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3365
+		}
3366 3366
 
3367
-        return $excerpt;
3367
+		return $excerpt;
3368 3368
 
3369
-    }// end the_lesson_excerpt
3369
+	}// end the_lesson_excerpt
3370 3370
 
3371
-    /**
3372
-     * Returns the lesson prerequisite for the given lesson id.
3373
-     *
3374
-     * @since 1.9.0
3375
-     *
3376
-     * @param $current_lesson_id
3377
-     * @return mixed | bool | int $prerequisite_lesson_id or false
3378
-     */
3379
-    public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3371
+	/**
3372
+	 * Returns the lesson prerequisite for the given lesson id.
3373
+	 *
3374
+	 * @since 1.9.0
3375
+	 *
3376
+	 * @param $current_lesson_id
3377
+	 * @return mixed | bool | int $prerequisite_lesson_id or false
3378
+	 */
3379
+	public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3380 3380
 
3381
-        $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3381
+		$prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3382 3382
 
3383
-        // set ti to false if not a valid prerequisite lesson id
3384
-        if(  empty( $prerequisite_lesson_id )
3385
-            || 'lesson' != get_post_type( $prerequisite_lesson_id )
3386
-            || $prerequisite_lesson_id == $current_lesson_id  ) {
3383
+		// set ti to false if not a valid prerequisite lesson id
3384
+		if(  empty( $prerequisite_lesson_id )
3385
+			|| 'lesson' != get_post_type( $prerequisite_lesson_id )
3386
+			|| $prerequisite_lesson_id == $current_lesson_id  ) {
3387 3387
 
3388
-            $prerequisite_lesson_id = false;
3388
+			$prerequisite_lesson_id = false;
3389 3389
 
3390
-        }
3390
+		}
3391 3391
 
3392
-        return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3392
+		return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3393 3393
 
3394
-    }
3394
+	}
3395 3395
 
3396
-    /**
3397
-     * This function requires that you pass in the lesson you would like to check for
3398
-     * a pre-requisite and not the pre-requisite. It will check if the
3399
-     * lesson has a pre-requiste and then check if it is completed.
3400
-     *
3401
-     * @since 1.9.0
3402
-     *
3403
-     * @param $lesson_id
3404
-     * @param $user_id
3405
-     * @return bool
3406
-     */
3407
-    public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3396
+	/**
3397
+	 * This function requires that you pass in the lesson you would like to check for
3398
+	 * a pre-requisite and not the pre-requisite. It will check if the
3399
+	 * lesson has a pre-requiste and then check if it is completed.
3400
+	 *
3401
+	 * @since 1.9.0
3402
+	 *
3403
+	 * @param $lesson_id
3404
+	 * @param $user_id
3405
+	 * @return bool
3406
+	 */
3407
+	public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3408 3408
 
3409
-        if( empty( $lesson_id ) || empty( $user_id )
3410
-        || 'lesson' != get_post_type( $lesson_id )
3411
-        ||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3409
+		if( empty( $lesson_id ) || empty( $user_id )
3410
+		|| 'lesson' != get_post_type( $lesson_id )
3411
+		||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3412 3412
 
3413
-            return false;
3413
+			return false;
3414 3414
 
3415
-        }
3415
+		}
3416 3416
 
3417
-        $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3417
+		$pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3418 3418
 
3419
-        // not a valid pre-requisite so pre-requisite is completed
3420
-        if( 'lesson' != get_post_type( $pre_requisite_id )
3421
-            || ! is_numeric( $pre_requisite_id ) ){
3419
+		// not a valid pre-requisite so pre-requisite is completed
3420
+		if( 'lesson' != get_post_type( $pre_requisite_id )
3421
+			|| ! is_numeric( $pre_requisite_id ) ){
3422 3422
 
3423
-            return true;
3423
+			return true;
3424 3424
 
3425
-        }
3425
+		}
3426 3426
 
3427
-        return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3427
+		return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3428 3428
 
3429
-    }// end is_prerequisite_complete
3429
+	}// end is_prerequisite_complete
3430 3430
 
3431
-    /**
3432
-     * Show the user not taking course message if it is the case
3433
-     *
3434
-     * @since 1.9.0
3435
-     */
3436
-    public  static function user_not_taking_course_message(){
3431
+	/**
3432
+	 * Show the user not taking course message if it is the case
3433
+	 *
3434
+	 * @since 1.9.0
3435
+	 */
3436
+	public  static function user_not_taking_course_message(){
3437 3437
 
3438
-        $lesson_id = get_the_ID();
3438
+		$lesson_id = get_the_ID();
3439 3439
 
3440
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3441
-            return;
3442
-        }
3440
+		if( 'lesson' != get_post_type( $lesson_id ) ){
3441
+			return;
3442
+		}
3443 3443
 
3444
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3445
-        $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3446
-        $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3447
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3444
+		$is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3445
+		$pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3446
+		$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3447
+		$user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3448 3448
 
3449
-        if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3450
-            ?>
3449
+		if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3450
+			?>
3451 3451
 
3452 3452
             <div class="sensei-message alert">
3453 3453
                 <?php echo Sensei()->permissions_message['message']; ?>
@@ -3455,46 +3455,46 @@  discard block
 block discarded – undo
3455 3455
 
3456 3456
             <?php
3457 3457
 
3458
-        }// end if
3458
+		}// end if
3459 3459
 
3460
-    } // end user_not_taking_course_message
3460
+	} // end user_not_taking_course_message
3461 3461
 
3462
-    /**
3463
-     * Outputs the lessons course signup lingk
3464
-     *
3465
-     * This hook runs inside the single lesson page.
3466
-     *
3467
-     * @since 1.9.0
3468
-     */
3469
-    public static function course_signup_link( ){
3462
+	/**
3463
+	 * Outputs the lessons course signup lingk
3464
+	 *
3465
+	 * This hook runs inside the single lesson page.
3466
+	 *
3467
+	 * @since 1.9.0
3468
+	 */
3469
+	public static function course_signup_link( ){
3470 3470
 
3471
-        $course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3471
+		$course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3472 3472
 
3473
-        if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3473
+		if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3474 3474
 
3475
-            return;
3475
+			return;
3476 3476
 
3477
-        }
3478
-        ?>
3477
+		}
3478
+		?>
3479 3479
 
3480 3480
         <section class="course-signup lesson-meta">
3481 3481
 
3482 3482
             <?php
3483
-            $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3483
+			$wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3484 3484
 
3485
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3485
+			if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3486 3486
 
3487
-                global $current_user;
3488
-                if( is_user_logged_in() ) {
3489
-                    wp_get_current_user();
3487
+				global $current_user;
3488
+				if( is_user_logged_in() ) {
3489
+					wp_get_current_user();
3490 3490
 
3491
-                    $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3491
+					$course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3492 3492
 
3493
-                    if( $course_purchased ) {
3493
+					if( $course_purchased ) {
3494 3494
 
3495
-                        $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3496
-                        $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3497
-                        ?>
3495
+						$prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3496
+						$course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3497
+						?>
3498 3498
                             <div class="sensei-message info">
3499 3499
 
3500 3500
                                 <?php  echo sprintf( __( 'Please complete %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); ?>
@@ -3506,14 +3506,14 @@  discard block
 block discarded – undo
3506 3506
                         <div class="sensei-message info">
3507 3507
 
3508 3508
                             <?php
3509
-                            $course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3510
-                                            . '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3511
-                                            . '">' . __( 'course', 'woothemes-sensei' )
3512
-                                            . '</a>';
3509
+							$course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3510
+											. '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3511
+											. '">' . __( 'course', 'woothemes-sensei' )
3512
+											. '</a>';
3513 3513
 
3514
-                            echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3514
+							echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3515 3515
 
3516
-                            ?>
3516
+							?>
3517 3517
 
3518 3518
                         </div>
3519 3519
                     <?php } ?>
@@ -3530,14 +3530,14 @@  discard block
 block discarded – undo
3530 3530
 
3531 3531
                 <div class="sensei-message info">
3532 3532
                     <?php
3533
-                    $course_link =  '<a href="'
3534
-                                        . esc_url( get_permalink( $course_id ) )
3535
-                                        . '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3536
-                                        . '">' . __( 'course', 'woothemes-sensei' )
3537
-                                    . '</a>';
3538
-
3539
-                    echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3540
-                    ?>
3533
+					$course_link =  '<a href="'
3534
+										. esc_url( get_permalink( $course_id ) )
3535
+										. '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3536
+										. '">' . __( 'course', 'woothemes-sensei' )
3537
+									. '</a>';
3538
+
3539
+					echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3540
+					?>
3541 3541
                 </div>
3542 3542
 
3543 3543
             <?php endif; ?>
@@ -3547,75 +3547,75 @@  discard block
 block discarded – undo
3547 3547
         </section>
3548 3548
 
3549 3549
         <?php
3550
-    }// end course_signup_link
3550
+	}// end course_signup_link
3551 3551
 
3552
-    /**
3553
-     * Show a message telling the user to complete the previous message if they haven't done so yet
3554
-     *
3555
-     * @since 1.9.0
3556
-     */
3557
-    public  static function prerequisite_complete_message(){
3552
+	/**
3553
+	 * Show a message telling the user to complete the previous message if they haven't done so yet
3554
+	 *
3555
+	 * @since 1.9.0
3556
+	 */
3557
+	public  static function prerequisite_complete_message(){
3558 3558
 
3559
-        $lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3560
-        $lesson_has_pre_requisite = $lesson_prerequisite > 0;
3561
-        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3559
+		$lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3560
+		$lesson_has_pre_requisite = $lesson_prerequisite > 0;
3561
+		if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3562 3562
 
3563
-            $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>';
3564
-            echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3563
+			$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>';
3564
+			echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3565 3565
 
3566
-        }
3566
+		}
3567 3567
 
3568
-    }
3568
+	}
3569 3569
 
3570
-    /**
3571
-     * Deprecate the sensei_lesson_archive_header hook but keep it
3572
-     * active for backwards compatibility.
3573
-     *
3574
-     * @deprecated since 1.9.0
3575
-     */
3576
-    public static function deprecate_sensei_lesson_archive_header_hook(){
3570
+	/**
3571
+	 * Deprecate the sensei_lesson_archive_header hook but keep it
3572
+	 * active for backwards compatibility.
3573
+	 *
3574
+	 * @deprecated since 1.9.0
3575
+	 */
3576
+	public static function deprecate_sensei_lesson_archive_header_hook(){
3577 3577
 
3578
-        sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3578
+		sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3579 3579
 
3580
-    }
3580
+	}
3581 3581
 
3582
-    /**
3583
-     * Outputs the the lesson archive header.
3584
-     *
3585
-     * @since  1.9.0
3586
-     * @return void
3587
-     */
3588
-    public function the_archive_header( ) {
3582
+	/**
3583
+	 * Outputs the the lesson archive header.
3584
+	 *
3585
+	 * @since  1.9.0
3586
+	 * @return void
3587
+	 */
3588
+	public function the_archive_header( ) {
3589 3589
 
3590
-        $before_html = '<header class="archive-header"><h1>';
3591
-        $after_html = '</h1></header>';
3592
-        $html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3590
+		$before_html = '<header class="archive-header"><h1>';
3591
+		$after_html = '</h1></header>';
3592
+		$html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3593 3593
 
3594
-        echo apply_filters( 'sensei_lesson_archive_title', $html );
3594
+		echo apply_filters( 'sensei_lesson_archive_title', $html );
3595 3595
 
3596
-    } // sensei_course_archive_header()
3596
+	} // sensei_course_archive_header()
3597 3597
 
3598
-    /**
3599
-     * Output the title for the single lesson page
3600
-     *
3601
-     * @global $post
3602
-     * @since 1.9.0
3603
-     */
3604
-    public static function the_title(){
3598
+	/**
3599
+	 * Output the title for the single lesson page
3600
+	 *
3601
+	 * @global $post
3602
+	 * @since 1.9.0
3603
+	 */
3604
+	public static function the_title(){
3605 3605
 
3606
-        global $post;
3606
+		global $post;
3607 3607
 
3608
-        ?>
3608
+		?>
3609 3609
         <header>
3610 3610
 
3611 3611
             <h1>
3612 3612
 
3613 3613
                 <?php
3614
-                /**
3615
-                 * Filter documented in class-sensei-messages.php the_title
3616
-                 */
3617
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3618
-                ?>
3614
+				/**
3615
+				 * Filter documented in class-sensei-messages.php the_title
3616
+				 */
3617
+				echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3618
+				?>
3619 3619
 
3620 3620
             </h1>
3621 3621
 
@@ -3623,68 +3623,68 @@  discard block
 block discarded – undo
3623 3623
 
3624 3624
         <?php
3625 3625
 
3626
-    }//the_title
3626
+	}//the_title
3627 3627
 
3628
-    /**
3629
-     * Flush the rewrite rules for a lesson post type
3630
-     *
3631
-     * @since 1.9.0
3632
-     *
3633
-     * @param $post_id
3634
-     */
3635
-    public static function flush_rewrite_rules( $post_id ){
3628
+	/**
3629
+	 * Flush the rewrite rules for a lesson post type
3630
+	 *
3631
+	 * @since 1.9.0
3632
+	 *
3633
+	 * @param $post_id
3634
+	 */
3635
+	public static function flush_rewrite_rules( $post_id ){
3636 3636
 
3637
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3637
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3638 3638
 
3639
-            return;
3639
+			return;
3640 3640
 
3641
-        }
3641
+		}
3642 3642
 
3643 3643
 
3644
-        if( 'lesson' == get_post_type( $post_id )  ){
3644
+		if( 'lesson' == get_post_type( $post_id )  ){
3645 3645
 
3646
-            Sensei()->initiate_rewrite_rules_flush();
3646
+			Sensei()->initiate_rewrite_rules_flush();
3647 3647
 
3648
-        }
3648
+		}
3649 3649
 
3650
-    }
3650
+	}
3651 3651
 
3652
-    /**
3653
-     * Output the quiz specific buttons and messaging on the single lesson page
3654
-     *
3655
-     *
3656
-     * @since 1.0.0 moved here from frontend class
3657
-     *
3658
-     * @param int $lesson_id
3659
-     * @param int $user_id
3660
-     */
3661
-    public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3652
+	/**
3653
+	 * Output the quiz specific buttons and messaging on the single lesson page
3654
+	 *
3655
+	 *
3656
+	 * @since 1.0.0 moved here from frontend class
3657
+	 *
3658
+	 * @param int $lesson_id
3659
+	 * @param int $user_id
3660
+	 */
3661
+	public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3662 3662
 
3663 3663
 
3664
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3665
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3666
-        $lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3667
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3668
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3669
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3670
-        $show_actions              = is_user_logged_in() ? true : false;
3664
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3665
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3666
+		$lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3667
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3668
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3669
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3670
+		$show_actions              = is_user_logged_in() ? true : false;
3671 3671
 
3672
-        if( intval( $lesson_prerequisite ) > 0 ) {
3672
+		if( intval( $lesson_prerequisite ) > 0 ) {
3673 3673
 
3674
-            // If the user hasn't completed the prereq then hide the current actions
3675
-            $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3674
+			// If the user hasn't completed the prereq then hide the current actions
3675
+			$show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3676 3676
 
3677
-        }
3678
-        ?>
3677
+		}
3678
+		?>
3679 3679
 
3680 3680
         <footer>
3681 3681
 
3682 3682
             <?php
3683
-            if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3683
+			if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3684 3684
 
3685
-                $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3686
-                if( $has_quiz_questions ) {
3687
-                    ?>
3685
+				$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3686
+				if( $has_quiz_questions ) {
3687
+					?>
3688 3688
 
3689 3689
                     <p>
3690 3690
 
@@ -3699,87 +3699,87 @@  discard block
 block discarded – undo
3699 3699
                     </p>
3700 3700
 
3701 3701
                     <?php
3702
-                }
3702
+				}
3703 3703
 
3704
-            } // End If Statement
3704
+			} // End If Statement
3705 3705
 
3706
-            if ( $show_actions && ! $has_user_completed_lesson ) {
3706
+			if ( $show_actions && ! $has_user_completed_lesson ) {
3707 3707
 
3708
-                sensei_complete_lesson_button();
3708
+				sensei_complete_lesson_button();
3709 3709
 
3710
-            } elseif( $show_actions ) {
3710
+			} elseif( $show_actions ) {
3711 3711
 
3712
-                sensei_reset_lesson_button();
3712
+				sensei_reset_lesson_button();
3713 3713
 
3714
-            } // End If Statement
3715
-            ?>
3714
+			} // End If Statement
3715
+			?>
3716 3716
 
3717 3717
         </footer>
3718 3718
 
3719 3719
         <?php
3720
-    } // End sensei_lesson_quiz_meta()
3720
+	} // End sensei_lesson_quiz_meta()
3721 3721
 
3722
-    /**
3723
-     * Show the lesson comments. This should be used in the loop.
3724
-     *
3725
-     * @since 1.9.0
3726
-     */
3727
-    public static function output_comments(){
3722
+	/**
3723
+	 * Show the lesson comments. This should be used in the loop.
3724
+	 *
3725
+	 * @since 1.9.0
3726
+	 */
3727
+	public static function output_comments(){
3728 3728
 
3729
-        if( ! is_user_logged_in() ){
3730
-            return;
3731
-        }
3729
+		if( ! is_user_logged_in() ){
3730
+			return;
3731
+		}
3732 3732
 
3733
-        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3734
-        $course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3735
-        $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3736
-        $user_taking_course = Sensei_Utils::user_started_course($course_id );
3733
+		$pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3734
+		$course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3735
+		$allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3736
+		$user_taking_course = Sensei_Utils::user_started_course($course_id );
3737 3737
 
3738
-        $lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3738
+		$lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3739 3739
 
3740
-        if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3740
+		if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3741 3741
 
3742
-            comments_template();
3742
+			comments_template();
3743 3743
 
3744
-        } // End If Statement
3744
+		} // End If Statement
3745 3745
 
3746
-    } //output_comments
3746
+	} //output_comments
3747 3747
 
3748
-    /**
3749
-     * Display the leeson quiz status if it should be shown
3750
-     *
3751
-     * @param int $lesson_id defaults to the global lesson id
3752
-     * @param int $user_id defaults to the current user id
3753
-     *
3754
-     * @since 1.9.0
3755
-     */
3756
-    public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3748
+	/**
3749
+	 * Display the leeson quiz status if it should be shown
3750
+	 *
3751
+	 * @param int $lesson_id defaults to the global lesson id
3752
+	 * @param int $user_id defaults to the current user id
3753
+	 *
3754
+	 * @since 1.9.0
3755
+	 */
3756
+	public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3757 3757
 
3758
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3759
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3760
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3761
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3762
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3758
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3759
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3760
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3761
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3762
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3763 3763
 
3764 3764
 
3765
-        if ( $quiz_id && is_user_logged_in()
3766
-            && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3765
+		if ( $quiz_id && is_user_logged_in()
3766
+			&& Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3767 3767
 
3768
-            $no_quiz_count = 0;
3769
-            $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3768
+			$no_quiz_count = 0;
3769
+			$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3770 3770
 
3771
-            // Display lesson quiz status message
3772
-            if ( $has_user_completed_lesson || $has_quiz_questions ) {
3773
-                $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3774
-                echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3775
-                if( $has_quiz_questions ) {
3776
-                   // echo $status['extra'];
3777
-                } // End If Statement
3778
-            } // End If Statement
3771
+			// Display lesson quiz status message
3772
+			if ( $has_user_completed_lesson || $has_quiz_questions ) {
3773
+				$status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3774
+				echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3775
+				if( $has_quiz_questions ) {
3776
+				   // echo $status['extra'];
3777
+				} // End If Statement
3778
+			} // End If Statement
3779 3779
 
3780
-        }
3780
+		}
3781 3781
 
3782
-    }
3782
+	}
3783 3783
 
3784 3784
 } // End Class
3785 3785
 
Please login to merge, or discard this patch.
includes/class-sensei-analysis-user-profile-list-table.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -201,7 +201,7 @@
 block discarded – undo
201 201
 
202 202
 		if( 'complete' == $item->comment_approved ) {
203 203
 
204
-            $status =  __( 'Completed', 'woothemes-sensei' );
204
+			$status =  __( 'Completed', 'woothemes-sensei' );
205 205
 			$status_class = 'graded';
206 206
 
207 207
 			$course_end_date = $item->comment_date;
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis User Profile List Table Class
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Analysis User Profile Data Table in Sensei.
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
 	 * @since  1.2.0
19 19
 	 * @return  void
20 20
 	 */
21
-	public function __construct ( $user_id = 0 ) {
22
-		$this->user_id = intval( $user_id );
21
+	public function __construct($user_id = 0) {
22
+		$this->user_id = intval($user_id);
23 23
 
24 24
 		// Load Parent token into constructor
25
-		parent::__construct( 'analysis_user_profile' );
25
+		parent::__construct('analysis_user_profile');
26 26
 
27 27
 		// Actions
28
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
29
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
28
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
29
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
30 30
 
31
-		add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) );
31
+		add_filter('sensei_list_table_search_button_text', array($this, 'search_button'));
32 32
 	} // End __construct()
33 33
 
34 34
 	/**
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	function get_columns() {
40 40
 		$columns = array(
41
-			'title' => __( 'Course', 'woothemes-sensei' ),
42
-			'started' => __( 'Date Started', 'woothemes-sensei' ),
43
-			'completed' => __( 'Date Completed', 'woothemes-sensei' ),
44
-			'status' => __( 'Status', 'woothemes-sensei' ),
41
+			'title' => __('Course', 'woothemes-sensei'),
42
+			'started' => __('Date Started', 'woothemes-sensei'),
43
+			'completed' => __('Date Completed', 'woothemes-sensei'),
44
+			'status' => __('Status', 'woothemes-sensei'),
45 45
 //			'grade' => __( 'Grade', 'woothemes-sensei' ),
46
-			'percent' => __( 'Percent Complete', 'woothemes-sensei' ),
46
+			'percent' => __('Percent Complete', 'woothemes-sensei'),
47 47
 		);
48
-		$columns = apply_filters( 'sensei_analysis_user_profile_columns', $columns );
48
+		$columns = apply_filters('sensei_analysis_user_profile_columns', $columns);
49 49
 		return $columns;
50 50
 	}
51 51
 
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	function get_sortable_columns() {
58 58
 		$columns = array(
59
-			'title' => array( 'title', false ),
60
-			'started' => array( 'started', false ),
61
-			'completed' => array( 'completed', false ),
62
-			'status' => array( 'status', false ),
59
+			'title' => array('title', false),
60
+			'started' => array('started', false),
61
+			'completed' => array('completed', false),
62
+			'status' => array('status', false),
63 63
 //			'grade' => array( 'grade', false ),
64
-			'percent' => array( 'percent', false )
64
+			'percent' => array('percent', false)
65 65
 		);
66
-		$columns = apply_filters( 'sensei_analysis_user_profile_columns_sortable', $columns );
66
+		$columns = apply_filters('sensei_analysis_user_profile_columns_sortable', $columns);
67 67
 		return $columns;
68 68
 	}
69 69
 
@@ -77,32 +77,32 @@  discard block
 block discarded – undo
77 77
 
78 78
 		// Handle orderby (needs work)
79 79
 		$orderby = '';
80
-		if ( !empty( $_GET['orderby'] ) ) {
81
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
82
-				$orderby = esc_html( $_GET['orderby'] );
80
+		if ( ! empty($_GET['orderby'])) {
81
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
82
+				$orderby = esc_html($_GET['orderby']);
83 83
 			} // End If Statement
84 84
 		}
85 85
 
86 86
 		// Handle order
87 87
 		$order = 'ASC';
88
-		if ( !empty( $_GET['order'] ) ) {
89
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
88
+		if ( ! empty($_GET['order'])) {
89
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
90 90
 		}
91 91
 
92 92
 		// Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids
93 93
 		$search = false;
94
-		if ( !empty( $_GET['s'] ) ) {
95
-			$search = esc_html( $_GET['s'] );
94
+		if ( ! empty($_GET['s'])) {
95
+			$search = esc_html($_GET['s']);
96 96
 		} // End If Statement
97 97
 		$this->search = $search;
98 98
 
99
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
100
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
99
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
100
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
101 101
 
102 102
 		$paged = $this->get_pagenum();
103 103
 		$offset = 0;
104
-		if ( !empty($paged) ) {
105
-			$offset = $per_page * ( $paged - 1 );
104
+		if ( ! empty($paged)) {
105
+			$offset = $per_page * ($paged - 1);
106 106
 		} // End If Statement
107 107
 
108 108
 		$args = array(
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
 			'orderby' => $orderby,
112 112
 			'order' => $order,
113 113
 		);
114
-		if ( $this->search ) {
114
+		if ($this->search) {
115 115
 			$args['search'] = $this->search;
116 116
 		} // End If Statement
117 117
 
118
-		$this->items = $this->get_course_statuses( $args );
118
+		$this->items = $this->get_course_statuses($args);
119 119
 
120 120
 		$total_items = $this->total_items;
121
-		$total_pages = ceil( $total_items / $per_page );
122
-		$this->set_pagination_args( array(
121
+		$total_pages = ceil($total_items / $per_page);
122
+		$this->set_pagination_args(array(
123 123
 			'total_items' => $total_items,
124 124
 			'total_pages' => $total_pages,
125 125
 			'per_page' => $per_page
126
-		) );
126
+		));
127 127
 	}
128 128
 
129 129
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @since  1.7.0
132 132
 	 * @return data
133 133
 	 */
134
-	public function generate_report( $report ) {
134
+	public function generate_report($report) {
135 135
 
136 136
 		$data = array();
137 137
 
@@ -139,22 +139,22 @@  discard block
 block discarded – undo
139 139
 
140 140
 		// Handle orderby
141 141
 		$orderby = '';
142
-		if ( !empty( $_GET['orderby'] ) ) {
143
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
144
-				$orderby = esc_html( $_GET['orderby'] );
142
+		if ( ! empty($_GET['orderby'])) {
143
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
144
+				$orderby = esc_html($_GET['orderby']);
145 145
 			} // End If Statement
146 146
 		}
147 147
 
148 148
 		// Handle order
149 149
 		$order = 'ASC';
150
-		if ( !empty( $_GET['order'] ) ) {
151
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
150
+		if ( ! empty($_GET['order'])) {
151
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
152 152
 		}
153 153
 
154 154
 		// Handle search
155 155
 		$search = false;
156
-		if ( !empty( $_GET['s'] ) ) {
157
-			$search = esc_html( $_GET['s'] );
156
+		if ( ! empty($_GET['s'])) {
157
+			$search = esc_html($_GET['s']);
158 158
 		} // End If Statement
159 159
 		$this->search = $search;
160 160
 
@@ -162,23 +162,23 @@  discard block
 block discarded – undo
162 162
 			'orderby' => $orderby,
163 163
 			'order' => $order,
164 164
 		);
165
-		if ( $this->search ) {
165
+		if ($this->search) {
166 166
 			$args['search'] = $this->search;
167 167
 		} // End If Statement
168 168
 
169 169
 		// Start the csv with the column headings
170 170
 		$column_headers = array();
171 171
 		$columns = $this->get_columns();
172
-		foreach( $columns AS $key => $title ) {
172
+		foreach ($columns AS $key => $title) {
173 173
 			$column_headers[] = $title;
174 174
 		}
175 175
 		$data[] = $column_headers;
176 176
 
177
-		$this->items = $this->get_course_statuses( $args );
177
+		$this->items = $this->get_course_statuses($args);
178 178
 
179 179
 		// Process each row
180
-		foreach( $this->items AS $item) {
181
-			$data[] = $this->get_row_data( $item );
180
+		foreach ($this->items AS $item) {
181
+			$data[] = $this->get_row_data($item);
182 182
 		}
183 183
 
184 184
 		return $data;
@@ -189,43 +189,43 @@  discard block
 block discarded – undo
189 189
 	 * @since  1.7.0
190 190
 	 * @param object $item The current item
191 191
 	 */
192
-	protected function get_row_data( $item ) {
192
+	protected function get_row_data($item) {
193 193
 
194
-		$course_title =  get_the_title( $item->comment_post_ID );
195
-		$course_percent = get_comment_meta( $item->comment_ID, 'percent', true );
196
-		$course_start_date = get_comment_meta( $item->comment_ID, 'start', true );
194
+		$course_title = get_the_title($item->comment_post_ID);
195
+		$course_percent = get_comment_meta($item->comment_ID, 'percent', true);
196
+		$course_start_date = get_comment_meta($item->comment_ID, 'start', true);
197 197
 		$course_end_date = '';
198 198
 
199
-		if( 'complete' == $item->comment_approved ) {
199
+		if ('complete' == $item->comment_approved) {
200 200
 
201
-            $status =  __( 'Completed', 'woothemes-sensei' );
201
+            $status = __('Completed', 'woothemes-sensei');
202 202
 			$status_class = 'graded';
203 203
 
204 204
 			$course_end_date = $item->comment_date;
205 205
 
206 206
 		} else {
207 207
 
208
-			$status =  __( 'In Progress', 'woothemes-sensei' );
208
+			$status = __('In Progress', 'woothemes-sensei');
209 209
 			$status_class = 'in-progress';
210 210
 
211 211
 		}
212 212
 
213 213
 		// Output users data
214
-		if ( !$this->csv_output ) {
215
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $this->user_id, 'course_id' => $item->comment_post_ID ), admin_url( 'admin.php' ) );
214
+		if ( ! $this->csv_output) {
215
+			$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $this->user_id, 'course_id' => $item->comment_post_ID), admin_url('admin.php'));
216 216
 
217
-			$course_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $course_title . '</a></strong>';
218
-			$status = sprintf( '<span class="%s">%s</span>', $status_class, $status );
219
-			if ( is_numeric($course_percent) ) {
217
+			$course_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.$course_title.'</a></strong>';
218
+			$status = sprintf('<span class="%s">%s</span>', $status_class, $status);
219
+			if (is_numeric($course_percent)) {
220 220
 				$course_percent .= '%';
221 221
 			}
222 222
 		} // End If Statement
223
-		$column_data = apply_filters( 'sensei_analysis_user_profile_column_data', array( 'title' => $course_title,
223
+		$column_data = apply_filters('sensei_analysis_user_profile_column_data', array('title' => $course_title,
224 224
 										'started' => $course_start_date,
225 225
 										'completed' => $course_end_date,
226 226
 										'status' => $status,
227 227
 										'percent' => $course_percent,
228
-									), $item );
228
+									), $item);
229 229
 
230 230
 		return $column_data;
231 231
 	}
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @since  1.7.0
236 236
 	 * @return array statuses
237 237
 	 */
238
-	private function get_course_statuses( $args ) {
238
+	private function get_course_statuses($args) {
239 239
 
240 240
 		$activity_args = array( 
241 241
 				'user_id' => $this->user_id,
@@ -247,23 +247,23 @@  discard block
 block discarded – undo
247 247
 				'status' => 'any',
248 248
 			);
249 249
 
250
-		$activity_args = apply_filters( 'sensei_analysis_user_profile_filter_statuses', $activity_args );
250
+		$activity_args = apply_filters('sensei_analysis_user_profile_filter_statuses', $activity_args);
251 251
 
252 252
 		// WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice
253
-		$this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
253
+		$this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0)));
254 254
 
255 255
 		// Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views?
256
-		if ( $this->total_items < $activity_args['offset'] ) {
256
+		if ($this->total_items < $activity_args['offset']) {
257 257
 
258
-			$new_paged = floor( $this->total_items / $activity_args['number'] );
258
+			$new_paged = floor($this->total_items / $activity_args['number']);
259 259
 			$activity_args['offset'] = $new_paged * $activity_args['number'];
260 260
 
261 261
 		}
262
-		$statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true );
262
+		$statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true);
263 263
 
264 264
 		// Need to always return an array, even with only 1 item
265
-		if ( !is_array($statuses) ) {
266
-			$statuses = array( $statuses );
265
+		if ( ! is_array($statuses)) {
266
+			$statuses = array($statuses);
267 267
 		}
268 268
 
269 269
 		return $statuses;
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * @return void
277 277
 	 */
278 278
 	public function no_items() {
279
-		echo  __( 'No courses found.', 'woothemes-sensei' );
279
+		echo  __('No courses found.', 'woothemes-sensei');
280 280
 	} // End no_items()
281 281
 
282 282
 	/**
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 * @return void
286 286
 	 */
287 287
 	public function data_table_header() {
288
-		echo '<strong>' . __( 'Courses', 'woothemes-sensei' ) . '</strong>';
288
+		echo '<strong>'.__('Courses', 'woothemes-sensei').'</strong>';
289 289
 	}
290 290
 
291 291
 	/**
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 	 * @return void
295 295
 	 */
296 296
 	public function data_table_footer() {
297
-		$user = get_user_by( 'id', $this->user_id );
298
-		$report = sanitize_title( $user->display_name ) . '-course-overview';
299
-		$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $this->user_id, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) );
300
-		echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>';
297
+		$user = get_user_by('id', $this->user_id);
298
+		$report = sanitize_title($user->display_name).'-course-overview';
299
+		$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $this->user_id, 'sensei_report_download' => $report), admin_url('admin.php'));
300
+		echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>';
301 301
 	}
302 302
 
303 303
 	/**
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 	 * @since  1.7.0
306 306
 	 * @return string
307 307
 	 */
308
-	public function search_button( $text = '' ) {
309
-		return __( 'Search Courses', 'woothemes-sensei' );
308
+	public function search_button($text = '') {
309
+		return __('Search Courses', 'woothemes-sensei');
310 310
 	}
311 311
 
312 312
 } // End Class
Please login to merge, or discard this patch.