Completed
Push — master ( 77803a...2e041b )
by Dwain
26: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.
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   +1037 added lines, -1037 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' ) );
@@ -1827,7 +1827,7 @@  discard block
 block discarded – undo
1827 1827
 			$nonce = esc_html( $_POST['lesson_add_course_nonce'] );
1828 1828
 		} // End If Statement
1829 1829
 		if ( ! wp_verify_nonce( $nonce, 'lesson_add_course_nonce' )
1830
-            || ! current_user_can( 'edit_lessons' ) ) {
1830
+			|| ! current_user_can( 'edit_lessons' ) ) {
1831 1831
 			die('');
1832 1832
 		} // End If Statement
1833 1833
 		// Parse POST data
@@ -1856,7 +1856,7 @@  discard block
 block discarded – undo
1856 1856
 			$nonce = esc_html( $_POST['lesson_update_question_nonce'] );
1857 1857
 		} // End If Statement
1858 1858
 		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_nonce' )
1859
-            ||  ! current_user_can( 'edit_questions' )) {
1859
+			||  ! current_user_can( 'edit_questions' )) {
1860 1860
 
1861 1861
 			die('');
1862 1862
 
@@ -1909,7 +1909,7 @@  discard block
 block discarded – undo
1909 1909
 		} // End If Statement
1910 1910
 
1911 1911
 		if( ! wp_verify_nonce( $nonce, 'lesson_add_multiple_questions_nonce' )
1912
-            || ! current_user_can( 'edit_lessons' ) ) {
1912
+			|| ! current_user_can( 'edit_lessons' ) ) {
1913 1913
 			die( $return );
1914 1914
 		} // End If Statement
1915 1915
 
@@ -1965,7 +1965,7 @@  discard block
 block discarded – undo
1965 1965
 		} // End If Statement
1966 1966
 
1967 1967
 		if( ! wp_verify_nonce( $nonce, 'lesson_remove_multiple_questions_nonce' )
1968
-        || ! current_user_can( 'edit_lessons' ) ) {
1968
+		|| ! current_user_can( 'edit_lessons' ) ) {
1969 1969
 			die('');
1970 1970
 		} // End If Statement
1971 1971
 
@@ -2012,7 +2012,7 @@  discard block
 block discarded – undo
2012 2012
 		} // End If Statement
2013 2013
 
2014 2014
 		if( ! wp_verify_nonce( $nonce, 'lesson_add_existing_questions_nonce' )
2015
-        || ! current_user_can( 'edit_lessons' ) ) {
2015
+		|| ! current_user_can( 'edit_lessons' ) ) {
2016 2016
 			die('');
2017 2017
 		} // End If Statement
2018 2018
 
@@ -2037,12 +2037,12 @@  discard block
 block discarded – undo
2037 2037
 
2038 2038
 					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2039 2039
 					if( ! in_array( $quiz_id, $quizzes ) ) {
2040
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2040
+						add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2041 2041
 						$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2042 2042
 						update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2043
-			    	}
2043
+					}
2044 2044
 
2045
-			    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2045
+					add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2046 2046
 					$question_type = Sensei()->question->get_question_type( $question_id );
2047 2047
 
2048 2048
 					$return .= $this->quiz_panel_question( $question_type, $question_count, $question_id );
@@ -2064,7 +2064,7 @@  discard block
 block discarded – undo
2064 2064
 		} // End If Statement
2065 2065
 
2066 2066
 		if ( ! wp_verify_nonce( $nonce, 'lesson_update_grade_type_nonce' )
2067
-        || ! current_user_can( 'edit_lessons' ) ) {
2067
+		|| ! current_user_can( 'edit_lessons' ) ) {
2068 2068
 
2069 2069
 			die('');
2070 2070
 
@@ -2084,8 +2084,8 @@  discard block
 block discarded – undo
2084 2084
 			$nonce = esc_html( $_POST['lesson_update_question_order_nonce'] );
2085 2085
 		} // End If Statement
2086 2086
 
2087
-        if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_nonce' )
2088
-            ||! current_user_can( 'edit_lessons' ) ) {
2087
+		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_nonce' )
2088
+			||! current_user_can( 'edit_lessons' ) ) {
2089 2089
 			die('');
2090 2090
 		} // End If Statement
2091 2091
 
@@ -2111,7 +2111,7 @@  discard block
 block discarded – undo
2111 2111
 			$nonce = esc_html( $_POST['lesson_update_question_order_random_nonce'] );
2112 2112
 		} // End If Statement
2113 2113
 		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_random_nonce' )
2114
-            || ! current_user_can( 'edit_lessons' ) ) {
2114
+			|| ! current_user_can( 'edit_lessons' ) ) {
2115 2115
 
2116 2116
 			die('');
2117 2117
 
@@ -2161,34 +2161,34 @@  discard block
 block discarded – undo
2161 2161
 		$post_content = $course_content;
2162 2162
 		// Course Query Arguments
2163 2163
 		$post_type_args = array(	'post_content' => $post_content,
2164
-  		    						'post_status' => $post_status,
2165
-  		    						'post_title' => $post_title,
2166
-  		    						'post_type' => $post_type
2167
-  		    						);
2164
+  									'post_status' => $post_status,
2165
+  									'post_title' => $post_title,
2166
+  									'post_type' => $post_type
2167
+  									);
2168 2168
   		// Only save if there is a valid title
2169 2169
   		if ( $post_title != '' ) {
2170
-  		    // Check for prerequisite courses & product id
2171
-  		    $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2172
-  		    $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2173
-  		    $course_category_id = absint( $data[ 'course_category' ] );
2174
-  		    if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2175
-  		    // Insert or Update the Lesson Quiz
2176
-		    if ( 0 < $course_id ) {
2177
-		    	$post_type_args[ 'ID' ] = $course_id;
2178
-		    	$course_id = wp_update_post($post_type_args);
2179
-		    	update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2180
-		    	update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2181
-		    	if ( 0 < $course_category_id ) {
2182
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2183
-		    	} // End If Statement
2184
-		    } else {
2185
-		    	$course_id = wp_insert_post($post_type_args);
2186
-		    	add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2187
-		    	add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2188
-		    	if ( 0 < $course_category_id ) {
2189
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2190
-		    	} // End If Statement
2191
-		    } // End If Statement
2170
+  			// Check for prerequisite courses & product id
2171
+  			$course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2172
+  			$course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2173
+  			$course_category_id = absint( $data[ 'course_category' ] );
2174
+  			if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2175
+  			// Insert or Update the Lesson Quiz
2176
+			if ( 0 < $course_id ) {
2177
+				$post_type_args[ 'ID' ] = $course_id;
2178
+				$course_id = wp_update_post($post_type_args);
2179
+				update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2180
+				update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2181
+				if ( 0 < $course_category_id ) {
2182
+					wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2183
+				} // End If Statement
2184
+			} else {
2185
+				$course_id = wp_insert_post($post_type_args);
2186
+				add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2187
+				add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2188
+				if ( 0 < $course_category_id ) {
2189
+					wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2190
+				} // End If Statement
2191
+			} // End If Statement
2192 2192
 		} // End If Statement
2193 2193
   		// Check that the insert or update saved by testing the post id
2194 2194
   		if ( 0 < $course_id ) {
@@ -2279,17 +2279,17 @@  discard block
 block discarded – undo
2279 2279
 		$answer_feedback = '';
2280 2280
 		if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) {
2281 2281
 
2282
-            $answer_feedback = $data[ 'answer_feedback_boolean' ];
2282
+			$answer_feedback = $data[ 'answer_feedback_boolean' ];
2283 2283
 
2284 2284
 		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2285 2285
 
2286
-            $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2286
+			$answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2287 2287
 
2288
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2288
+		}elseif( isset( $data[ 'answer_feedback' ] )  ){
2289 2289
 
2290
-            $answer_feedback = $data[ 'answer_feedback' ];
2290
+			$answer_feedback = $data[ 'answer_feedback' ];
2291 2291
 
2292
-        } // End If Statement
2292
+		} // End If Statement
2293 2293
 
2294 2294
 		$post_title = $question_text;
2295 2295
 		$post_author = $data[ 'post_author' ];
@@ -2304,10 +2304,10 @@  discard block
 block discarded – undo
2304 2304
 		}
2305 2305
 		// Question Query Arguments
2306 2306
 		$post_type_args = array(	'post_content' => $post_content,
2307
-  		    						'post_status' => $post_status,
2308
-  		    						'post_title' => $post_title,
2309
-  		    						'post_type' => $post_type
2310
-  		    						);
2307
+  									'post_status' => $post_status,
2308
+  									'post_title' => $post_title,
2309
+  									'post_type' => $post_type
2310
+  									);
2311 2311
 
2312 2312
   		// Remove empty values and reindex the array
2313 2313
   		if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) {
@@ -2343,14 +2343,14 @@  discard block
 block discarded – undo
2343 2343
   		if ( $post_title != '' ) {
2344 2344
 
2345 2345
   			// Get Quiz ID for the question
2346
-  		    $quiz_id = $data['quiz_id'];
2346
+  			$quiz_id = $data['quiz_id'];
2347 2347
 
2348
-  		    // Get question media
2348
+  			// Get question media
2349 2349
 			$question_media = $data['question_media'];
2350 2350
 
2351
-  		    // Get answer order
2352
-  		    $answer_order = '';
2353
-  		    if( isset( $data['answer_order'] ) ) {
2351
+  			// Get answer order
2352
+  			$answer_order = '';
2353
+  			if( isset( $data['answer_order'] ) ) {
2354 2354
 				$answer_order = $data['answer_order'];
2355 2355
 			}
2356 2356
 
@@ -2360,38 +2360,38 @@  discard block
 block discarded – undo
2360 2360
 				$random_order = $data['random_order'];
2361 2361
 			}
2362 2362
 
2363
-  		    // Insert or Update the question
2364
-  		    if ( 0 < $question_id ) {
2365
-
2366
-  		    	$post_type_args[ 'ID' ] = $question_id;
2367
-		    	$question_id = wp_update_post( $post_type_args );
2368
-
2369
-		    	// Update poast meta
2370
-		    	if( 'quiz' == $context ) {
2371
-		    		$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2372
-		    		if( ! in_array( $quiz_id, $quizzes ) ) {
2373
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2374
-			    	}
2375
-		    	}
2376
-
2377
-		    	update_post_meta( $question_id, '_question_grade', $question_grade );
2378
-		    	update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2379
-		    	update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2380
-		    	update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2381
-		    	update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2382
-		    	update_post_meta( $question_id, '_question_media', $question_media );
2383
-		    	update_post_meta( $question_id, '_answer_order', $answer_order );
2384
-		    	update_post_meta( $question_id, '_random_order', $random_order );
2385
-
2386
-		    	if( 'quiz' != $context ) {
2387
-		    		wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2388
-		    	}
2363
+  			// Insert or Update the question
2364
+  			if ( 0 < $question_id ) {
2365
+
2366
+  				$post_type_args[ 'ID' ] = $question_id;
2367
+				$question_id = wp_update_post( $post_type_args );
2368
+
2369
+				// Update poast meta
2370
+				if( 'quiz' == $context ) {
2371
+					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2372
+					if( ! in_array( $quiz_id, $quizzes ) ) {
2373
+						add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2374
+					}
2375
+				}
2376
+
2377
+				update_post_meta( $question_id, '_question_grade', $question_grade );
2378
+				update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2379
+				update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2380
+				update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2381
+				update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2382
+				update_post_meta( $question_id, '_question_media', $question_media );
2383
+				update_post_meta( $question_id, '_answer_order', $answer_order );
2384
+				update_post_meta( $question_id, '_random_order', $random_order );
2385
+
2386
+				if( 'quiz' != $context ) {
2387
+					wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2388
+				}
2389 2389
 				// Don't store empty value, no point
2390 2390
 				if ( !empty($answer_feedback) ) {
2391 2391
 					update_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2392 2392
 				}
2393 2393
 
2394
-		    } else {
2394
+			} else {
2395 2395
 				$question_id = wp_insert_post( $post_type_args );
2396 2396
 				$question_count = intval( $data['question_count'] );
2397 2397
 				++$question_count;
@@ -2404,29 +2404,29 @@  discard block
 block discarded – undo
2404 2404
 				}
2405 2405
 
2406 2406
 				if( isset( $question_grade ) ) {
2407
-		    		add_post_meta( $question_id, '_question_grade', $question_grade );
2408
-		    	}
2409
-		    	add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2410
-		    	add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2411
-		    	add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2412
-		    	add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2413
-		    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2414
-		    	add_post_meta( $question_id, '_question_media', $question_media );
2415
-		    	add_post_meta( $question_id, '_answer_order', $answer_order );
2416
-		    	add_post_meta( $question_id, '_random_order', $random_order );
2407
+					add_post_meta( $question_id, '_question_grade', $question_grade );
2408
+				}
2409
+				add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2410
+				add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2411
+				add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2412
+				add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2413
+				add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2414
+				add_post_meta( $question_id, '_question_media', $question_media );
2415
+				add_post_meta( $question_id, '_answer_order', $answer_order );
2416
+				add_post_meta( $question_id, '_random_order', $random_order );
2417 2417
 				// Don't store empty value, no point
2418 2418
 				if ( !empty($answer_feedback) ) {
2419 2419
 					add_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2420 2420
 				}
2421 2421
 
2422
-		    	// Set the post terms for question-type
2423
-			    wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2422
+				// Set the post terms for question-type
2423
+				wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2424 2424
 
2425
-			    if( $question_category ) {
2426
-	    			wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2427
-	    		}
2425
+				if( $question_category ) {
2426
+					wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2427
+				}
2428 2428
 
2429
-		    } // End If Statement
2429
+			} // End If Statement
2430 2430
 		} // End If Statement
2431 2431
   		// Check that the insert or update saved by testing the post id
2432 2432
   		if ( 0 < $question_id ) {
@@ -2475,7 +2475,7 @@  discard block
 block discarded – undo
2475 2475
 	public function lesson_complexities() {
2476 2476
 
2477 2477
 		// V2 - make filter for this array
2478
-        $lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2478
+		$lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2479 2479
 									'std' => __( 'Standard', 'woothemes-sensei' ),
2480 2480
 									'hard' => __( 'Hard', 'woothemes-sensei' )
2481 2481
 									);
@@ -2542,14 +2542,14 @@  discard block
 block discarded – undo
2542 2542
 		$post_args = array(	'post_type' 		=> 'quiz',
2543 2543
 							'posts_per_page' 		=> 1,
2544 2544
 							'orderby'         	=> 'title',
2545
-    						'order'           	=> 'DESC',
2546
-    						'post_parent'      	=> $lesson_id,
2547
-    						'post_status'		=> $post_status,
2545
+							'order'           	=> 'DESC',
2546
+							'post_parent'      	=> $lesson_id,
2547
+							'post_status'		=> $post_status,
2548 2548
 							'suppress_filters' 	=> 0,
2549 2549
 							'fields'            => $fields
2550 2550
 							);
2551 2551
 		$posts_array = get_posts( $post_args );
2552
-        $quiz_id = array_shift($posts_array);
2552
+		$quiz_id = array_shift($posts_array);
2553 2553
 
2554 2554
 		return $quiz_id;
2555 2555
 	} // End lesson_quizzes()
@@ -2557,34 +2557,34 @@  discard block
 block discarded – undo
2557 2557
 
2558 2558
 	/**
2559 2559
 	 * Fetches all the questions for a quiz depending on certain conditions.
2560
-     *
2561
-     * Determine which questions should be shown depending on:
2562
-     * - admin/teacher selected questions to be shown
2563
-     * - questions shown to a user previously (saved as asked questions)
2564
-     * - limit number of questions lesson setting
2565 2560
 	 *
2566
-     * @since 1.0
2561
+	 * Determine which questions should be shown depending on:
2562
+	 * - admin/teacher selected questions to be shown
2563
+	 * - questions shown to a user previously (saved as asked questions)
2564
+	 * - limit number of questions lesson setting
2565
+	 *
2566
+	 * @since 1.0
2567 2567
 	 * @param int $quiz_id (default: 0)
2568 2568
 	 * @param string $post_status (default: 'publish')
2569 2569
 	 * @param string $orderby (default: 'meta_value_num title')
2570 2570
 	 * @param string $order (default: 'ASC')
2571
-     *
2571
+	 *
2572 2572
 	 * @return array $questions { $question type WP_Post }
2573 2573
 	 */
2574 2574
 	public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) {
2575 2575
 
2576 2576
 		$quiz_id = (string) $quiz_id;
2577
-        $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2577
+		$quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2578 2578
 
2579
-        // setup the user id
2580
-        if( is_admin() ) {
2581
-            $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2582
-        } else {
2583
-            $user_id = get_current_user_id();
2584
-        }
2579
+		// setup the user id
2580
+		if( is_admin() ) {
2581
+			$user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2582
+		} else {
2583
+			$user_id = get_current_user_id();
2584
+		}
2585 2585
 
2586
-        // get the users current status on the lesson
2587
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2586
+		// get the users current status on the lesson
2587
+		$user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2588 2588
 
2589 2589
 		// Set the default question order if it has not already been set for this quiz
2590 2590
 		$this->set_default_question_order( $quiz_id );
@@ -2614,14 +2614,14 @@  discard block
 block discarded – undo
2614 2614
 			'suppress_filters' 	=> 0
2615 2615
 		);
2616 2616
 
2617
-        //query the questions
2617
+		//query the questions
2618 2618
 		$questions_query = new WP_Query( $question_query_args );
2619 2619
 
2620
-        // Set return array to initially include all items
2621
-        $questions = $questions_query->posts;
2620
+		// Set return array to initially include all items
2621
+		$questions = $questions_query->posts;
2622 2622
 
2623
-        // set the questions array that will be manipulated within this function
2624
-        $questions_array = $questions_query->posts;
2623
+		// set the questions array that will be manipulated within this function
2624
+		$questions_array = $questions_query->posts;
2625 2625
 
2626 2626
 		// If viewing quiz on frontend or in grading then only single questions must be shown
2627 2627
 		$selected_questions = false;
@@ -2734,36 +2734,36 @@  discard block
 block discarded – undo
2734 2734
 			}
2735 2735
 		}
2736 2736
 
2737
-        // Save the questions that will be asked for the current user
2738
-        // this happens only once per user/quiz, unless the user resets the quiz
2739
-        if( ! is_admin() ){
2737
+		// Save the questions that will be asked for the current user
2738
+		// this happens only once per user/quiz, unless the user resets the quiz
2739
+		if( ! is_admin() ){
2740 2740
 
2741
-            if( $user_lesson_status ) {
2741
+			if( $user_lesson_status ) {
2742 2742
 
2743
-                $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2744
-                if ( empty($questions_asked) && $user_lesson_status) {
2743
+				$questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2744
+				if ( empty($questions_asked) && $user_lesson_status) {
2745 2745
 
2746
-                    $questions_asked = array();
2747
-                    foreach ($questions as $question) {
2746
+					$questions_asked = array();
2747
+					foreach ($questions as $question) {
2748 2748
 
2749
-                        $questions_asked[] = $question->ID;
2749
+						$questions_asked[] = $question->ID;
2750 2750
 
2751
-                    }
2751
+					}
2752 2752
 
2753
-                    // save the questions asked id
2754
-                    $questions_asked_csv = implode(',', $questions_asked);
2755
-                    update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv);
2753
+					// save the questions asked id
2754
+					$questions_asked_csv = implode(',', $questions_asked);
2755
+					update_comment_meta($user_lesson_status->comment_ID, 'questions_asked', $questions_asked_csv);
2756 2756
 
2757
-                }
2758
-            }
2759
-        }
2757
+				}
2758
+			}
2759
+		}
2760 2760
 
2761
-        /**
2762
-         * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions
2763
-         *
2764
-         * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2765
-         * @since 1.8.0
2766
-         */
2761
+		/**
2762
+		 * Filter the questions returned by Sensei_Lesson::lessons_quiz_questions
2763
+		 *
2764
+		 * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2765
+		 * @since 1.8.0
2766
+		 */
2767 2767
 		return apply_filters( 'sensei_lesson_quiz_questions', $questions,  $quiz_id  );
2768 2768
 
2769 2769
 	} // End lesson_quiz_questions()
@@ -2867,7 +2867,7 @@  discard block
 block discarded – undo
2867 2867
  			// Display Image Placeholder if none
2868 2868
 			if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) {
2869 2869
 
2870
-                $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2870
+				$img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2871 2871
 
2872 2872
 			} // End If Statement
2873 2873
 
@@ -2879,418 +2879,418 @@  discard block
 block discarded – undo
2879 2879
 
2880 2880
 	} // End lesson_image()
2881 2881
 
2882
-    /**
2883
-     * Ooutpu the lesson image
2884
-     *
2885
-     * @since 1.9.0
2886
-     * @param integer $lesson_id
2887
-     */
2888
-    public static function the_lesson_image( $lesson_id = 0 ){
2882
+	/**
2883
+	 * Ooutpu the lesson image
2884
+	 *
2885
+	 * @since 1.9.0
2886
+	 * @param integer $lesson_id
2887
+	 */
2888
+	public static function the_lesson_image( $lesson_id = 0 ){
2889 2889
 
2890
-        echo Sensei()->lesson->lesson_image( $lesson_id );
2890
+		echo Sensei()->lesson->lesson_image( $lesson_id );
2891 2891
 
2892
-    }
2892
+	}
2893 2893
 
2894 2894
 	/**
2895 2895
 	 * Returns the the lesson excerpt.
2896 2896
 	 *
2897 2897
 	 * @param WP_Post $lesson
2898
-     * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2898
+	 * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2899 2899
 	 * @return string
2900 2900
 	 */
2901 2901
 	public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) {
2902 2902
 		$html = '';
2903 2903
 		if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) {
2904 2904
 
2905
-            $excerpt =  $lesson->post_excerpt;
2905
+			$excerpt =  $lesson->post_excerpt;
2906 2906
 
2907
-            // if $add_p_tags true wrap with <p> else return the excerpt as is
2908
-            $html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2907
+			// if $add_p_tags true wrap with <p> else return the excerpt as is
2908
+			$html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2909 2909
 
2910 2910
 		}
2911 2911
 		return apply_filters( 'sensei_lesson_excerpt', $html );
2912 2912
 
2913 2913
 	} // End lesson_excerpt()
2914 2914
 
2915
-    /**
2916
-     * Returns the course for a given lesson
2917
-     *
2918
-     * @since 1.7.4
2919
-     * @access public
2920
-     *
2921
-     * @param int $lesson_id
2922
-     * @return int|bool $course_id or bool when nothing is found.
2923
-     */
2924
-     public function get_course_id( $lesson_id ){
2925
-
2926
-         if( ! isset( $lesson_id ) || empty( $lesson_id )
2927
-         ||  'lesson' != get_post_type( $lesson_id ) ){
2928
-             return false;
2929
-         }
2930
-
2931
-         $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2932
-
2933
-         // make sure the course id is valid
2934
-         if( empty( $lesson_course_id )
2935
-             || is_array( $lesson_course_id )
2936
-             || intval( $lesson_course_id ) < 1
2937
-             || 'course' != get_post_type( $lesson_course_id ) ){
2938
-
2939
-             return false;
2940
-
2941
-         }
2942
-
2943
-         return $lesson_course_id;
2944
-
2945
-     }// en get_course_id
2946
-
2947
-    /**
2948
-     * Add the admin all lessons screen edit options.
2949
-     *
2950
-     * The fields in this function work for both quick and bulk edit. The ID attributes is used
2951
-     * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then
2952
-     * name attribute is will be used by the quick edit and submitted via standard POST. This
2953
-     * will use this classes save_post_meta function to save the new field data.
2954
-     *
2955
-     * @hooked quick_edit_custom_box
2956
-     * @hooked bulk_edit_custom_box
2957
-     *
2958
-     * @since 1.8.0
2959
-     *
2960
-     * @param string $column_name
2961
-     * @param string $post_type
2962
-     * @return void
2963
-     */
2964
-    public function all_lessons_edit_fields( $column_name, $post_type ) {
2965
-
2966
-        // only show these options ont he lesson post type edit screen
2967
-        if( 'lesson' != $post_type || 'lesson-course' != $column_name
2968
-            || ! current_user_can( 'edit_lessons' ) ) {
2969
-            return;
2970
-        }
2971
-
2972
-        ?>
2915
+	/**
2916
+	 * Returns the course for a given lesson
2917
+	 *
2918
+	 * @since 1.7.4
2919
+	 * @access public
2920
+	 *
2921
+	 * @param int $lesson_id
2922
+	 * @return int|bool $course_id or bool when nothing is found.
2923
+	 */
2924
+	 public function get_course_id( $lesson_id ){
2925
+
2926
+		 if( ! isset( $lesson_id ) || empty( $lesson_id )
2927
+		 ||  'lesson' != get_post_type( $lesson_id ) ){
2928
+			 return false;
2929
+		 }
2930
+
2931
+		 $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2932
+
2933
+		 // make sure the course id is valid
2934
+		 if( empty( $lesson_course_id )
2935
+			 || is_array( $lesson_course_id )
2936
+			 || intval( $lesson_course_id ) < 1
2937
+			 || 'course' != get_post_type( $lesson_course_id ) ){
2938
+
2939
+			 return false;
2940
+
2941
+		 }
2942
+
2943
+		 return $lesson_course_id;
2944
+
2945
+	 }// en get_course_id
2946
+
2947
+	/**
2948
+	 * Add the admin all lessons screen edit options.
2949
+	 *
2950
+	 * The fields in this function work for both quick and bulk edit. The ID attributes is used
2951
+	 * by bulk edit javascript in the front end to retrieve the new values set byt the user. Then
2952
+	 * name attribute is will be used by the quick edit and submitted via standard POST. This
2953
+	 * will use this classes save_post_meta function to save the new field data.
2954
+	 *
2955
+	 * @hooked quick_edit_custom_box
2956
+	 * @hooked bulk_edit_custom_box
2957
+	 *
2958
+	 * @since 1.8.0
2959
+	 *
2960
+	 * @param string $column_name
2961
+	 * @param string $post_type
2962
+	 * @return void
2963
+	 */
2964
+	public function all_lessons_edit_fields( $column_name, $post_type ) {
2965
+
2966
+		// only show these options ont he lesson post type edit screen
2967
+		if( 'lesson' != $post_type || 'lesson-course' != $column_name
2968
+			|| ! current_user_can( 'edit_lessons' ) ) {
2969
+			return;
2970
+		}
2971
+
2972
+		?>
2973 2973
         <fieldset class="sensei-edit-field-set inline-edit-lesson">
2974 2974
             <div class="sensei-inline-edit-col column-<?php echo $column_name ?>">
2975 2975
                     <?php
2976
-                    echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2977
-                    // create a nonce field to be  used as a security measure when saving the data
2978
-                    wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2979
-                    wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2980
-
2981
-                    // unchanged option - we need this in because
2982
-                    // the default option in bulk edit should not be empty. If it is
2983
-                    // the user will erase data they didn't want to touch.
2984
-                    $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2985
-
2986
-                    //
2987
-                    //course selection
2988
-                    //
2989
-                    $courses =  WooThemes_Sensei_Course::get_all_courses();
2990
-                    $course_options = array();
2991
-                    if ( count( $courses ) > 0 ) {
2992
-                        foreach ($courses as $course ){
2993
-                            $course_options[ $course->ID ] = get_the_title( $course->ID );
2994
-                        }
2995
-                    }
2996
-                    //pre-append the no change option
2997
-                    $course_options['-1']=  $no_change_text;
2998
-                    $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2999
-                    $course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
3000
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
3001
-
3002
-                    //
3003
-                    // lesson complexity selection
3004
-                    //
3005
-                    $lesson_complexities =  $this->lesson_complexities();
3006
-                    //pre-append the no change option
3007
-                    $lesson_complexities['-1']=  $no_change_text;
3008
-                    $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
3009
-                    $complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
3010
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
3011
-
3012
-                    ?>
2976
+					echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2977
+					// create a nonce field to be  used as a security measure when saving the data
2978
+					wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2979
+					wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2980
+
2981
+					// unchanged option - we need this in because
2982
+					// the default option in bulk edit should not be empty. If it is
2983
+					// the user will erase data they didn't want to touch.
2984
+					$no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2985
+
2986
+					//
2987
+					//course selection
2988
+					//
2989
+					$courses =  WooThemes_Sensei_Course::get_all_courses();
2990
+					$course_options = array();
2991
+					if ( count( $courses ) > 0 ) {
2992
+						foreach ($courses as $course ){
2993
+							$course_options[ $course->ID ] = get_the_title( $course->ID );
2994
+						}
2995
+					}
2996
+					//pre-append the no change option
2997
+					$course_options['-1']=  $no_change_text;
2998
+					$course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2999
+					$course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
3000
+					echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
3001
+
3002
+					//
3003
+					// lesson complexity selection
3004
+					//
3005
+					$lesson_complexities =  $this->lesson_complexities();
3006
+					//pre-append the no change option
3007
+					$lesson_complexities['-1']=  $no_change_text;
3008
+					$complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
3009
+					$complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
3010
+					echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
3011
+
3012
+					?>
3013 3013
 
3014 3014
                     <h4><?php _e('Quiz Settings', 'woothemes-sensei'); ?> </h4>
3015 3015
 
3016 3016
                     <?php
3017 3017
 
3018
-                    //
3019
-                    // Lesson require pass to complete
3020
-                    //
3021
-                    $pass_required_options = array(
3022
-                        '-1' => $no_change_text,
3023
-                         '0' => __('No','woothemes'),
3024
-                         '1' => __('Yes','woothemes'),
3025
-                    );
3026
-
3027
-                    $pass_required_select_attributes = array( 'name'=> 'pass_required',
3028
-                                                                'id'=> 'sensei-edit-lesson-pass-required',
3029
-                                                                'class'=>' '   );
3030
-                    $require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3031
-                    echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3032
-
3033
-                    //
3034
-                    // Quiz pass percentage
3035
-                    //
3036
-                    $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3037
-                    echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3038
-
3039
-                    //
3040
-                    // Enable quiz reset button
3041
-                    //
3042
-                    $quiz_reset_select__options = array(
3043
-                        '-1' => $no_change_text,
3044
-                        '0' => __('No','woothemes'),
3045
-                        '1' => __('Yes','woothemes'),
3046
-                    );
3047
-                    $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3048
-                    $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3049
-                    $quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3050
-                    echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3051
-
3052
-                    ?>
3018
+					//
3019
+					// Lesson require pass to complete
3020
+					//
3021
+					$pass_required_options = array(
3022
+						'-1' => $no_change_text,
3023
+						 '0' => __('No','woothemes'),
3024
+						 '1' => __('Yes','woothemes'),
3025
+					);
3026
+
3027
+					$pass_required_select_attributes = array( 'name'=> 'pass_required',
3028
+																'id'=> 'sensei-edit-lesson-pass-required',
3029
+																'class'=>' '   );
3030
+					$require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3031
+					echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3032
+
3033
+					//
3034
+					// Quiz pass percentage
3035
+					//
3036
+					$quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3037
+					echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3038
+
3039
+					//
3040
+					// Enable quiz reset button
3041
+					//
3042
+					$quiz_reset_select__options = array(
3043
+						'-1' => $no_change_text,
3044
+						'0' => __('No','woothemes'),
3045
+						'1' => __('Yes','woothemes'),
3046
+					);
3047
+					$quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3048
+					$quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3049
+					$quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3050
+					echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3051
+
3052
+					?>
3053 3053
             </div>
3054 3054
         </fieldset>
3055 3055
     <?php
3056
-    }// all_lessons_edit_fields
3057
-
3058
-    /**
3059
-     * Create the html for the edit field
3060
-     *
3061
-     * Wraps the passed in field and title combination with the correct html.
3062
-     *
3063
-     * @since 1.8.0
3064
-     *
3065
-     * @param string $title that will stand to the left of the field.
3066
-     * @param string $field type markup for the field that must be wrapped.
3067
-     * @return string $field_html
3068
-     */
3069
-    public function generate_all_lessons_edit_field( $title  ,$field ){
3070
-
3071
-        $html = '';
3072
-        $html = '<div class="inline-edit-group" >';
3073
-        $html .=  '<span class="title">'. $title .'</span> ';
3074
-        $html .= '<span class="input-text-wrap">';
3075
-        $html .= $field;
3076
-        $html .= '</span>';
3077
-        $html .= '</label></div>';
3078
-
3079
-        return $html ;
3080
-
3081
-    }//end generate_all_lessons_edit_field
3082
-
3083
-    /**
3084
-     * Respond to the ajax call from the bulk edit save function. This comes
3085
-     * from the admin all lesson screen.
3086
-     *
3087
-     * @since 1.8.0
3088
-     * @return void
3089
-     */
3090
-    function save_all_lessons_edit_fields() {
3091
-
3092
-        // verify all the data before attempting to save
3093
-        if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3094
-            ||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3095
-            die();
3096
-        }
3097
-
3098
-        // get our variables
3099
-        $new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3100
-        $new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3101
-        $new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3102
-        $new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3103
-        $new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3104
-        // store the values for all selected posts
3105
-        foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3106
-
3107
-            // get the quiz id needed for the quiz meta
3108
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3109
-
3110
-            // do not save the items if the value is -1 as this
3111
-            // means it was not changed
3112
-
3113
-            // update lesson course
3114
-            if( -1 != $new_course ){
3115
-                update_post_meta( $lesson_id, '_lesson_course', $new_course );
3116
-            }
3117
-            // update lesson complexity
3118
-            if( -1 != $new_complexity ){
3119
-                update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3120
-            }
3121
-
3122
-            // Quiz Related settings
3123
-            if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3124
-
3125
-                // update pass required
3126
-                if (-1 != $new_pass_required) {
3127
-
3128
-                    $checked = $new_pass_required  ? 'on' : '';
3129
-                    update_post_meta($quiz_id, '_pass_required', $checked);
3130
-                    unset( $checked );
3131
-                }
3056
+	}// all_lessons_edit_fields
3132 3057
 
3133
-                // update pass percentage
3134
-                if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3058
+	/**
3059
+	 * Create the html for the edit field
3060
+	 *
3061
+	 * Wraps the passed in field and title combination with the correct html.
3062
+	 *
3063
+	 * @since 1.8.0
3064
+	 *
3065
+	 * @param string $title that will stand to the left of the field.
3066
+	 * @param string $field type markup for the field that must be wrapped.
3067
+	 * @return string $field_html
3068
+	 */
3069
+	public function generate_all_lessons_edit_field( $title  ,$field ){
3135 3070
 
3136
-                        update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3071
+		$html = '';
3072
+		$html = '<div class="inline-edit-group" >';
3073
+		$html .=  '<span class="title">'. $title .'</span> ';
3074
+		$html .= '<span class="input-text-wrap">';
3075
+		$html .= $field;
3076
+		$html .= '</span>';
3077
+		$html .= '</label></div>';
3137 3078
 
3138
-                }
3079
+		return $html ;
3139 3080
 
3140
-                //
3141
-                // update enable quiz reset
3142
-                //
3143
-                if (-1 != $new_enable_quiz_reset ) {
3081
+	}//end generate_all_lessons_edit_field
3144 3082
 
3145
-                    $checked = $new_enable_quiz_reset ? 'on' : ''  ;
3146
-                    update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3147
-                    unset( $checked );
3083
+	/**
3084
+	 * Respond to the ajax call from the bulk edit save function. This comes
3085
+	 * from the admin all lesson screen.
3086
+	 *
3087
+	 * @since 1.8.0
3088
+	 * @return void
3089
+	 */
3090
+	function save_all_lessons_edit_fields() {
3148 3091
 
3149
-                }
3092
+		// verify all the data before attempting to save
3093
+		if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3094
+			||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3095
+			die();
3096
+		}
3150 3097
 
3098
+		// get our variables
3099
+		$new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3100
+		$new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3101
+		$new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3102
+		$new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3103
+		$new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3104
+		// store the values for all selected posts
3105
+		foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3151 3106
 
3152
-            } // end if quiz
3107
+			// get the quiz id needed for the quiz meta
3108
+			$quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3153 3109
 
3154
-        }// end for each
3110
+			// do not save the items if the value is -1 as this
3111
+			// means it was not changed
3155 3112
 
3156
-        die();
3113
+			// update lesson course
3114
+			if( -1 != $new_course ){
3115
+				update_post_meta( $lesson_id, '_lesson_course', $new_course );
3116
+			}
3117
+			// update lesson complexity
3118
+			if( -1 != $new_complexity ){
3119
+				update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3120
+			}
3157 3121
 
3158
-    } // end save_all_lessons_edit_fields
3122
+			// Quiz Related settings
3123
+			if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3159 3124
 
3160
-    /**
3161
-     * Loading the quick edit fields defaults.
3162
-     *
3163
-     * This function will localise the default values along with the script that will
3164
-     * add these values to the inputs.
3165
-     *
3166
-     * NOTE: this function runs for each row in the edit column
3167
-     *
3168
-     * @since 1.8.0
3169
-     * @return void
3170
-     */
3171
-    public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3125
+				// update pass required
3126
+				if (-1 != $new_pass_required) {
3172 3127
 
3173
-        if( 'lesson-course' != $column_name ){
3174
-            return;
3175
-        }
3176
-        // load the script
3177
-        $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3178
-        wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3128
+					$checked = $new_pass_required  ? 'on' : '';
3129
+					update_post_meta($quiz_id, '_pass_required', $checked);
3130
+					unset( $checked );
3131
+				}
3179 3132
 
3180
-        // setup the values for all meta fields
3181
-        $data = array();
3182
-        foreach( $this->meta_fields as $field ){
3133
+				// update pass percentage
3134
+				if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3183 3135
 
3184
-            $data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3136
+						update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3185 3137
 
3186
-        }
3187
-        // add quiz meta fields
3188
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3189
-        foreach( Sensei()->quiz->meta_fields as $field ){
3138
+				}
3190 3139
 
3191
-            $data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3140
+				//
3141
+				// update enable quiz reset
3142
+				//
3143
+				if (-1 != $new_enable_quiz_reset ) {
3192 3144
 
3193
-        }
3145
+					$checked = $new_enable_quiz_reset ? 'on' : ''  ;
3146
+					update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3147
+					unset( $checked );
3194 3148
 
3195
-        wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3149
+				}
3196 3150
 
3197
-    }// end quick edit admin defaults
3198 3151
 
3199
-    /**
3200
-     * Filter the classes for lessons on the single course page.
3201
-     *
3202
-     * Adds the nesecary classes depending on the user data
3203
-     *
3204
-     * @since 1.9.0
3205
-     * @param array $classes
3206
-     * @return array $classes
3207
-     */
3208
-    public static function single_course_lessons_classes( $classes ){
3152
+			} // end if quiz
3209 3153
 
3210
-        if(  is_singular('course') ){
3154
+		}// end for each
3211 3155
 
3212
-            global $post;
3213
-            $course_id = $post->ID;
3156
+		die();
3214 3157
 
3215
-            $lesson_classes = array( 'course', 'post' );
3216
-            if ( is_user_logged_in() ) {
3158
+	} // end save_all_lessons_edit_fields
3217 3159
 
3218
-                // Check if Lesson is complete
3219
-                $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3220
-                if ( $single_lesson_complete ) {
3160
+	/**
3161
+	 * Loading the quick edit fields defaults.
3162
+	 *
3163
+	 * This function will localise the default values along with the script that will
3164
+	 * add these values to the inputs.
3165
+	 *
3166
+	 * NOTE: this function runs for each row in the edit column
3167
+	 *
3168
+	 * @since 1.8.0
3169
+	 * @return void
3170
+	 */
3171
+	public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3221 3172
 
3222
-                    $lesson_classes[] = 'lesson-completed';
3173
+		if( 'lesson-course' != $column_name ){
3174
+			return;
3175
+		}
3176
+		// load the script
3177
+		$suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3178
+		wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3223 3179
 
3224
-                } // End If Statement
3180
+		// setup the values for all meta fields
3181
+		$data = array();
3182
+		foreach( $this->meta_fields as $field ){
3225 3183
 
3226
-            } // End If Statement
3184
+			$data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3227 3185
 
3228
-            $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3229
-            if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3186
+		}
3187
+		// add quiz meta fields
3188
+		$quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3189
+		foreach( Sensei()->quiz->meta_fields as $field ){
3230 3190
 
3231
-                $lesson_classes[] = 'lesson-preview';
3191
+			$data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3232 3192
 
3233
-            }
3193
+		}
3194
+
3195
+		wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3196
+
3197
+	}// end quick edit admin defaults
3198
+
3199
+	/**
3200
+	 * Filter the classes for lessons on the single course page.
3201
+	 *
3202
+	 * Adds the nesecary classes depending on the user data
3203
+	 *
3204
+	 * @since 1.9.0
3205
+	 * @param array $classes
3206
+	 * @return array $classes
3207
+	 */
3208
+	public static function single_course_lessons_classes( $classes ){
3234 3209
 
3235
-            $classes = array_merge( $classes, $lesson_classes  );
3210
+		if(  is_singular('course') ){
3236 3211
 
3237
-        }
3212
+			global $post;
3213
+			$course_id = $post->ID;
3238 3214
 
3239
-        return $classes;
3215
+			$lesson_classes = array( 'course', 'post' );
3216
+			if ( is_user_logged_in() ) {
3240 3217
 
3241
-    }// end single_course_lessons_classes
3218
+				// Check if Lesson is complete
3219
+				$single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3220
+				if ( $single_lesson_complete ) {
3242 3221
 
3243
-    /**
3244
-     * Output the lesson meta for the given lesson
3245
-     *
3246
-     * @since 1.9.0
3247
-     * @param $lesson_id
3248
-     */
3249
-    public static function the_lesson_meta( $lesson_id ){
3222
+					$lesson_classes[] = 'lesson-completed';
3250 3223
 
3251
-        global $wp_query;
3252
-        $loop_lesson_number = $wp_query->current_post + 1;
3224
+				} // End If Statement
3225
+
3226
+			} // End If Statement
3253 3227
 
3254
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
3255
-        $single_lesson_complete = false;
3256
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3228
+			$is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3229
+			if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3257 3230
 
3258
-        // Get Lesson data
3259
-        $complexity_array = Sensei()->lesson->lesson_complexities();
3231
+				$lesson_classes[] = 'lesson-preview';
3260 3232
 
3261
-        $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3262
-        if ( '' != $lesson_complexity ) {
3233
+			}
3263 3234
 
3264
-            $lesson_complexity = $complexity_array[$lesson_complexity];
3235
+			$classes = array_merge( $classes, $lesson_classes  );
3265 3236
 
3266
-        }
3267
-        $user_info = get_userdata( absint( get_post()->post_author ) );
3268
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3269
-        $preview_label = '';
3270
-        if ( $is_preview && !$is_user_taking_course ) {
3237
+		}
3271 3238
 
3272
-            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3273
-            $preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3239
+		return $classes;
3274 3240
 
3275
-        }
3241
+	}// end single_course_lessons_classes
3276 3242
 
3243
+	/**
3244
+	 * Output the lesson meta for the given lesson
3245
+	 *
3246
+	 * @since 1.9.0
3247
+	 * @param $lesson_id
3248
+	 */
3249
+	public static function the_lesson_meta( $lesson_id ){
3277 3250
 
3278
-        $count_markup= '';
3279
-        /**
3280
-         * Filter for if you want the $lesson_count to show next to the lesson.
3281
-         *
3282
-         * @since 1.0
3283
-         * @param bool default false.
3284
-         */
3285
-        if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3251
+		global $wp_query;
3252
+		$loop_lesson_number = $wp_query->current_post + 1;
3286 3253
 
3287
-            $count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3254
+		$course_id = Sensei()->lesson->get_course_id( $lesson_id );
3255
+		$single_lesson_complete = false;
3256
+		$is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3288 3257
 
3289
-        }
3258
+		// Get Lesson data
3259
+		$complexity_array = Sensei()->lesson->lesson_complexities();
3290 3260
 
3291
-        $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3261
+		$lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3262
+		if ( '' != $lesson_complexity ) {
3292 3263
 
3293
-        ?>
3264
+			$lesson_complexity = $complexity_array[$lesson_complexity];
3265
+
3266
+		}
3267
+		$user_info = get_userdata( absint( get_post()->post_author ) );
3268
+		$is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3269
+		$preview_label = '';
3270
+		if ( $is_preview && !$is_user_taking_course ) {
3271
+
3272
+			$preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3273
+			$preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3274
+
3275
+		}
3276
+
3277
+
3278
+		$count_markup= '';
3279
+		/**
3280
+		 * Filter for if you want the $lesson_count to show next to the lesson.
3281
+		 *
3282
+		 * @since 1.0
3283
+		 * @param bool default false.
3284
+		 */
3285
+		if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3286
+
3287
+			$count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3288
+
3289
+		}
3290
+
3291
+		$heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3292
+
3293
+		?>
3294 3294
         <header>
3295 3295
             <h2>
3296 3296
                 <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>"
@@ -3303,40 +3303,40 @@  discard block
 block discarded – undo
3303 3303
 
3304 3304
                 <?php
3305 3305
 
3306
-                $meta_html = '';
3307
-                $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3306
+				$meta_html = '';
3307
+				$user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3308 3308
 
3309
-                $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3310
-                if ( '' != $lesson_length ) {
3309
+				$lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3310
+				if ( '' != $lesson_length ) {
3311 3311
 
3312
-                    $meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3312
+					$meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3313 3313
 
3314
-                }
3314
+				}
3315 3315
 
3316
-                if ( Sensei()->settings->get( 'lesson_author' ) ) {
3316
+				if ( Sensei()->settings->get( 'lesson_author' ) ) {
3317 3317
 
3318
-                    $meta_html .= '<span class="lesson-author">' .  __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
3318
+					$meta_html .= '<span class="lesson-author">' .  __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
3319 3319
 
3320
-                } // End If Statement
3321
-                if ( '' != $lesson_complexity ) {
3320
+				} // End If Statement
3321
+				if ( '' != $lesson_complexity ) {
3322 3322
 
3323
-                    $meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3323
+					$meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3324 3324
 
3325
-                }
3325
+				}
3326 3326
 
3327
-                if ( $single_lesson_complete ) {
3327
+				if ( $single_lesson_complete ) {
3328 3328
 
3329
-                    $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3329
+					$meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3330 3330
 
3331
-                } elseif ( $user_lesson_status ) {
3331
+				} elseif ( $user_lesson_status ) {
3332 3332
 
3333
-                    $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3333
+					$meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3334 3334
 
3335
-                } // End If Statement
3335
+				} // End If Statement
3336 3336
 
3337
-                echo $meta_html;
3337
+				echo $meta_html;
3338 3338
 
3339
-                ?>
3339
+				?>
3340 3340
 
3341 3341
             </p> <!-- lesson meta -->
3342 3342
 
@@ -3344,132 +3344,132 @@  discard block
 block discarded – undo
3344 3344
 
3345 3345
     <?php
3346 3346
 
3347
-    } // end the_lesson_meta
3347
+	} // end the_lesson_meta
3348 3348
 
3349
-    /**
3350
-     * Output the lessons thumbnail
3351
-     *
3352
-     * 1.9.0
3353
-     *
3354
-     * @param $lesson_id
3355
-     */
3356
-    public static function the_lesson_thumbnail( $lesson_id ){
3349
+	/**
3350
+	 * Output the lessons thumbnail
3351
+	 *
3352
+	 * 1.9.0
3353
+	 *
3354
+	 * @param $lesson_id
3355
+	 */
3356
+	public static function the_lesson_thumbnail( $lesson_id ){
3357 3357
 
3358
-        if( empty( $lesson_id ) ){
3358
+		if( empty( $lesson_id ) ){
3359 3359
 
3360
-            $lesson_id = get_the_ID();
3360
+			$lesson_id = get_the_ID();
3361 3361
 
3362
-        }
3362
+		}
3363 3363
 
3364
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3365
-            return;
3366
-        }
3364
+		if( 'lesson' != get_post_type( $lesson_id ) ){
3365
+			return;
3366
+		}
3367 3367
 
3368
-        echo Sensei()->lesson->lesson_image( $lesson_id );
3369
-    }
3368
+		echo Sensei()->lesson->lesson_image( $lesson_id );
3369
+	}
3370 3370
 
3371 3371
 
3372
-    /**
3373
-     * Alter the sensei lesson excerpt.
3374
-     *
3375
-     * @since 1.9.0
3376
-     * @param string $excerpt
3377
-     * @return string $excerpt
3378
-     */
3379
-    public static function alter_the_lesson_excerpt( $excerpt ) {
3372
+	/**
3373
+	 * Alter the sensei lesson excerpt.
3374
+	 *
3375
+	 * @since 1.9.0
3376
+	 * @param string $excerpt
3377
+	 * @return string $excerpt
3378
+	 */
3379
+	public static function alter_the_lesson_excerpt( $excerpt ) {
3380 3380
 
3381
-        if ('lesson' == get_post_type(get_the_ID())){
3381
+		if ('lesson' == get_post_type(get_the_ID())){
3382 3382
 
3383
-            // remove this hooks to avoid an infinite loop.
3384
-            remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3383
+			// remove this hooks to avoid an infinite loop.
3384
+			remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3385 3385
 
3386
-            return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3387
-        }
3386
+			return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3387
+		}
3388 3388
 
3389
-        return $excerpt;
3389
+		return $excerpt;
3390 3390
 
3391
-    }// end the_lesson_excerpt
3391
+	}// end the_lesson_excerpt
3392 3392
 
3393
-    /**
3394
-     * Returns the lesson prerequisite for the given lesson id.
3395
-     *
3396
-     * @since 1.9.0
3397
-     *
3398
-     * @param $current_lesson_id
3399
-     * @return mixed | bool | int $prerequisite_lesson_id or false
3400
-     */
3401
-    public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3393
+	/**
3394
+	 * Returns the lesson prerequisite for the given lesson id.
3395
+	 *
3396
+	 * @since 1.9.0
3397
+	 *
3398
+	 * @param $current_lesson_id
3399
+	 * @return mixed | bool | int $prerequisite_lesson_id or false
3400
+	 */
3401
+	public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3402 3402
 
3403
-        $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3403
+		$prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3404 3404
 
3405
-        // set ti to false if not a valid prerequisite lesson id
3406
-        if(  empty( $prerequisite_lesson_id )
3407
-            || 'lesson' != get_post_type( $prerequisite_lesson_id )
3408
-            || $prerequisite_lesson_id == $current_lesson_id  ) {
3405
+		// set ti to false if not a valid prerequisite lesson id
3406
+		if(  empty( $prerequisite_lesson_id )
3407
+			|| 'lesson' != get_post_type( $prerequisite_lesson_id )
3408
+			|| $prerequisite_lesson_id == $current_lesson_id  ) {
3409 3409
 
3410
-            $prerequisite_lesson_id = false;
3410
+			$prerequisite_lesson_id = false;
3411 3411
 
3412
-        }
3412
+		}
3413 3413
 
3414
-        return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3414
+		return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3415 3415
 
3416
-    }
3416
+	}
3417 3417
 
3418
-    /**
3419
-     * This function requires that you pass in the lesson you would like to check for
3420
-     * a pre-requisite and not the pre-requisite. It will check if the
3421
-     * lesson has a pre-requiste and then check if it is completed.
3422
-     *
3423
-     * @since 1.9.0
3424
-     *
3425
-     * @param $lesson_id
3426
-     * @param $user_id
3427
-     * @return bool
3428
-     */
3429
-    public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3418
+	/**
3419
+	 * This function requires that you pass in the lesson you would like to check for
3420
+	 * a pre-requisite and not the pre-requisite. It will check if the
3421
+	 * lesson has a pre-requiste and then check if it is completed.
3422
+	 *
3423
+	 * @since 1.9.0
3424
+	 *
3425
+	 * @param $lesson_id
3426
+	 * @param $user_id
3427
+	 * @return bool
3428
+	 */
3429
+	public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3430 3430
 
3431
-        if( empty( $lesson_id ) || empty( $user_id )
3432
-        || 'lesson' != get_post_type( $lesson_id )
3433
-        ||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3431
+		if( empty( $lesson_id ) || empty( $user_id )
3432
+		|| 'lesson' != get_post_type( $lesson_id )
3433
+		||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3434 3434
 
3435
-            return false;
3435
+			return false;
3436 3436
 
3437
-        }
3437
+		}
3438 3438
 
3439
-        $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3439
+		$pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3440 3440
 
3441
-        // not a valid pre-requisite so pre-requisite is completed
3442
-        if( 'lesson' != get_post_type( $pre_requisite_id )
3443
-            || ! is_numeric( $pre_requisite_id ) ){
3441
+		// not a valid pre-requisite so pre-requisite is completed
3442
+		if( 'lesson' != get_post_type( $pre_requisite_id )
3443
+			|| ! is_numeric( $pre_requisite_id ) ){
3444 3444
 
3445
-            return true;
3445
+			return true;
3446 3446
 
3447
-        }
3447
+		}
3448 3448
 
3449
-        return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3449
+		return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3450 3450
 
3451
-    }// end is_prerequisite_complete
3451
+	}// end is_prerequisite_complete
3452 3452
 
3453
-    /**
3454
-     * Show the user not taking course message if it is the case
3455
-     *
3456
-     * @since 1.9.0
3457
-     */
3458
-    public  static function user_not_taking_course_message(){
3453
+	/**
3454
+	 * Show the user not taking course message if it is the case
3455
+	 *
3456
+	 * @since 1.9.0
3457
+	 */
3458
+	public  static function user_not_taking_course_message(){
3459 3459
 
3460
-        $lesson_id = get_the_ID();
3460
+		$lesson_id = get_the_ID();
3461 3461
 
3462
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3463
-            return;
3464
-        }
3462
+		if( 'lesson' != get_post_type( $lesson_id ) ){
3463
+			return;
3464
+		}
3465 3465
 
3466
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3467
-        $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3468
-        $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3469
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3466
+		$is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3467
+		$pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3468
+		$lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3469
+		$user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3470 3470
 
3471
-        if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3472
-            ?>
3471
+		if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3472
+			?>
3473 3473
 
3474 3474
             <div class="sensei-message alert">
3475 3475
                 <?php echo Sensei()->permissions_message['message']; ?>
@@ -3477,46 +3477,46 @@  discard block
 block discarded – undo
3477 3477
 
3478 3478
             <?php
3479 3479
 
3480
-        }// end if
3480
+		}// end if
3481 3481
 
3482
-    } // end user_not_taking_course_message
3482
+	} // end user_not_taking_course_message
3483 3483
 
3484
-    /**
3485
-     * Outputs the lessons course signup lingk
3486
-     *
3487
-     * This hook runs inside the single lesson page.
3488
-     *
3489
-     * @since 1.9.0
3490
-     */
3491
-    public static function course_signup_link( ){
3484
+	/**
3485
+	 * Outputs the lessons course signup lingk
3486
+	 *
3487
+	 * This hook runs inside the single lesson page.
3488
+	 *
3489
+	 * @since 1.9.0
3490
+	 */
3491
+	public static function course_signup_link( ){
3492 3492
 
3493
-        $course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3493
+		$course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3494 3494
 
3495
-        if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3495
+		if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3496 3496
 
3497
-            return;
3497
+			return;
3498 3498
 
3499
-        }
3500
-        ?>
3499
+		}
3500
+		?>
3501 3501
 
3502 3502
         <section class="course-signup lesson-meta">
3503 3503
 
3504 3504
             <?php
3505
-            $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3505
+			$wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3506 3506
 
3507
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3507
+			if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3508 3508
 
3509
-                global $current_user;
3510
-                if( is_user_logged_in() ) {
3511
-                    wp_get_current_user();
3509
+				global $current_user;
3510
+				if( is_user_logged_in() ) {
3511
+					wp_get_current_user();
3512 3512
 
3513
-                    $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3513
+					$course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3514 3514
 
3515
-                    if( $course_purchased ) {
3515
+					if( $course_purchased ) {
3516 3516
 
3517
-                        $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3518
-                        $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3519
-                        ?>
3517
+						$prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3518
+						$course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3519
+						?>
3520 3520
                             <div class="sensei-message info">
3521 3521
 
3522 3522
                                 <?php  echo sprintf( __( 'Please complete %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); ?>
@@ -3528,14 +3528,14 @@  discard block
 block discarded – undo
3528 3528
                         <div class="sensei-message info">
3529 3529
 
3530 3530
                             <?php
3531
-                            $course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3532
-                                            . '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3533
-                                            . '">' . __( 'course', 'woothemes-sensei' )
3534
-                                            . '</a>';
3531
+							$course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3532
+											. '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3533
+											. '">' . __( 'course', 'woothemes-sensei' )
3534
+											. '</a>';
3535 3535
 
3536
-                            echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3536
+							echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3537 3537
 
3538
-                            ?>
3538
+							?>
3539 3539
 
3540 3540
                         </div>
3541 3541
                     <?php } ?>
@@ -3552,14 +3552,14 @@  discard block
 block discarded – undo
3552 3552
 
3553 3553
                 <div class="sensei-message info">
3554 3554
                     <?php
3555
-                    $course_link =  '<a href="'
3556
-                                        . esc_url( get_permalink( $course_id ) )
3557
-                                        . '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3558
-                                        . '">' . __( 'course', 'woothemes-sensei' )
3559
-                                    . '</a>';
3560
-
3561
-                    echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3562
-                    ?>
3555
+					$course_link =  '<a href="'
3556
+										. esc_url( get_permalink( $course_id ) )
3557
+										. '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3558
+										. '">' . __( 'course', 'woothemes-sensei' )
3559
+									. '</a>';
3560
+
3561
+					echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3562
+					?>
3563 3563
                 </div>
3564 3564
 
3565 3565
             <?php endif; ?>
@@ -3569,75 +3569,75 @@  discard block
 block discarded – undo
3569 3569
         </section>
3570 3570
 
3571 3571
         <?php
3572
-    }// end course_signup_link
3572
+	}// end course_signup_link
3573 3573
 
3574
-    /**
3575
-     * Show a message telling the user to complete the previous message if they haven't done so yet
3576
-     *
3577
-     * @since 1.9.0
3578
-     */
3579
-    public  static function prerequisite_complete_message(){
3574
+	/**
3575
+	 * Show a message telling the user to complete the previous message if they haven't done so yet
3576
+	 *
3577
+	 * @since 1.9.0
3578
+	 */
3579
+	public  static function prerequisite_complete_message(){
3580 3580
 
3581
-        $lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3582
-        $lesson_has_pre_requisite = $lesson_prerequisite > 0;
3583
-        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3581
+		$lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3582
+		$lesson_has_pre_requisite = $lesson_prerequisite > 0;
3583
+		if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3584 3584
 
3585
-            $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>';
3586
-            echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3585
+			$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>';
3586
+			echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3587 3587
 
3588
-        }
3588
+		}
3589 3589
 
3590
-    }
3590
+	}
3591 3591
 
3592
-    /**
3593
-     * Deprecate the sensei_lesson_archive_header hook but keep it
3594
-     * active for backwards compatibility.
3595
-     *
3596
-     * @deprecated since 1.9.0
3597
-     */
3598
-    public static function deprecate_sensei_lesson_archive_header_hook(){
3592
+	/**
3593
+	 * Deprecate the sensei_lesson_archive_header hook but keep it
3594
+	 * active for backwards compatibility.
3595
+	 *
3596
+	 * @deprecated since 1.9.0
3597
+	 */
3598
+	public static function deprecate_sensei_lesson_archive_header_hook(){
3599 3599
 
3600
-        sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3600
+		sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3601 3601
 
3602
-    }
3602
+	}
3603 3603
 
3604
-    /**
3605
-     * Outputs the the lesson archive header.
3606
-     *
3607
-     * @since  1.9.0
3608
-     * @return void
3609
-     */
3610
-    public function the_archive_header( ) {
3604
+	/**
3605
+	 * Outputs the the lesson archive header.
3606
+	 *
3607
+	 * @since  1.9.0
3608
+	 * @return void
3609
+	 */
3610
+	public function the_archive_header( ) {
3611 3611
 
3612
-        $before_html = '<header class="archive-header"><h1>';
3613
-        $after_html = '</h1></header>';
3614
-        $html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3612
+		$before_html = '<header class="archive-header"><h1>';
3613
+		$after_html = '</h1></header>';
3614
+		$html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3615 3615
 
3616
-        echo apply_filters( 'sensei_lesson_archive_title', $html );
3616
+		echo apply_filters( 'sensei_lesson_archive_title', $html );
3617 3617
 
3618
-    } // sensei_course_archive_header()
3618
+	} // sensei_course_archive_header()
3619 3619
 
3620
-    /**
3621
-     * Output the title for the single lesson page
3622
-     *
3623
-     * @global $post
3624
-     * @since 1.9.0
3625
-     */
3626
-    public static function the_title(){
3620
+	/**
3621
+	 * Output the title for the single lesson page
3622
+	 *
3623
+	 * @global $post
3624
+	 * @since 1.9.0
3625
+	 */
3626
+	public static function the_title(){
3627 3627
 
3628
-        global $post;
3628
+		global $post;
3629 3629
 
3630
-        ?>
3630
+		?>
3631 3631
         <header>
3632 3632
 
3633 3633
             <h1>
3634 3634
 
3635 3635
                 <?php
3636
-                /**
3637
-                 * Filter documented in class-sensei-messages.php the_title
3638
-                 */
3639
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3640
-                ?>
3636
+				/**
3637
+				 * Filter documented in class-sensei-messages.php the_title
3638
+				 */
3639
+				echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3640
+				?>
3641 3641
 
3642 3642
             </h1>
3643 3643
 
@@ -3645,68 +3645,68 @@  discard block
 block discarded – undo
3645 3645
 
3646 3646
         <?php
3647 3647
 
3648
-    }//the_title
3648
+	}//the_title
3649 3649
 
3650
-    /**
3651
-     * Flush the rewrite rules for a lesson post type
3652
-     *
3653
-     * @since 1.9.0
3654
-     *
3655
-     * @param $post_id
3656
-     */
3657
-    public static function flush_rewrite_rules( $post_id ){
3650
+	/**
3651
+	 * Flush the rewrite rules for a lesson post type
3652
+	 *
3653
+	 * @since 1.9.0
3654
+	 *
3655
+	 * @param $post_id
3656
+	 */
3657
+	public static function flush_rewrite_rules( $post_id ){
3658 3658
 
3659
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3659
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3660 3660
 
3661
-            return;
3661
+			return;
3662 3662
 
3663
-        }
3663
+		}
3664 3664
 
3665 3665
 
3666
-        if( 'lesson' == get_post_type( $post_id )  ){
3666
+		if( 'lesson' == get_post_type( $post_id )  ){
3667 3667
 
3668
-            Sensei()->initiate_rewrite_rules_flush();
3668
+			Sensei()->initiate_rewrite_rules_flush();
3669 3669
 
3670
-        }
3670
+		}
3671 3671
 
3672
-    }
3672
+	}
3673 3673
 
3674
-    /**
3675
-     * Output the quiz specific buttons and messaging on the single lesson page
3676
-     *
3677
-     *
3678
-     * @since 1.0.0 moved here from frontend class
3679
-     *
3680
-     * @param int $lesson_id
3681
-     * @param int $user_id
3682
-     */
3683
-    public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3674
+	/**
3675
+	 * Output the quiz specific buttons and messaging on the single lesson page
3676
+	 *
3677
+	 *
3678
+	 * @since 1.0.0 moved here from frontend class
3679
+	 *
3680
+	 * @param int $lesson_id
3681
+	 * @param int $user_id
3682
+	 */
3683
+	public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3684 3684
 
3685 3685
 
3686
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3687
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3688
-        $lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3689
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3690
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3691
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3692
-        $show_actions              = is_user_logged_in() ? true : false;
3686
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3687
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3688
+		$lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3689
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3690
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3691
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3692
+		$show_actions              = is_user_logged_in() ? true : false;
3693 3693
 
3694
-        if( intval( $lesson_prerequisite ) > 0 ) {
3694
+		if( intval( $lesson_prerequisite ) > 0 ) {
3695 3695
 
3696
-            // If the user hasn't completed the prereq then hide the current actions
3697
-            $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3696
+			// If the user hasn't completed the prereq then hide the current actions
3697
+			$show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3698 3698
 
3699
-        }
3700
-        ?>
3699
+		}
3700
+		?>
3701 3701
 
3702 3702
         <footer>
3703 3703
 
3704 3704
             <?php
3705
-            if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3705
+			if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3706 3706
 
3707
-                $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3708
-                if( $has_quiz_questions ) {
3709
-                    ?>
3707
+				$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3708
+				if( $has_quiz_questions ) {
3709
+					?>
3710 3710
 
3711 3711
                     <p>
3712 3712
 
@@ -3721,87 +3721,87 @@  discard block
 block discarded – undo
3721 3721
                     </p>
3722 3722
 
3723 3723
                     <?php
3724
-                }
3724
+				}
3725 3725
 
3726
-            } // End If Statement
3726
+			} // End If Statement
3727 3727
 
3728
-            if ( $show_actions && ! $has_user_completed_lesson ) {
3728
+			if ( $show_actions && ! $has_user_completed_lesson ) {
3729 3729
 
3730
-                sensei_complete_lesson_button();
3730
+				sensei_complete_lesson_button();
3731 3731
 
3732
-            } elseif( $show_actions ) {
3732
+			} elseif( $show_actions ) {
3733 3733
 
3734
-                sensei_reset_lesson_button();
3734
+				sensei_reset_lesson_button();
3735 3735
 
3736
-            } // End If Statement
3737
-            ?>
3736
+			} // End If Statement
3737
+			?>
3738 3738
 
3739 3739
         </footer>
3740 3740
 
3741 3741
         <?php
3742
-    } // End sensei_lesson_quiz_meta()
3742
+	} // End sensei_lesson_quiz_meta()
3743 3743
 
3744
-    /**
3745
-     * Show the lesson comments. This should be used in the loop.
3746
-     *
3747
-     * @since 1.9.0
3748
-     */
3749
-    public static function output_comments(){
3744
+	/**
3745
+	 * Show the lesson comments. This should be used in the loop.
3746
+	 *
3747
+	 * @since 1.9.0
3748
+	 */
3749
+	public static function output_comments(){
3750 3750
 
3751
-        if( ! is_user_logged_in() ){
3752
-            return;
3753
-        }
3751
+		if( ! is_user_logged_in() ){
3752
+			return;
3753
+		}
3754 3754
 
3755
-        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3756
-        $course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3757
-        $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3758
-        $user_taking_course = Sensei_Utils::user_started_course($course_id );
3755
+		$pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3756
+		$course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3757
+		$allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3758
+		$user_taking_course = Sensei_Utils::user_started_course($course_id );
3759 3759
 
3760
-        $lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3760
+		$lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3761 3761
 
3762
-        if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3762
+		if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3763 3763
 
3764
-            comments_template();
3764
+			comments_template();
3765 3765
 
3766
-        } // End If Statement
3766
+		} // End If Statement
3767 3767
 
3768
-    } //output_comments
3768
+	} //output_comments
3769 3769
 
3770
-    /**
3771
-     * Display the leeson quiz status if it should be shown
3772
-     *
3773
-     * @param int $lesson_id defaults to the global lesson id
3774
-     * @param int $user_id defaults to the current user id
3775
-     *
3776
-     * @since 1.9.0
3777
-     */
3778
-    public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3770
+	/**
3771
+	 * Display the leeson quiz status if it should be shown
3772
+	 *
3773
+	 * @param int $lesson_id defaults to the global lesson id
3774
+	 * @param int $user_id defaults to the current user id
3775
+	 *
3776
+	 * @since 1.9.0
3777
+	 */
3778
+	public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3779 3779
 
3780
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3781
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3782
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3783
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3784
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3780
+		$lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3781
+		$user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3782
+		$lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3783
+		$quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3784
+		$has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3785 3785
 
3786 3786
 
3787
-        if ( $quiz_id && is_user_logged_in()
3788
-            && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3787
+		if ( $quiz_id && is_user_logged_in()
3788
+			&& Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3789 3789
 
3790
-            $no_quiz_count = 0;
3791
-            $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3790
+			$no_quiz_count = 0;
3791
+			$has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3792 3792
 
3793
-            // Display lesson quiz status message
3794
-            if ( $has_user_completed_lesson || $has_quiz_questions ) {
3795
-                $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3796
-                echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3797
-                if( $has_quiz_questions ) {
3798
-                   // echo $status['extra'];
3799
-                } // End If Statement
3800
-            } // End If Statement
3793
+			// Display lesson quiz status message
3794
+			if ( $has_user_completed_lesson || $has_quiz_questions ) {
3795
+				$status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3796
+				echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3797
+				if( $has_quiz_questions ) {
3798
+				   // echo $status['extra'];
3799
+				} // End If Statement
3800
+			} // End If Statement
3801 3801
 
3802
-        }
3802
+		}
3803 3803
 
3804
-    }
3804
+	}
3805 3805
 
3806 3806
 } // End Class
3807 3807
 
Please login to merge, or discard this patch.
Spacing   +1091 added lines, -1091 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Sensei Lessons Class
@@ -19,83 +19,83 @@  discard block
 block discarded – undo
19 19
 	 * Constructor.
20 20
 	 * @since  1.0.0
21 21
 	 */
22
-	public function __construct () {
22
+	public function __construct() {
23 23
 
24 24
         $this->token = 'lesson';
25 25
 
26 26
 		// Setup meta fields for this post type
27
-		$this->meta_fields = array( 'lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed' );
27
+		$this->meta_fields = array('lesson_prerequisite', 'lesson_course', 'lesson_preview', 'lesson_length', 'lesson_complexity', 'lesson_video_embed');
28 28
 
29 29
         $this->question_order = '';
30 30
 
31 31
 		// Admin actions
32
-		if ( is_admin() ) {
32
+		if (is_admin()) {
33 33
 
34 34
 			// Metabox functions
35
-			add_action( 'admin_menu', array( $this, 'meta_box_setup' ), 20 );
36
-			add_action( 'save_post', array( $this, 'meta_box_save' ) );
37
-			add_action( 'save_post', array( $this, 'quiz_update' ) );
35
+			add_action('admin_menu', array($this, 'meta_box_setup'), 20);
36
+			add_action('save_post', array($this, 'meta_box_save'));
37
+			add_action('save_post', array($this, 'quiz_update'));
38 38
 
39 39
 			// Custom Write Panel Columns
40
-			add_filter( 'manage_edit-lesson_columns', array( $this, 'add_column_headings' ), 10, 1 );
41
-			add_action( 'manage_posts_custom_column', array( $this, 'add_column_data' ), 10, 2 );
40
+			add_filter('manage_edit-lesson_columns', array($this, 'add_column_headings'), 10, 1);
41
+			add_action('manage_posts_custom_column', array($this, 'add_column_data'), 10, 2);
42 42
 
43 43
 			// Add/Update question
44
-			add_action( 'wp_ajax_lesson_update_question', array( $this, 'lesson_update_question' ) );
45
-			add_action( 'wp_ajax_nopriv_lesson_update_question', array( $this, 'lesson_update_question' ) );
44
+			add_action('wp_ajax_lesson_update_question', array($this, 'lesson_update_question'));
45
+			add_action('wp_ajax_nopriv_lesson_update_question', array($this, 'lesson_update_question'));
46 46
 
47 47
 			// Add course
48
-			add_action( 'wp_ajax_lesson_add_course', array( $this, 'lesson_add_course' ) );
49
-			add_action( 'wp_ajax_nopriv_lesson_add_course', array( $this, 'lesson_add_course' ) );
48
+			add_action('wp_ajax_lesson_add_course', array($this, 'lesson_add_course'));
49
+			add_action('wp_ajax_nopriv_lesson_add_course', array($this, 'lesson_add_course'));
50 50
 
51 51
 			// Update grade type
52
-			add_action( 'wp_ajax_lesson_update_grade_type', array( $this, 'lesson_update_grade_type' ) );
53
-			add_action( 'wp_ajax_nopriv_lesson_update_grade_type', array( $this, 'lesson_update_grade_type' ) );
52
+			add_action('wp_ajax_lesson_update_grade_type', array($this, 'lesson_update_grade_type'));
53
+			add_action('wp_ajax_nopriv_lesson_update_grade_type', array($this, 'lesson_update_grade_type'));
54 54
 
55 55
 			// Update question order
56
-			add_action( 'wp_ajax_lesson_update_question_order', array( $this, 'lesson_update_question_order' ) );
57
-			add_action( 'wp_ajax_nopriv_lesson_update_question_order', array( $this, 'lesson_update_question_order' ) );
56
+			add_action('wp_ajax_lesson_update_question_order', array($this, 'lesson_update_question_order'));
57
+			add_action('wp_ajax_nopriv_lesson_update_question_order', array($this, 'lesson_update_question_order'));
58 58
 
59 59
 			//Update question order
60
-			add_action( 'wp_ajax_lesson_update_question_order_random', array( $this, 'lesson_update_question_order_random' ) );
61
-			add_action( 'wp_ajax_nopriv_lesson_update_question_order_random', array( $this, 'lesson_update_question_order_random' ) );
60
+			add_action('wp_ajax_lesson_update_question_order_random', array($this, 'lesson_update_question_order_random'));
61
+			add_action('wp_ajax_nopriv_lesson_update_question_order_random', array($this, 'lesson_update_question_order_random'));
62 62
 
63 63
 			// Get answer ID
64
-			add_action( 'wp_ajax_question_get_answer_id', array( $this, 'question_get_answer_id' ) );
65
-			add_action( 'wp_ajax_nopriv_question_get_answer_id', array( $this, 'question_get_answer_id' ) );
64
+			add_action('wp_ajax_question_get_answer_id', array($this, 'question_get_answer_id'));
65
+			add_action('wp_ajax_nopriv_question_get_answer_id', array($this, 'question_get_answer_id'));
66 66
 
67 67
 			// Add multiple questions
68
-			add_action( 'wp_ajax_lesson_add_multiple_questions', array( $this, 'lesson_add_multiple_questions' ) );
69
-			add_action( 'wp_ajax_nopriv_lesson_add_multiple_questions', array( $this, 'lesson_add_multiple_questions' ) );
68
+			add_action('wp_ajax_lesson_add_multiple_questions', array($this, 'lesson_add_multiple_questions'));
69
+			add_action('wp_ajax_nopriv_lesson_add_multiple_questions', array($this, 'lesson_add_multiple_questions'));
70 70
 
71 71
 			// Remove multiple questions
72
-			add_action( 'wp_ajax_lesson_remove_multiple_questions', array( $this, 'lesson_remove_multiple_questions' ) );
73
-			add_action( 'wp_ajax_nopriv_lesson_remove_multiple_questions', array( $this, 'lesson_remove_multiple_questions' ) );
72
+			add_action('wp_ajax_lesson_remove_multiple_questions', array($this, 'lesson_remove_multiple_questions'));
73
+			add_action('wp_ajax_nopriv_lesson_remove_multiple_questions', array($this, 'lesson_remove_multiple_questions'));
74 74
 
75 75
 			// Get question category limit
76
-			add_action( 'wp_ajax_get_question_category_limit', array( $this, 'get_question_category_limit' ) );
77
-			add_action( 'wp_ajax_nopriv_get_question_category_limit', array( $this, 'get_question_category_limit' ) );
76
+			add_action('wp_ajax_get_question_category_limit', array($this, 'get_question_category_limit'));
77
+			add_action('wp_ajax_nopriv_get_question_category_limit', array($this, 'get_question_category_limit'));
78 78
 
79 79
 			// Add existing questions
80
-			add_action( 'wp_ajax_lesson_add_existing_questions', array( $this, 'lesson_add_existing_questions' ) );
81
-			add_action( 'wp_ajax_nopriv_lesson_add_existing_questions', array( $this, 'lesson_add_existing_questions' ) );
80
+			add_action('wp_ajax_lesson_add_existing_questions', array($this, 'lesson_add_existing_questions'));
81
+			add_action('wp_ajax_nopriv_lesson_add_existing_questions', array($this, 'lesson_add_existing_questions'));
82 82
 
83 83
 			// Filter existing questions
84
-			add_action( 'wp_ajax_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
85
-			add_action( 'wp_ajax_nopriv_filter_existing_questions', array( $this, 'quiz_panel_filter_existing_questions' ) );
84
+			add_action('wp_ajax_filter_existing_questions', array($this, 'quiz_panel_filter_existing_questions'));
85
+			add_action('wp_ajax_nopriv_filter_existing_questions', array($this, 'quiz_panel_filter_existing_questions'));
86 86
 
87 87
             // output bulk edit fields
88
-            add_action( 'bulk_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
89
-            add_action( 'quick_edit_custom_box', array( $this, 'all_lessons_edit_fields' ), 10, 2 );
88
+            add_action('bulk_edit_custom_box', array($this, 'all_lessons_edit_fields'), 10, 2);
89
+            add_action('quick_edit_custom_box', array($this, 'all_lessons_edit_fields'), 10, 2);
90 90
 
91 91
             // load quick edit default values
92
-            add_action('manage_lesson_posts_custom_column', array( $this, 'set_quick_edit_admin_defaults'), 11, 2);
92
+            add_action('manage_lesson_posts_custom_column', array($this, 'set_quick_edit_admin_defaults'), 11, 2);
93 93
 
94 94
             // save bulk edit fields
95
-            add_action( 'wp_ajax_save_bulk_edit_book', array( $this, 'save_all_lessons_edit_fields' ) );
95
+            add_action('wp_ajax_save_bulk_edit_book', array($this, 'save_all_lessons_edit_fields'));
96 96
 
97 97
             // flush rewrite rules when saving a lesson
98
-            add_action('save_post', array( __CLASS__, 'flush_rewrite_rules' ) );
98
+            add_action('save_post', array(__CLASS__, 'flush_rewrite_rules'));
99 99
 
100 100
 		} else {
101 101
 			// Frontend actions
@@ -108,34 +108,34 @@  discard block
 block discarded – undo
108 108
 	 * @access public
109 109
 	 * @return void
110 110
 	 */
111
-	public function meta_box_setup () {
111
+	public function meta_box_setup() {
112 112
 
113 113
 		// Add Meta Box for Prerequisite Lesson
114
-		add_meta_box( 'lesson-prerequisite', __( 'Lesson Prerequisite', 'woothemes-sensei' ), array( $this, 'lesson_prerequisite_meta_box_content' ), $this->token, 'side', 'default' );
114
+		add_meta_box('lesson-prerequisite', __('Lesson Prerequisite', 'woothemes-sensei'), array($this, 'lesson_prerequisite_meta_box_content'), $this->token, 'side', 'default');
115 115
 
116 116
 		// Add Meta Box for Lesson Course
117
-		add_meta_box( 'lesson-course', __( 'Lesson Course', 'woothemes-sensei' ), array( $this, 'lesson_course_meta_box_content' ), $this->token, 'side', 'default' );
117
+		add_meta_box('lesson-course', __('Lesson Course', 'woothemes-sensei'), array($this, 'lesson_course_meta_box_content'), $this->token, 'side', 'default');
118 118
 
119 119
 		// Add Meta Box for Lesson Preview
120
-		add_meta_box( 'lesson-preview', __( 'Lesson Preview', 'woothemes-sensei' ), array( $this, 'lesson_preview_meta_box_content' ), $this->token, 'side', 'default' );
120
+		add_meta_box('lesson-preview', __('Lesson Preview', 'woothemes-sensei'), array($this, 'lesson_preview_meta_box_content'), $this->token, 'side', 'default');
121 121
 
122 122
 		// Add Meta Box for Lesson Information
123
-		add_meta_box( 'lesson-info', __( 'Lesson Information', 'woothemes-sensei' ), array( $this, 'lesson_info_meta_box_content' ), $this->token, 'normal', 'default' );
123
+		add_meta_box('lesson-info', __('Lesson Information', 'woothemes-sensei'), array($this, 'lesson_info_meta_box_content'), $this->token, 'normal', 'default');
124 124
 
125 125
 		// Add Meta Box for Quiz Settings
126
-		add_meta_box( 'lesson-quiz-settings', __( 'Quiz Settings', 'woothemes-sensei' ), array( $this, 'lesson_quiz_settings_meta_box_content' ), $this->token, 'normal', 'default' );
126
+		add_meta_box('lesson-quiz-settings', __('Quiz Settings', 'woothemes-sensei'), array($this, 'lesson_quiz_settings_meta_box_content'), $this->token, 'normal', 'default');
127 127
 
128 128
 		// Add Meta Box for Lesson Quiz Questions
129
-		add_meta_box( 'lesson-quiz', __( 'Quiz Questions', 'woothemes-sensei' ), array( $this, 'lesson_quiz_meta_box_content' ), $this->token, 'normal', 'default' );
129
+		add_meta_box('lesson-quiz', __('Quiz Questions', 'woothemes-sensei'), array($this, 'lesson_quiz_meta_box_content'), $this->token, 'normal', 'default');
130 130
 
131 131
 		// Remove "Custom Settings" meta box.
132
-		remove_meta_box( 'woothemes-settings', $this->token, 'normal' );
132
+		remove_meta_box('woothemes-settings', $this->token, 'normal');
133 133
 
134 134
 		// Add JS scripts
135
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
135
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
136 136
 
137 137
 		// Add CSS
138
-		add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
138
+		add_action('admin_enqueue_scripts', array($this, 'enqueue_styles'));
139 139
 
140 140
 	} // End meta_box_setup()
141 141
 
@@ -146,30 +146,30 @@  discard block
 block discarded – undo
146 146
 	 * @access public
147 147
 	 * @return void
148 148
 	 */
149
-	public function lesson_info_meta_box_content () {
149
+	public function lesson_info_meta_box_content() {
150 150
 		global $post;
151 151
 
152
-		$lesson_length = get_post_meta( $post->ID, '_lesson_length', true );
153
-		$lesson_complexity = get_post_meta( $post->ID, '_lesson_complexity', true );
152
+		$lesson_length = get_post_meta($post->ID, '_lesson_length', true);
153
+		$lesson_complexity = get_post_meta($post->ID, '_lesson_complexity', true);
154 154
 		$complexity_array = $this->lesson_complexities();
155
-		$lesson_video_embed = get_post_meta( $post->ID, '_lesson_video_embed', true );
155
+		$lesson_video_embed = get_post_meta($post->ID, '_lesson_video_embed', true);
156 156
 
157 157
 		$html = '';
158 158
 		// Lesson Length
159
-		$html .= '<p><label for="lesson_length">' . __( 'Lesson Length in minutes', 'woothemes-sensei' ) . ': </label>';
160
-		$html .= '<input type="number" id="lesson-length" name="lesson_length" class="small-text" value="' . esc_attr( $lesson_length ) . '" /></p>' . "\n";
159
+		$html .= '<p><label for="lesson_length">'.__('Lesson Length in minutes', 'woothemes-sensei').': </label>';
160
+		$html .= '<input type="number" id="lesson-length" name="lesson_length" class="small-text" value="'.esc_attr($lesson_length).'" /></p>'."\n";
161 161
 		// Lesson Complexity
162
-		$html .= '<p><label for="lesson_complexity">' . __( 'Lesson Complexity', 'woothemes-sensei' ) . ': </label>';
162
+		$html .= '<p><label for="lesson_complexity">'.__('Lesson Complexity', 'woothemes-sensei').': </label>';
163 163
 		$html .= '<select id="lesson-complexity-options" name="lesson_complexity" class="chosen_select lesson-complexity-select">';
164
-			$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
165
-			foreach ($complexity_array as $key => $value){
166
-				$html .= '<option value="' . esc_attr( $key ) . '"' . selected( $key, $lesson_complexity, false ) . '>' . esc_html( $value ) . '</option>' . "\n";
164
+			$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
165
+			foreach ($complexity_array as $key => $value) {
166
+				$html .= '<option value="'.esc_attr($key).'"'.selected($key, $lesson_complexity, false).'>'.esc_html($value).'</option>'."\n";
167 167
 			} // End For Loop
168
-		$html .= '</select></p>' . "\n";
168
+		$html .= '</select></p>'."\n";
169 169
 
170
-		$html .= '<p><label for="lesson_video_embed">' . __( 'Video Embed Code', 'woothemes-sensei' ) . ':</label><br/>' . "\n";
171
-		$html .= '<textarea rows="5" cols="50" name="lesson_video_embed" tabindex="6" id="course-video-embed">' . $lesson_video_embed . '</textarea></p>' . "\n";
172
-		$html .= '<p>' .  __( 'Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei' ) . '</p>';
170
+		$html .= '<p><label for="lesson_video_embed">'.__('Video Embed Code', 'woothemes-sensei').':</label><br/>'."\n";
171
+		$html .= '<textarea rows="5" cols="50" name="lesson_video_embed" tabindex="6" id="course-video-embed">'.$lesson_video_embed.'</textarea></p>'."\n";
172
+		$html .= '<p>'.__('Paste the embed code for your video (e.g. YouTube, Vimeo etc.) in the box above.', 'woothemes-sensei').'</p>';
173 173
 
174 174
 		echo $html;
175 175
 
@@ -181,31 +181,31 @@  discard block
 block discarded – undo
181 181
 	 * @access public
182 182
 	 * @return void
183 183
 	 */
184
-	public function lesson_prerequisite_meta_box_content () {
184
+	public function lesson_prerequisite_meta_box_content() {
185 185
 		global $post;
186 186
 		// Get existing post meta
187
-		$select_lesson_prerequisite = get_post_meta( $post->ID, '_lesson_prerequisite', true );
187
+		$select_lesson_prerequisite = get_post_meta($post->ID, '_lesson_prerequisite', true);
188 188
 		// Get the Lesson Posts
189
-		$post_args = array(	'post_type' 		=> 'lesson',
189
+		$post_args = array('post_type' 		=> 'lesson',
190 190
 							'posts_per_page' 		=> -1,
191 191
 							'orderby'         	=> 'title',
192 192
     						'order'           	=> 'ASC',
193 193
     						'exclude' 			=> $post->ID,
194 194
 							'suppress_filters' 	=> 0
195 195
 							);
196
-		$posts_array = get_posts( $post_args );
196
+		$posts_array = get_posts($post_args);
197 197
 		// Build the HTML to Output
198 198
 		$html = '';
199
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
200
-		if ( count( $posts_array ) > 0 ) {
201
-			$html .= '<select id="lesson-prerequisite-options" name="lesson_prerequisite" class="chosen_select widefat">' . "\n";
202
-			$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
203
-				foreach ($posts_array as $post_item){
204
-					$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '"' . selected( $post_item->ID, $select_lesson_prerequisite, false ) . '>' . esc_html( $post_item->post_title ) . '</option>' . "\n";
199
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
200
+		if (count($posts_array) > 0) {
201
+			$html .= '<select id="lesson-prerequisite-options" name="lesson_prerequisite" class="chosen_select widefat">'."\n";
202
+			$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
203
+				foreach ($posts_array as $post_item) {
204
+					$html .= '<option value="'.esc_attr(absint($post_item->ID)).'"'.selected($post_item->ID, $select_lesson_prerequisite, false).'>'.esc_html($post_item->post_title).'</option>'."\n";
205 205
 				} // End For Loop
206
-			$html .= '</select>' . "\n";
206
+			$html .= '</select>'."\n";
207 207
 		} else {
208
-			$html .= '<p>' . esc_html( __( 'No lessons exist yet. Please add some first.', 'woothemes-sensei' ) ) . '</p>';
208
+			$html .= '<p>'.esc_html(__('No lessons exist yet. Please add some first.', 'woothemes-sensei')).'</p>';
209 209
 		} // End If Statement
210 210
 		// Output the HTML
211 211
 		echo $html;
@@ -217,20 +217,20 @@  discard block
 block discarded – undo
217 217
 	 * @access public
218 218
 	 * @return void
219 219
 	 */
220
-	public function lesson_preview_meta_box_content () {
220
+	public function lesson_preview_meta_box_content() {
221 221
 		global $post;
222 222
 		// Get existing post meta
223
-		$lesson_preview = get_post_meta( $post->ID, '_lesson_preview', true );
223
+		$lesson_preview = get_post_meta($post->ID, '_lesson_preview', true);
224 224
 		$html = '';
225
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
225
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
226 226
 
227 227
 		$checked = '';
228
-		if ( isset( $lesson_preview ) && ( '' != $lesson_preview ) ) {
229
-	 	    $checked = checked( 'preview', $lesson_preview, false );
228
+		if (isset($lesson_preview) && ('' != $lesson_preview)) {
229
+	 	    $checked = checked('preview', $lesson_preview, false);
230 230
 	 	} // End If Statement
231 231
 
232 232
 	 	$html .= '<label for="lesson_preview">';
233
-	 	$html .= '<input type="checkbox" id="lesson_preview" name="lesson_preview" value="preview" ' . $checked . '>&nbsp;' . __( 'Allow this lesson to be viewed without purchase/login', 'woothemes-sensei' ) . '<br>';
233
+	 	$html .= '<input type="checkbox" id="lesson_preview" name="lesson_preview" value="preview" '.$checked.'>&nbsp;'.__('Allow this lesson to be viewed without purchase/login', 'woothemes-sensei').'<br>';
234 234
 
235 235
 		// Output the HTML
236 236
 		echo $html;
@@ -243,32 +243,32 @@  discard block
 block discarded – undo
243 243
 	 * @param int $post_id
244 244
 	 * @return integer $post_id
245 245
 	 */
246
-	public function meta_box_save ( $post_id ) {
246
+	public function meta_box_save($post_id) {
247 247
 
248 248
 		// Verify the nonce before proceeding.
249
-		if ( ( get_post_type( $post_id ) != $this->token ) || !isset(   $_POST[ 'woo_' . $this->token . '_nonce'] )  || ! wp_verify_nonce( $_POST[ 'woo_' . $this->token . '_nonce' ], 'sensei-save-post-meta' ) ) {
249
+		if ((get_post_type($post_id) != $this->token) || ! isset($_POST['woo_'.$this->token.'_nonce']) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_nonce'], 'sensei-save-post-meta')) {
250 250
 			return $post_id;
251 251
 		} // End If Statement
252 252
 		// Get the post type object.
253
-		$post_type = get_post_type_object( get_post_type( $post_id ) );
253
+		$post_type = get_post_type_object(get_post_type($post_id));
254 254
 		// Check if the current user has permission to edit the post.
255
-		if ( !current_user_can( $post_type->cap->edit_post, $post_id ) ) {
255
+		if ( ! current_user_can($post_type->cap->edit_post, $post_id)) {
256 256
 			return $post_id;
257 257
 		} // End If Statement
258 258
 		// Check if the current post type is a page
259
-		if ( 'page' == $_POST[ 'post_type' ] ) {
260
-			if ( ! current_user_can( 'edit_page', $post_id ) ) {
259
+		if ('page' == $_POST['post_type']) {
260
+			if ( ! current_user_can('edit_page', $post_id)) {
261 261
 				return $post_id;
262 262
 			} // End If Statement
263 263
 		} else {
264
-			if ( ! current_user_can( 'edit_post', $post_id ) ) {
264
+			if ( ! current_user_can('edit_post', $post_id)) {
265 265
 				return $post_id;
266 266
 			} // End If Statement
267 267
 		} // End If Statement
268 268
 		// Save the post meta data fields
269
-		if ( isset($this->meta_fields) && is_array($this->meta_fields) ) {
270
-			foreach ( $this->meta_fields as $meta_key ) {
271
-				$this->save_post_meta( $meta_key, $post_id );
269
+		if (isset($this->meta_fields) && is_array($this->meta_fields)) {
270
+			foreach ($this->meta_fields as $meta_key) {
271
+				$this->save_post_meta($meta_key, $post_id);
272 272
 			} // End For Loop
273 273
 		} // End If Statement
274 274
 	} // End meta_box_save()
@@ -280,37 +280,37 @@  discard block
 block discarded – undo
280 280
 	 * @access public
281 281
 	 * @return integer|boolean $post_id or false
282 282
 	 */
283
-	public function quiz_update( $post_id ) {
283
+	public function quiz_update($post_id) {
284 284
 		global $post;
285 285
 		// Verify the nonce before proceeding.
286
-		if ( ( 'lesson' != get_post_type( $post_id ) )|| !isset(   $_POST[ 'woo_' . $this->token . '_nonce'] )  || ! wp_verify_nonce( $_POST[ 'woo_' . $this->token . '_nonce' ], 'sensei-save-post-meta') ) {
287
-			if ( isset($post->ID) ) {
286
+		if (('lesson' != get_post_type($post_id)) || ! isset($_POST['woo_'.$this->token.'_nonce']) || ! wp_verify_nonce($_POST['woo_'.$this->token.'_nonce'], 'sensei-save-post-meta')) {
287
+			if (isset($post->ID)) {
288 288
 				return $post->ID;
289 289
 			} else {
290 290
 				return false;
291 291
 			} // End If Statement
292 292
 		} // End If Statement
293 293
 
294
-		if( wp_is_post_revision( $post_id ) || wp_is_post_autosave( $post_id ) ) {
294
+		if (wp_is_post_revision($post_id) || wp_is_post_autosave($post_id)) {
295 295
 			return false;
296 296
 		}
297 297
 
298 298
 		// Temporarily disable the filter
299
-        remove_action( 'save_post', array( $this, 'quiz_update' ) );
299
+        remove_action('save_post', array($this, 'quiz_update'));
300 300
 		// Save the Quiz
301
-		$quiz_id = $this->lesson_quizzes( $post_id, 'any');
301
+		$quiz_id = $this->lesson_quizzes($post_id, 'any');
302 302
 
303 303
 		 // Sanitize and setup the post data
304
-		$_POST = stripslashes_deep( $_POST );
305
-		if ( isset( $_POST[ 'quiz_id' ] ) && ( 0 < absint( $_POST[ 'quiz_id' ] ) ) ) {
306
-			$quiz_id = absint( $_POST[ 'quiz_id' ] );
304
+		$_POST = stripslashes_deep($_POST);
305
+		if (isset($_POST['quiz_id']) && (0 < absint($_POST['quiz_id']))) {
306
+			$quiz_id = absint($_POST['quiz_id']);
307 307
 		} // End If Statement
308
-		$post_title = esc_html( $_POST[ 'post_title' ] );
309
-		$post_status = esc_html( $_POST[ 'post_status' ] );
308
+		$post_title = esc_html($_POST['post_title']);
309
+		$post_status = esc_html($_POST['post_status']);
310 310
 		$post_content = '';
311 311
 
312 312
 		// Setup Query Arguments
313
-		$post_type_args = array(	'post_content' => $post_content,
313
+		$post_type_args = array('post_content' => $post_content,
314 314
   		    						'post_status' => $post_status,
315 315
   		    						'post_title' => $post_title,
316 316
   		    						'post_type' => 'quiz',
@@ -320,84 +320,84 @@  discard block
 block discarded – undo
320 320
 		$settings = $this->get_quiz_settings();
321 321
 
322 322
   		// Update or Insert the Lesson Quiz
323
-		if ( 0 < $quiz_id ) {
323
+		if (0 < $quiz_id) {
324 324
 			// Update the Quiz
325
-			$post_type_args[ 'ID' ] = $quiz_id;
325
+			$post_type_args['ID'] = $quiz_id;
326 326
 		    wp_update_post($post_type_args);
327 327
 
328 328
 		    // Update the post meta data
329
-		    update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
329
+		    update_post_meta($quiz_id, '_quiz_lesson', $post_id);
330 330
 
331
-		    foreach( $settings as $field ) {
332
-		    	if( 'random_question_order' != $field['id'] ) {
333
-			    	$value = $this->get_submitted_setting_value( $field );
334
-			    	if( isset( $value ) ) {
335
-			    		update_post_meta( $quiz_id, '_' . $field['id'], $value );
331
+		    foreach ($settings as $field) {
332
+		    	if ('random_question_order' != $field['id']) {
333
+			    	$value = $this->get_submitted_setting_value($field);
334
+			    	if (isset($value)) {
335
+			    		update_post_meta($quiz_id, '_'.$field['id'], $value);
336 336
 			    	}
337 337
 			    }
338 338
 		    }
339 339
 
340 340
 		    // Set the post terms for quiz-type
341
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
341
+		    wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type');
342 342
 		} else {
343 343
 			// Create the Quiz
344 344
 		    $quiz_id = wp_insert_post($post_type_args);
345 345
 
346 346
 		    // Add the post meta data WP will add it if it doesn't exist
347
-            update_post_meta( $quiz_id, '_quiz_lesson', $post_id );
347
+            update_post_meta($quiz_id, '_quiz_lesson', $post_id);
348 348
 
349
-		    foreach( $settings as $field ) {
350
-		    	if( 'random_question_order' != $field['id'] ) {
349
+		    foreach ($settings as $field) {
350
+		    	if ('random_question_order' != $field['id']) {
351 351
 
352 352
                     //ignore values not posted to avoid
353 353
                     // overwriting with empty or default values
354 354
                     // when the values are posted from bulk edit or quick edit
355
-                    if( !isset( $_POST[ $field['id'] ] ) ){
355
+                    if ( ! isset($_POST[$field['id']])) {
356 356
                         continue;
357 357
                     }
358 358
 
359
-			    	$value = $this->get_submitted_setting_value( $field );
360
-			    	if( isset( $value ) ) {
361
-			    		add_post_meta( $quiz_id, '_' . $field['id'], $value );
359
+			    	$value = $this->get_submitted_setting_value($field);
360
+			    	if (isset($value)) {
361
+			    		add_post_meta($quiz_id, '_'.$field['id'], $value);
362 362
 			    	}
363 363
 			    }
364 364
 		    }
365 365
 
366 366
 		    // Set the post terms for quiz-type
367
-		    wp_set_post_terms( $quiz_id, array( 'multiple-choice' ), 'quiz-type' );
367
+		    wp_set_post_terms($quiz_id, array('multiple-choice'), 'quiz-type');
368 368
 		} // End If Statement
369 369
 
370 370
 		// Add default lesson order meta value
371
-		$course_id = get_post_meta( $post_id, '_lesson_course', true );
372
-		if( $course_id ) {
373
-			if( ! get_post_meta( $post_id, '_order_' . $course_id, true ) ) {
374
-				update_post_meta( $post_id, '_order_' . $course_id, 0 );
371
+		$course_id = get_post_meta($post_id, '_lesson_course', true);
372
+		if ($course_id) {
373
+			if ( ! get_post_meta($post_id, '_order_'.$course_id, true)) {
374
+				update_post_meta($post_id, '_order_'.$course_id, 0);
375 375
 			}
376 376
 		}
377 377
 		// Add reference back to the Quiz
378
-		update_post_meta( $post_id, '_lesson_quiz', $quiz_id );
378
+		update_post_meta($post_id, '_lesson_quiz', $quiz_id);
379 379
 		// Mark if the Lesson Quiz has questions
380
-		$quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
381
-		if( 0 < count( $quiz_questions ) ) {
382
-			update_post_meta( $post_id, '_quiz_has_questions', '1' );
380
+		$quiz_questions = Sensei()->lesson->lesson_quiz_questions($quiz_id);
381
+		if (0 < count($quiz_questions)) {
382
+			update_post_meta($post_id, '_quiz_has_questions', '1');
383 383
 		}
384 384
 		else {
385
-			delete_post_meta( $post_id, '_quiz_has_questions' );
385
+			delete_post_meta($post_id, '_quiz_has_questions');
386 386
 		}
387 387
 
388 388
 		// Restore the previously disabled filter
389
-        add_action( 'save_post', array( $this, 'quiz_update' ) );
389
+        add_action('save_post', array($this, 'quiz_update'));
390 390
 
391 391
 	} // End post_updated()
392 392
 
393
-	public function get_submitted_setting_value( $field = false ) {
393
+	public function get_submitted_setting_value($field = false) {
394 394
 
395
-		if( ! $field ) return;
395
+		if ( ! $field) return;
396 396
 
397 397
 		$value = false;
398 398
 
399
-		if( 'quiz_grade_type' == $field['id'] ) {
400
-			if( isset( $_POST[ $field['id'] ] ) && 'on' == $_POST[ $field['id'] ] ) {
399
+		if ('quiz_grade_type' == $field['id']) {
400
+			if (isset($_POST[$field['id']]) && 'on' == $_POST[$field['id']]) {
401 401
 				$value = 'auto';
402 402
 			} else {
403 403
 				$value = 'manual';
@@ -405,8 +405,8 @@  discard block
 block discarded – undo
405 405
 			return $value;
406 406
 		}
407 407
 
408
-		if ( isset( $_POST[ $field['id'] ] ) ) {
409
-			$value = $_POST[ $field['id'] ];
408
+		if (isset($_POST[$field['id']])) {
409
+			$value = $_POST[$field['id']];
410 410
 		} else {
411 411
 			$value = $field['default'];
412 412
 		}
@@ -422,18 +422,18 @@  discard block
 block discarded – undo
422 422
 	 * @param int $post_id (default: 0)
423 423
 	 * @return int|bool meta id or saved status
424 424
 	 */
425
-	private function save_post_meta( $post_key = '', $post_id = 0 ) {
425
+	private function save_post_meta($post_key = '', $post_id = 0) {
426 426
 		// Get the meta key.
427
-		$meta_key = '_' . $post_key;
427
+		$meta_key = '_'.$post_key;
428 428
 
429 429
         //ignore fields are not posted
430 430
 
431
-        if( !isset( $_POST[ $post_key ] ) ){
431
+        if ( ! isset($_POST[$post_key])) {
432 432
 
433 433
             // except for lesson preview checkbox field
434
-            if( 'lesson_preview' == $post_key ){
434
+            if ('lesson_preview' == $post_key) {
435 435
 
436
-                $_POST[ $post_key ] = '';
436
+                $_POST[$post_key] = '';
437 437
 
438 438
             } else {
439 439
 
@@ -444,15 +444,15 @@  discard block
 block discarded – undo
444 444
         }
445 445
 
446 446
 		// Get the posted data and sanitize it for use as an HTML class.
447
-		if ( 'lesson_video_embed' == $post_key) {
448
-			$new_meta_value = esc_html( $_POST[$post_key] );
447
+		if ('lesson_video_embed' == $post_key) {
448
+			$new_meta_value = esc_html($_POST[$post_key]);
449 449
 		} else {
450
-			$new_meta_value = ( isset( $_POST[$post_key] ) ? sanitize_html_class( $_POST[$post_key] ) : '' );
450
+			$new_meta_value = (isset($_POST[$post_key]) ? sanitize_html_class($_POST[$post_key]) : '');
451 451
 		} // End If Statement
452 452
 
453 453
         // update field with the new value
454
-        if( -1 != $new_meta_value  ){
455
-            return update_post_meta( $post_id, $meta_key, $new_meta_value );
454
+        if ( -1 != $new_meta_value  ) {
455
+            return update_post_meta($post_id, $meta_key, $new_meta_value);
456 456
         }
457 457
 
458 458
 	} // End save_post_meta()
@@ -463,30 +463,30 @@  discard block
 block discarded – undo
463 463
 	 * @access public
464 464
 	 * @return void
465 465
 	 */
466
-	public function lesson_course_meta_box_content () {
466
+	public function lesson_course_meta_box_content() {
467 467
 		global $post;
468 468
 		// Setup Lesson Meta Data
469 469
 		$selected_lesson_course = 0;
470
-		if ( 0 < $post->ID ) {
471
-			$selected_lesson_course = get_post_meta( $post->ID, '_lesson_course', true );
470
+		if (0 < $post->ID) {
471
+			$selected_lesson_course = get_post_meta($post->ID, '_lesson_course', true);
472 472
 		} // End If Statement
473 473
 		// Handle preselected course
474
-		if ( isset( $_GET[ 'course_id' ] ) && ( 0 < absint( $_GET[ 'course_id' ] ) ) ) {
475
-			$selected_lesson_course = absint( $_GET[ 'course_id' ] );
474
+		if (isset($_GET['course_id']) && (0 < absint($_GET['course_id']))) {
475
+			$selected_lesson_course = absint($_GET['course_id']);
476 476
 		} // End If Statement
477 477
 		// Get the Lesson Posts
478
-		$post_args = array(	'post_type' 		=> 'course',
478
+		$post_args = array('post_type' 		=> 'course',
479 479
 							'posts_per_page' 		=> -1,
480 480
 							'orderby'         	=> 'title',
481 481
     						'order'           	=> 'ASC',
482 482
     						'post_status'      	=> 'any',
483 483
     						'suppress_filters' 	=> 0,
484 484
 							);
485
-		$posts_array = get_posts( $post_args );
485
+		$posts_array = get_posts($post_args);
486 486
 		// Buid the HTML to Output
487 487
 		$html = '';
488 488
 		// Nonce
489
-		$html .= wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
489
+		$html .= wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
490 490
 
491 491
         // Select the course for the lesson
492 492
         $drop_down_args = array(
@@ -496,67 +496,67 @@  discard block
 block discarded – undo
496 496
 
497 497
         $courses = WooThemes_Sensei_Course::get_all_courses();
498 498
         $courses_options = array();
499
-        foreach( $courses as $course ){
500
-            $courses_options[ $course->ID ] = get_the_title( $course ) ;
499
+        foreach ($courses as $course) {
500
+            $courses_options[$course->ID] = get_the_title($course);
501 501
         }
502
-        $html .= Sensei_Utils::generate_drop_down( $selected_lesson_course, $courses_options, $drop_down_args );
502
+        $html .= Sensei_Utils::generate_drop_down($selected_lesson_course, $courses_options, $drop_down_args);
503 503
 
504 504
         // Course Actions Panel
505
-		if ( current_user_can( 'publish_courses' )) {
505
+		if (current_user_can('publish_courses')) {
506 506
 				$html .= '<div id="lesson-course-actions">';
507 507
 					$html .= '<p>';
508 508
 						// Add a course action link
509
-						$html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ ' . __('Add New Course', 'woothemes-sensei' ) . '</a>';
509
+						$html .= '<a id="lesson-course-add" href="#course-add" class="lesson-add-course">+ '.__('Add New Course', 'woothemes-sensei').'</a>';
510 510
 					$html .= '</p>';
511 511
 				$html .= '</div>';
512 512
 				// Add a course input fields
513 513
 				$html .= '<div id="lesson-course-details" class="hidden">';
514 514
 					$html .= '<p>';
515 515
 						// Course Title input
516
-						$html .= '<label>' . __( 'Course Title' , 'woothemes-sensei' ) . '</label> ';
516
+						$html .= '<label>'.__('Course Title', 'woothemes-sensei').'</label> ';
517 517
 	  					$html .= '<input type="text" id="course-title" name="course_title" value="" size="25" class="widefat" />';
518 518
 	  					// Course Description input
519
-	  					$html .= '<label>' . __( 'Description' , 'woothemes-sensei' ) . '</label> ';
519
+	  					$html .= '<label>'.__('Description', 'woothemes-sensei').'</label> ';
520 520
 	  					$html .= '<textarea rows="10" cols="40" id="course-content" name="course_content" value="" size="300" class="widefat"></textarea>';
521 521
 	  					// Course Prerequisite
522
-	  					$html .= '<label>' . __( 'Course Prerequisite' , 'woothemes-sensei' ) . '</label> ';
523
-	  					$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">' . "\n";
524
-							$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>';
525
-							foreach ($posts_array as $post_item){
526
-								$html .= '<option value="' . esc_attr( absint( $post_item->ID ) ) . '">' . esc_html( $post_item->post_title ) . '</option>' . "\n";
522
+	  					$html .= '<label>'.__('Course Prerequisite', 'woothemes-sensei').'</label> ';
523
+	  					$html .= '<select id="course-prerequisite-options" name="course_prerequisite" class="chosen_select widefat">'."\n";
524
+							$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>';
525
+							foreach ($posts_array as $post_item) {
526
+								$html .= '<option value="'.esc_attr(absint($post_item->ID)).'">'.esc_html($post_item->post_title).'</option>'."\n";
527 527
 							} // End For Loop
528
-						$html .= '</select>' . "\n";
528
+						$html .= '</select>'."\n";
529 529
 						// Course Product
530
-                        if ( Sensei_WC::is_woocommerce_active() ) {
530
+                        if (Sensei_WC::is_woocommerce_active()) {
531 531
 	  						// Get the Products
532
-							$select_course_woocommerce_product = get_post_meta( $post_item->ID, '_course_woocommerce_product', true );
532
+							$select_course_woocommerce_product = get_post_meta($post_item->ID, '_course_woocommerce_product', true);
533 533
 
534
-							$product_args = array(	'post_type' 		=> array( 'product', 'product_variation' ),
534
+							$product_args = array('post_type' 		=> array('product', 'product_variation'),
535 535
 													'posts_per_page' 		=> -1,
536 536
 													'orderby'         	=> 'title',
537 537
 	    											'order'           	=> 'DESC',
538
-	    											'post_status'		=> array( 'publish', 'private', 'draft' ),
538
+	    											'post_status'		=> array('publish', 'private', 'draft'),
539 539
 	    											'tax_query'			=> array(
540 540
 														array(
541 541
 															'taxonomy'	=> 'product_type',
542 542
 															'field'		=> 'slug',
543
-															'terms'		=> array( 'variable', 'grouped' ),
543
+															'terms'		=> array('variable', 'grouped'),
544 544
 															'operator'	=> 'NOT IN'
545 545
 														)
546 546
 													),
547 547
 	    											'suppress_filters' 	=> 0
548 548
 													);
549
-							$products_array = get_posts( $product_args );
550
-							$html .= '<label>' . __( 'WooCommerce Product' , 'woothemes-sensei' ) . '</label> ';
551
-	  						$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">' . "\n";
552
-								$html .= '<option value="-">' . __( 'None', 'woothemes-sensei' ) . '</option>';
549
+							$products_array = get_posts($product_args);
550
+							$html .= '<label>'.__('WooCommerce Product', 'woothemes-sensei').'</label> ';
551
+	  						$html .= '<select id="course-woocommerce-product-options" name="course_woocommerce_product" class="chosen_select widefat">'."\n";
552
+								$html .= '<option value="-">'.__('None', 'woothemes-sensei').'</option>';
553 553
 								$prev_parent_id = 0;
554
-								foreach ($products_array as $products_item){
554
+								foreach ($products_array as $products_item) {
555 555
 
556
-									if ( 'product_variation' == $products_item->post_type ) {
557
-										$product_object = get_product( $products_item->ID );
558
-										$parent_id = wp_get_post_parent_id( $products_item->ID );
559
-										$product_name = ucwords( woocommerce_get_formatted_variation( $product_object->variation_data, true ) );
556
+									if ('product_variation' == $products_item->post_type) {
557
+										$product_object = get_product($products_item->ID);
558
+										$parent_id = wp_get_post_parent_id($products_item->ID);
559
+										$product_name = ucwords(woocommerce_get_formatted_variation($product_object->variation_data, true));
560 560
 									} else {
561 561
 										$parent_id = false;
562 562
 										$prev_parent_id = 0;
@@ -564,32 +564,32 @@  discard block
 block discarded – undo
564 564
 									}
565 565
 
566 566
 									// Show variations in groups
567
-									if( $parent_id && $parent_id != $prev_parent_id ) {
568
-										if( 0 != $prev_parent_id ) {
567
+									if ($parent_id && $parent_id != $prev_parent_id) {
568
+										if (0 != $prev_parent_id) {
569 569
 											$html .= '</optgroup>';
570 570
 										}
571
-										$html .= '<optgroup label="' . get_the_title( $parent_id ) . '">';
571
+										$html .= '<optgroup label="'.get_the_title($parent_id).'">';
572 572
 										$prev_parent_id = $parent_id;
573
-									} elseif( ! $parent_id && 0 == $prev_parent_id ) {
573
+									} elseif ( ! $parent_id && 0 == $prev_parent_id) {
574 574
 										$html .= '</optgroup>';
575 575
 									}
576 576
 
577
-									$html .= '<option value="' . esc_attr( absint( $products_item->ID ) ) . '">' . esc_html( $products_item->post_title ) . '</option>' . "\n";
577
+									$html .= '<option value="'.esc_attr(absint($products_item->ID)).'">'.esc_html($products_item->post_title).'</option>'."\n";
578 578
 								} // End For Loop
579
-							$html .= '</select>' . "\n";
579
+							$html .= '</select>'."\n";
580 580
 						} else {
581 581
 							// Default
582 582
 							$html .= '<input type="hidden" name="course_woocommerce_product" id="course-woocommerce-product-options" value="-" />';
583 583
 						}
584 584
 						// Course Category
585
-	  					$html .= '<label>' . __( 'Course Category' , 'woothemes-sensei' ) . '</label> ';
586
-	  					$cat_args = array( 'echo' => false, 'hierarchical' => true, 'show_option_none' => __( 'None', 'woothemes-sensei' ), 'taxonomy' => 'course-category', 'orderby' => 'name', 'id' => 'course-category-options', 'name' => 'course_category', 'class' => 'widefat' );
587
-						$html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args)) . "\n";
585
+	  					$html .= '<label>'.__('Course Category', 'woothemes-sensei').'</label> ';
586
+	  					$cat_args = array('echo' => false, 'hierarchical' => true, 'show_option_none' => __('None', 'woothemes-sensei'), 'taxonomy' => 'course-category', 'orderby' => 'name', 'id' => 'course-category-options', 'name' => 'course_category', 'class' => 'widefat');
587
+						$html .= wp_dropdown_categories(apply_filters('widget_course_categories_dropdown_args', $cat_args))."\n";
588 588
 	  					// Save the course action button
589
-	  					$html .= '<a title="' . esc_attr( __( 'Save Course', 'woothemes-sensei' ) ) . '" href="#add-course-metadata" class="lesson_course_save button button-highlighted">' . esc_html( __( 'Add Course', 'woothemes-sensei' ) ) . '</a>';
589
+	  					$html .= '<a title="'.esc_attr(__('Save Course', 'woothemes-sensei')).'" href="#add-course-metadata" class="lesson_course_save button button-highlighted">'.esc_html(__('Add Course', 'woothemes-sensei')).'</a>';
590 590
 						$html .= '&nbsp;&nbsp;&nbsp;';
591 591
 						// Cancel action link
592
-						$html .= '<a href="#course-add-cancel" class="lesson_course_cancel">' . __( 'Cancel', 'woothemes-sensei' ) . '</a>';
592
+						$html .= '<a href="#course-add-cancel" class="lesson_course_cancel">'.__('Cancel', 'woothemes-sensei').'</a>';
593 593
 					$html .= '</p>';
594 594
 				$html .= '</div>';
595 595
 			} // End If Statement
@@ -598,20 +598,20 @@  discard block
 block discarded – undo
598 598
 		echo $html;
599 599
 	} // End lesson_course_meta_box_content()
600 600
 
601
-	public function quiz_panel( $quiz_id = 0 ) {
601
+	public function quiz_panel($quiz_id = 0) {
602 602
 
603
-		$html = wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce', true, false  );
603
+		$html = wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce', true, false);
604 604
 		$html .= '<div id="add-quiz-main">';
605
-			if ( 0 == $quiz_id ) {
605
+			if (0 == $quiz_id) {
606 606
 				$html .= '<p>';
607 607
 					// Default message and Add a Quiz button
608
-					$html .= esc_html( __( 'Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei' ) );
608
+					$html .= esc_html(__('Once you have saved your lesson you will be able to add questions.', 'woothemes-sensei'));
609 609
 				$html .= '</p>';
610 610
 			}
611 611
 
612 612
 			// Quiz Panel CSS Class
613 613
 			$quiz_class = '';
614
-			if ( 0 == $quiz_id ) {
614
+			if (0 == $quiz_id) {
615 615
 				$quiz_class = ' class="hidden"';
616 616
 			} // End If Statement
617 617
 			// Build the HTML to Output
@@ -619,15 +619,15 @@  discard block
 block discarded – undo
619 619
 
620 620
 			// Setup Questions Query
621 621
 			$questions = array();
622
-			if ( 0 < $quiz_id ) {
623
-				$questions = $this->lesson_quiz_questions( $quiz_id );
622
+			if (0 < $quiz_id) {
623
+				$questions = $this->lesson_quiz_questions($quiz_id);
624 624
 			} // End If Statement
625 625
 
626 626
 			$question_count = 0;
627
-			foreach( $questions as $question ) {
627
+			foreach ($questions as $question) {
628 628
 
629
-				if( $question->post_type == 'multiple_question' ) {
630
-					$question_number = get_post_meta( $question->ID, 'number', true );
629
+				if ($question->post_type == 'multiple_question') {
630
+					$question_number = get_post_meta($question->ID, 'number', true);
631 631
 					$question_count += $question_number;
632 632
 				} else {
633 633
 					++$question_count;
@@ -636,68 +636,68 @@  discard block
 block discarded – undo
636 636
 			}
637 637
 
638 638
 			// Inner DIV
639
-			$html .= '<div id="add-quiz-metadata"' . $quiz_class . '>';
639
+			$html .= '<div id="add-quiz-metadata"'.$quiz_class.'>';
640 640
 
641 641
 				// Quiz ID
642
-				$html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="' . esc_attr( $quiz_id ) . '" />';
642
+				$html .= '<input type="hidden" name="quiz_id" id="quiz_id" value="'.esc_attr($quiz_id).'" />';
643 643
 
644 644
 				// Default Message
645
-				if ( 0 == $quiz_id ) {
645
+				if (0 == $quiz_id) {
646 646
 					$html .= '<p class="save-note">';
647
-						$html .= esc_html( __( 'Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei' ) );
647
+						$html .= esc_html(__('Please save your lesson in order to add questions to your quiz.', 'woothemes-sensei'));
648 648
 					$html .= '</p>';
649 649
 				} // End If Statement
650 650
 
651 651
 			$html .= '</div>';
652 652
 
653 653
 			// Question Container DIV
654
-			$html .= '<div id="add-question-main"' . $quiz_class . '>';
654
+			$html .= '<div id="add-question-main"'.$quiz_class.'>';
655 655
 				// Inner DIV
656 656
 				$html .= '<div id="add-question-metadata">';
657 657
 
658 658
 					// Count of questions
659
-					$html .= '<input type="hidden" name="question_counter" id="question_counter" value="' . esc_attr( $question_count ) . '" />';
659
+					$html .= '<input type="hidden" name="question_counter" id="question_counter" value="'.esc_attr($question_count).'" />';
660 660
 					// Table headers
661 661
 					$html .= '<table class="widefat" id="sortable-questions">
662 662
 								<thead>
663 663
 								    <tr>
664 664
 								        <th class="question-count-column">#</th>
665
-								        <th>' . __( 'Question', 'woothemes-sensei' ) . '</th>
666
-								        <th style="width:45px;">' . __( 'Grade', 'woothemes-sensei' ) . '</th>
667
-								        <th style="width:125px;">' . __( 'Type', 'woothemes-sensei' ) . '</th>
668
-								        <th style="width:125px;">' . __( 'Action', 'woothemes-sensei' ) . '</th>
665
+								        <th>' . __('Question', 'woothemes-sensei').'</th>
666
+								        <th style="width:45px;">' . __('Grade', 'woothemes-sensei').'</th>
667
+								        <th style="width:125px;">' . __('Type', 'woothemes-sensei').'</th>
668
+								        <th style="width:125px;">' . __('Action', 'woothemes-sensei').'</th>
669 669
 								    </tr>
670 670
 								</thead>
671 671
 								<tfoot>
672 672
 								    <tr>
673 673
 									    <th class="question-count-column">#</th>
674
-									    <th>' . __( 'Question', 'woothemes-sensei' ) . '</th>
675
-									    <th>' . __( 'Grade', 'woothemes-sensei' ) . '</th>
676
-									    <th>' . __( 'Type', 'woothemes-sensei' ) . '</th>
677
-									    <th>' . __( 'Action', 'woothemes-sensei' ) . '</th>
674
+									    <th>' . __('Question', 'woothemes-sensei').'</th>
675
+									    <th>' . __('Grade', 'woothemes-sensei').'</th>
676
+									    <th>' . __('Type', 'woothemes-sensei').'</th>
677
+									    <th>' . __('Action', 'woothemes-sensei').'</th>
678 678
 								    </tr>
679 679
 								</tfoot>';
680 680
 
681 681
 					$message_class = '';
682
-					if ( 0 < $question_count ) { $message_class = 'hidden'; }
682
+					if (0 < $question_count) { $message_class = 'hidden'; }
683 683
 
684
-					$html .= '<tbody id="no-questions-message" class="' . esc_attr( $message_class ) . '">';
684
+					$html .= '<tbody id="no-questions-message" class="'.esc_attr($message_class).'">';
685 685
 						$html .= '<tr>';
686
-							$html .= '<td colspan="5">' . __( 'There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei' ) . '</td>';
686
+							$html .= '<td colspan="5">'.__('There are no Questions for this Quiz yet. Please add some below.', 'woothemes-sensei').'</td>';
687 687
 						$html .= '</tr>';
688 688
 					$html .= '</tbody>';
689 689
 
690
-					if( 0 < $question_count ) {
691
-						$html .= $this->quiz_panel_questions( $questions );
690
+					if (0 < $question_count) {
691
+						$html .= $this->quiz_panel_questions($questions);
692 692
 					}
693 693
 
694 694
 					$html .= '</table>';
695 695
 
696
-					if( ! isset( $this->question_order ) ) {
696
+					if ( ! isset($this->question_order)) {
697 697
 						$this->question_order = '';
698 698
 					}
699 699
 
700
-					$html .= '<input type="hidden" id="question-order" name="question-order" value="' . $this->question_order . '" />';
700
+					$html .= '<input type="hidden" id="question-order" name="question-order" value="'.$this->question_order.'" />';
701 701
 
702 702
 				$html .= '</div>';
703 703
 
@@ -716,47 +716,47 @@  discard block
 block discarded – undo
716 716
 
717 717
 	}
718 718
 
719
-	public function quiz_panel_questions( $questions = array() ) {
719
+	public function quiz_panel_questions($questions = array()) {
720 720
 		global $quiz_questions;
721 721
 
722 722
 		$quiz_questions = $questions;
723 723
 
724 724
 		$html = '';
725 725
 
726
-		if( count( $questions ) > 0 ) {
726
+		if (count($questions) > 0) {
727 727
 
728 728
 			$question_class = '';
729 729
 			$question_counter = 1;
730 730
 
731
-			foreach ( $questions as $question ) {
731
+			foreach ($questions as $question) {
732 732
 
733 733
 				$question_id = $question->ID;
734 734
 
735
-				$question_type = Sensei()->question->get_question_type( $question_id );
735
+				$question_type = Sensei()->question->get_question_type($question_id);
736 736
 
737 737
 				$multiple_data = array();
738 738
 				$question_increment = 1;
739
-				if( 'multiple_question' == $question->post_type ) {
739
+				if ('multiple_question' == $question->post_type) {
740 740
 					$question_type = 'category';
741 741
 
742
-					$question_category = get_post_meta( $question->ID, 'category', true );
743
-					$question_cat = get_term( $question_category, 'question-category' );
742
+					$question_category = get_post_meta($question->ID, 'category', true);
743
+					$question_cat = get_term($question_category, 'question-category');
744 744
 
745
-					$question_number = get_post_meta( $question->ID, 'number', true );
745
+					$question_number = get_post_meta($question->ID, 'number', true);
746 746
 					$question_increment = $question_number;
747 747
 
748
-					$multiple_data = array( $question_cat->name, $question_number );
748
+					$multiple_data = array($question_cat->name, $question_number);
749 749
 				}
750 750
 
751
-				if( ! $question_type ) {
751
+				if ( ! $question_type) {
752 752
 					$question_type = 'multiple-choice';
753 753
 				}
754 754
 
755 755
 				// Row with question and actions
756
-				$html .= $this->quiz_panel_question( $question_type, $question_counter, $question_id, 'quiz', $multiple_data );
756
+				$html .= $this->quiz_panel_question($question_type, $question_counter, $question_id, 'quiz', $multiple_data);
757 757
 				$question_counter += $question_increment;
758 758
 
759
-				if( isset( $this->question_order ) && strlen( $this->question_order ) > 0 ) { $this->question_order .= ','; }
759
+				if (isset($this->question_order) && strlen($this->question_order) > 0) { $this->question_order .= ','; }
760 760
 				$this->question_order .= $question_id;
761 761
 			} // End For Loop
762 762
 		}
@@ -765,161 +765,161 @@  discard block
 block discarded – undo
765 765
 
766 766
 	}
767 767
 
768
-	public function quiz_panel_question( $question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array() ) {
769
-		global $row_counter,  $quiz_questions;
768
+	public function quiz_panel_question($question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array()) {
769
+		global $row_counter, $quiz_questions;
770 770
 
771 771
 		$html = '';
772 772
 
773 773
 		$question_class = '';
774
-		if( 'quiz' == $context ) {
775
-			if( ! $row_counter || ! isset( $row_counter ) ) {
774
+		if ('quiz' == $context) {
775
+			if ( ! $row_counter || ! isset($row_counter)) {
776 776
 				$row_counter = 1;
777 777
 			}
778
-			if( $row_counter % 2 ) { $question_class = 'alternate'; }
778
+			if ($row_counter % 2) { $question_class = 'alternate'; }
779 779
 			++$row_counter;
780 780
 		}
781 781
 
782
-		if( $question_id ) {
782
+		if ($question_id) {
783 783
 
784
-			if( $question_type != 'category' ) {
784
+			if ($question_type != 'category') {
785 785
 
786
-				$question_grade = Sensei()->question->get_question_grade( $question_id );
786
+				$question_grade = Sensei()->question->get_question_grade($question_id);
787 787
 
788
-				$question_media = get_post_meta( $question_id, '_question_media', true );
788
+				$question_media = get_post_meta($question_id, '_question_media', true);
789 789
 				$question_media_type = $question_media_thumb = $question_media_link = $question_media_title = '';
790 790
 				$question_media_thumb_class = $question_media_link_class = $question_media_delete_class = 'hidden';
791
-				$question_media_add_button = __( 'Add file', 'woothemes-sensei' );
792
-				if( 0 < intval( $question_media ) ) {
793
-					$mimetype = get_post_mime_type( $question_media );
794
-					if( $mimetype ) {
795
-						$mimetype_array = explode( '/', $mimetype);
796
-						if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) {
791
+				$question_media_add_button = __('Add file', 'woothemes-sensei');
792
+				if (0 < intval($question_media)) {
793
+					$mimetype = get_post_mime_type($question_media);
794
+					if ($mimetype) {
795
+						$mimetype_array = explode('/', $mimetype);
796
+						if (isset($mimetype_array[0]) && $mimetype_array[0]) {
797 797
 							$question_media_delete_class = '';
798 798
 							$question_media_type = $mimetype_array[0];
799
-							if( 'image' == $question_media_type ) {
800
-								$question_media_thumb = wp_get_attachment_thumb_url( $question_media );
801
-								if( $question_media_thumb ) {
799
+							if ('image' == $question_media_type) {
800
+								$question_media_thumb = wp_get_attachment_thumb_url($question_media);
801
+								if ($question_media_thumb) {
802 802
 									$question_media_thumb_class = '';
803 803
 								}
804 804
 							}
805
-							$question_media_url = wp_get_attachment_url( $question_media );
806
-							if( $question_media_url ) {
807
-								$attachment = get_post( $question_media );
805
+							$question_media_url = wp_get_attachment_url($question_media);
806
+							if ($question_media_url) {
807
+								$attachment = get_post($question_media);
808 808
 								$question_media_title = $attachment->post_title;
809 809
 
810
-								if( ! $question_media_title ) {
811
-									$question_media_filename = basename( $question_media_url );
810
+								if ( ! $question_media_title) {
811
+									$question_media_filename = basename($question_media_url);
812 812
 									$question_media_title = $question_media_filename;
813 813
 								}
814
-								$question_media_link = '<a class="' . $question_media_type . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_title . '</a>';
814
+								$question_media_link = '<a class="'.$question_media_type.'" href="'.esc_url($question_media_url).'" target="_blank">'.$question_media_title.'</a>';
815 815
 								$question_media_link_class = '';
816 816
 							}
817 817
 
818
-							$question_media_add_button = __( 'Change file', 'woothemes-sensei' );
818
+							$question_media_add_button = __('Change file', 'woothemes-sensei');
819 819
 						}
820 820
 					}
821 821
 				}
822 822
 
823
-				$random_order = get_post_meta( $question_id, '_random_order', true );
824
-				if( ! $random_order ) {
823
+				$random_order = get_post_meta($question_id, '_random_order', true);
824
+				if ( ! $random_order) {
825 825
 					$random_order = 'yes';
826 826
 				}
827 827
 
828
-				if( ! $question_type ) { $question_type = 'multiple-choice'; }
828
+				if ( ! $question_type) { $question_type = 'multiple-choice'; }
829 829
 			}
830 830
 
831
-			$html .= '<tbody class="' . $question_class . '">';
831
+			$html .= '<tbody class="'.$question_class.'">';
832 832
 
833
-				if( 'quiz' == $context ) {
833
+				if ('quiz' == $context) {
834 834
 					$html .= '<tr>';
835
-						if( $question_type != 'category' ) {
836
-							$question = get_post( $question_id );
837
-							$html .= '<td class="table-count question-number question-count-column"><span class="number">' . $question_counter . '</span></td>';
838
-							$html .= '<td>' . esc_html( $question->post_title ) . '</td>';
839
-							$html .= '<td class="question-grade-column">' . esc_html( $question_grade ) . '</td>';
840
-							$question_types_filtered = ucwords( str_replace( array( '-', 'boolean' ), array( ' ', __( 'True/False', 'woothemes-sensei' ) ), $question_type ) );
841
-							$html .= '<td>' . esc_html( $question_types_filtered ) . '</td>';
842
-							$html .= '<td><a title="' . esc_attr( __( 'Edit Question', 'woothemes-sensei' ) ) . '" href="#question_' . $question_counter .'" class="question_table_edit">' . esc_html( __( 'Edit', 'woothemes-sensei' ) ) . '</a> <a title="' . esc_attr( __( 'Remove Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_delete">' . esc_html( __( 'Remove', 'woothemes-sensei' ) ) . '</a></td>';
835
+						if ($question_type != 'category') {
836
+							$question = get_post($question_id);
837
+							$html .= '<td class="table-count question-number question-count-column"><span class="number">'.$question_counter.'</span></td>';
838
+							$html .= '<td>'.esc_html($question->post_title).'</td>';
839
+							$html .= '<td class="question-grade-column">'.esc_html($question_grade).'</td>';
840
+							$question_types_filtered = ucwords(str_replace(array('-', 'boolean'), array(' ', __('True/False', 'woothemes-sensei')), $question_type));
841
+							$html .= '<td>'.esc_html($question_types_filtered).'</td>';
842
+							$html .= '<td><a title="'.esc_attr(__('Edit Question', 'woothemes-sensei')).'" href="#question_'.$question_counter.'" class="question_table_edit">'.esc_html(__('Edit', 'woothemes-sensei')).'</a> <a title="'.esc_attr(__('Remove Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_table_delete">'.esc_html(__('Remove', 'woothemes-sensei')).'</a></td>';
843 843
 
844 844
 						} else {
845 845
 
846
-							$end_number = intval( $question_counter ) + intval( $multiple_data[1] ) - 1;
847
-							if( $question_counter == $end_number ) {
846
+							$end_number = intval($question_counter) + intval($multiple_data[1]) - 1;
847
+							if ($question_counter == $end_number) {
848 848
 								$row_numbers = $question_counter;
849 849
 							} else {
850
-								$row_numbers = $question_counter . ' - ' . $end_number;
850
+								$row_numbers = $question_counter.' - '.$end_number;
851 851
 							}
852
-							$row_title = sprintf( __( 'Selected from \'%1$s\' ', 'woothemes-sensei' ), $multiple_data[0] );
852
+							$row_title = sprintf(__('Selected from \'%1$s\' ', 'woothemes-sensei'), $multiple_data[0]);
853 853
 
854
-							$html .= '<td class="table-count question-number question-count-column"><span class="number hidden">' . $question_counter . '</span><span class="hidden total-number">' . $multiple_data[1] . '</span><span class="row-numbers">' . esc_html( $row_numbers ) . '</span></td>';
855
-							$html .= '<td>' . esc_html( $row_title ) . '</td>';
854
+							$html .= '<td class="table-count question-number question-count-column"><span class="number hidden">'.$question_counter.'</span><span class="hidden total-number">'.$multiple_data[1].'</span><span class="row-numbers">'.esc_html($row_numbers).'</span></td>';
855
+							$html .= '<td>'.esc_html($row_title).'</td>';
856 856
 							$html .= '<td class="question-grade-column"></td>';
857
-							$html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" /></td>';
858
-							$html .= '<td><a title="' . esc_attr( __( 'Edit Question', 'woothemes-sensei' ) ) . '" href="#question_' . $question_counter .'" class="question_table_edit" style="visibility:hidden;">' . esc_html( __( 'Edit', 'woothemes-sensei' ) ) . '</a> <a title="' . esc_attr( __( 'Remove Question(s)', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_multiple_delete" rel="' . $question_id . '">' . esc_html( __( 'Remove', 'woothemes-sensei' ) ) . '</a></td>';
857
+							$html .= '<td><input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" /></td>';
858
+							$html .= '<td><a title="'.esc_attr(__('Edit Question', 'woothemes-sensei')).'" href="#question_'.$question_counter.'" class="question_table_edit" style="visibility:hidden;">'.esc_html(__('Edit', 'woothemes-sensei')).'</a> <a title="'.esc_attr(__('Remove Question(s)', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_multiple_delete" rel="'.$question_id.'">'.esc_html(__('Remove', 'woothemes-sensei')).'</a></td>';
859 859
 
860 860
 						}
861 861
 					$html .= '</tr>';
862 862
 				}
863 863
 
864
-				if( $question_type != 'category' ) {
864
+				if ($question_type != 'category') {
865 865
 
866 866
 					$edit_class = '';
867
-					if( 'quiz' == $context ) {
867
+					if ('quiz' == $context) {
868 868
 						$edit_class = 'hidden';
869 869
 					}
870 870
 
871
-					$question = get_post( $question_id );
872
-					$html .= '<tr class="question-quick-edit ' . esc_attr( $edit_class ) . '">';
871
+					$question = get_post($question_id);
872
+					$html .= '<tr class="question-quick-edit '.esc_attr($edit_class).'">';
873 873
 						$html .= '<td colspan="5">';
874
-							$html .= '<span class="hidden question_original_counter">' . $question_counter . '</span>';
874
+							$html .= '<span class="hidden question_original_counter">'.$question_counter.'</span>';
875 875
 					    	$html .= '<div class="question_required_fields">';
876 876
 
877 877
 						    	// Question title
878 878
 						    	$html .= '<div>';
879
-							    	$html .= '<label for="question_' . $question_counter . '">' . __( 'Question:', 'woothemes-sensei' ) . '</label> ';
880
-							    	$html .= '<input type="text" id="question_' . $question_counter . '" name="question" value="' . esc_attr( htmlspecialchars( $question->post_title ) ) . '" size="25" class="widefat" />';
879
+							    	$html .= '<label for="question_'.$question_counter.'">'.__('Question:', 'woothemes-sensei').'</label> ';
880
+							    	$html .= '<input type="text" id="question_'.$question_counter.'" name="question" value="'.esc_attr(htmlspecialchars($question->post_title)).'" size="25" class="widefat" />';
881 881
 						    	$html .= '</div>';
882 882
 
883 883
 						    	// Question description
884 884
 						    	$html .= '<div>';
885
-							    	$html .= '<label for="question_' . $question_counter . '_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
885
+							    	$html .= '<label for="question_'.$question_counter.'_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> ';
886 886
 						    	$html .= '</div>';
887
-							    	$html .= '<textarea id="question_' . $question_counter . '_desc" name="question_description" class="widefat" rows="4">' . esc_textarea( $question->post_content ) . '</textarea>';
887
+							    	$html .= '<textarea id="question_'.$question_counter.'_desc" name="question_description" class="widefat" rows="4">'.esc_textarea($question->post_content).'</textarea>';
888 888
 
889 889
 						    	// Question grade
890 890
 						    	$html .= '<div>';
891
-							    	$html .= '<label for="question_' . $question_counter . '_grade">' . __( 'Question grade:', 'woothemes-sensei' ) . '</label> ';
892
-							    	$html .= '<input type="number" id="question_' . $question_counter . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . $question_grade . '" />';
891
+							    	$html .= '<label for="question_'.$question_counter.'_grade">'.__('Question grade:', 'woothemes-sensei').'</label> ';
892
+							    	$html .= '<input type="number" id="question_'.$question_counter.'_grade" class="question_grade small-text" name="question_grade" min="0" value="'.$question_grade.'" />';
893 893
 						    	$html .= '</div>';
894 894
 
895 895
 						    	// Random order
896
-						    	if( $question_type == 'multiple-choice' ) {
896
+						    	if ($question_type == 'multiple-choice') {
897 897
 						    		$html .= '<div>';
898
-						    			$html .= '<label for="' . $question_counter . '_random_order"><input type="checkbox" name="random_order" class="random_order" id="' . $question_counter . '_random_order" value="yes" ' . checked( $random_order, 'yes', false ) . ' /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
898
+						    			$html .= '<label for="'.$question_counter.'_random_order"><input type="checkbox" name="random_order" class="random_order" id="'.$question_counter.'_random_order" value="yes" '.checked($random_order, 'yes', false).' /> '.__('Randomise answer order', 'woothemes-sensei').'</label>';
899 899
 						    		$html .= '</div>';
900 900
 						    	}
901 901
 
902 902
 						    	// Question media
903 903
 						    	$html .= '<div>';
904
-							    	$html .= '<label for="question_' . $question_counter . '_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
905
-							    	$html .= '<button id="question_' . $question_counter . '_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . $question_media_add_button . '</button>';
906
-							    	$html .= '<button id="question_' . $question_counter . '_media_button_delete" class="delete_media_file_button button-secondary ' . $question_media_delete_class . '">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
907
-							    	$html .= '<span id="question_' . $question_counter . '_media_link" class="question_media_link ' . $question_media_link_class . '">' . $question_media_link . '</span>';
908
-							    	$html .= '<br/><img id="question_' . $question_counter . '_media_preview" class="question_media_preview ' . $question_media_thumb_class . '" src="' . $question_media_thumb . '" /><br/>';
909
-							    	$html .= '<input type="hidden" id="question_' . $question_counter . '_media" class="question_media" name="question_media" value="' . $question_media . '" />';
904
+							    	$html .= '<label for="question_'.$question_counter.'_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>';
905
+							    	$html .= '<button id="question_'.$question_counter.'_media_button" class="upload_media_file_button button-secondary" data-uploader_title="'.__('Add file to question', 'woothemes-sensei').'" data-uploader_button_text="'.__('Add to question', 'woothemes-sensei').'">'.$question_media_add_button.'</button>';
906
+							    	$html .= '<button id="question_'.$question_counter.'_media_button_delete" class="delete_media_file_button button-secondary '.$question_media_delete_class.'">'.__('Delete file', 'woothemes-sensei').'</button><br/>';
907
+							    	$html .= '<span id="question_'.$question_counter.'_media_link" class="question_media_link '.$question_media_link_class.'">'.$question_media_link.'</span>';
908
+							    	$html .= '<br/><img id="question_'.$question_counter.'_media_preview" class="question_media_preview '.$question_media_thumb_class.'" src="'.$question_media_thumb.'" /><br/>';
909
+							    	$html .= '<input type="hidden" id="question_'.$question_counter.'_media" class="question_media" name="question_media" value="'.$question_media.'" />';
910 910
 						    	$html .= '</div>';
911 911
 
912 912
 						    $html .= '</div>';
913 913
 
914
-						    $html .= $this->quiz_panel_question_field( $question_type, $question_id, $question_counter );
914
+						    $html .= $this->quiz_panel_question_field($question_type, $question_id, $question_counter);
915 915
 
916
-						    $html .= '<input type="hidden" id="question_' . $question_counter . '_question_type" class="question_type" name="question_type" value="' . $question_type . '" />';
917
-							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_' . $question_counter . '_id" value="' . $question_id . '" />';
916
+						    $html .= '<input type="hidden" id="question_'.$question_counter.'_question_type" class="question_type" name="question_type" value="'.$question_type.'" />';
917
+							$html .= '<input type="hidden" name="question_id" class="row_question_id" id="question_'.$question_counter.'_id" value="'.$question_id.'" />';
918 918
 
919
-							if( 'quiz' == $context ) {
919
+							if ('quiz' == $context) {
920 920
 					    		$html .= '<div class="update-question">';
921
-						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="' . esc_attr( __( 'Cancel', 'woothemes-sensei' ) ) . '">' . __( 'Cancel', 'woothemes-sensei' ) . '</a> ';
922
-						    		$html .= '<a title="' . esc_attr( __( 'Update Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="question_table_save button button-highlighted">' . esc_html( __( 'Update', 'woothemes-sensei' ) ) . '</a>';
921
+						    		$html .= '<a href="#question-edit-cancel" class="lesson_question_cancel" title="'.esc_attr(__('Cancel', 'woothemes-sensei')).'">'.__('Cancel', 'woothemes-sensei').'</a> ';
922
+						    		$html .= '<a title="'.esc_attr(__('Update Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="question_table_save button button-highlighted">'.esc_html(__('Update', 'woothemes-sensei')).'</a>';
923 923
 					    		$html .= '</div>';
924 924
 					    	}
925 925
 
@@ -934,79 +934,79 @@  discard block
 block discarded – undo
934 934
 		return $html;
935 935
 	}
936 936
 
937
-	public function quiz_panel_add( $context = 'quiz' ) {
937
+	public function quiz_panel_add($context = 'quiz') {
938 938
 
939 939
 
940 940
 		$html = '<div id="add-new-question">';
941 941
 
942 942
 			$question_types = Sensei()->question->question_types();
943 943
 
944
-			$question_cats = get_terms( 'question-category', array( 'hide_empty' => false ) );
944
+			$question_cats = get_terms('question-category', array('hide_empty' => false));
945 945
 
946
-			if( 'quiz' == $context ) {
946
+			if ('quiz' == $context) {
947 947
 	    		$html .= '<h2 class="nav-tab-wrapper add-question-tabs">';
948
-	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">' . __( 'New Question'  , 'woothemes-sensei' ) . '</a>';
949
-	    			$html .= '<a id="tab-existing" class="nav-tab">' . __( 'Existing Questions'  , 'woothemes-sensei' ) . '</a>';
950
-                    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats )  && ! Sensei()->teacher->is_admin_teacher() ) {
951
-	    				$html .= '<a id="tab-multiple" class="nav-tab">' . __( 'Category Questions'  , 'woothemes-sensei' ) . '</a>';
948
+	    			$html .= '<a id="tab-new" class="nav-tab nav-tab-active">'.__('New Question', 'woothemes-sensei').'</a>';
949
+	    			$html .= '<a id="tab-existing" class="nav-tab">'.__('Existing Questions', 'woothemes-sensei').'</a>';
950
+                    if ( ! empty($question_cats) && ! is_wp_error($question_cats) && ! Sensei()->teacher->is_admin_teacher()) {
951
+	    				$html .= '<a id="tab-multiple" class="nav-tab">'.__('Category Questions', 'woothemes-sensei').'</a>';
952 952
 	    			}
953 953
 	    		$html .= '</h2>';
954 954
 	    	}
955 955
 
956 956
 	    	$html .= '<div class="tab-content" id="tab-new-content">';
957 957
 
958
-	    		if( 'quiz' == $context ) {
959
-	    			$html .= '<p><em>' . sprintf( __( 'Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
958
+	    		if ('quiz' == $context) {
959
+	    			$html .= '<p><em>'.sprintf(__('Add a new question to this quiz - your question will also be added to the %1$squestion bank%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit.php?post_type=question').'">', '</a>').'</em></p>';
960 960
 	    		}
961 961
 
962 962
 				$html .= '<div class="question">';
963 963
 					$html .= '<div class="question_required_fields">';
964 964
 
965 965
 						// Question title
966
-						$html .= '<p><label>' . __( 'Question:'  , 'woothemes-sensei' ) . '</label> ';
966
+						$html .= '<p><label>'.__('Question:', 'woothemes-sensei').'</label> ';
967 967
 	  					$html .= '<input type="text" id="add_question" name="question" value="" size="25" class="widefat" /></p>';
968 968
 
969 969
 						// Question description
970 970
 						$html .= '<p>';
971
-							$html .= '<label for="question_desc">' . __( 'Question Description (optional):', 'woothemes-sensei' ) . '</label> ';
971
+							$html .= '<label for="question_desc">'.__('Question Description (optional):', 'woothemes-sensei').'</label> ';
972 972
 						$html .= '</p>';
973 973
 						$html .= '<textarea id="question_desc" name="question_description" class="widefat" rows="4"></textarea>';
974 974
 
975 975
 	  					// Question type
976
-						$html .= '<p><label>' . __( 'Question Type:' , 'woothemes-sensei' ) . '</label> ';
977
-						$html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">' . "\n";
978
-							foreach ( $question_types as $type => $label ) {
979
-								$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>' . "\n";
976
+						$html .= '<p><label>'.__('Question Type:', 'woothemes-sensei').'</label> ';
977
+						$html .= '<select id="add-question-type-options" name="question_type" class="chosen_select widefat question-type-select">'."\n";
978
+							foreach ($question_types as $type => $label) {
979
+								$html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>'."\n";
980 980
 							} // End For Loop
981
-						$html .= '</select></p>' . "\n";
981
+						$html .= '</select></p>'."\n";
982 982
 
983 983
 						// Question category
984
-						if( 'quiz' == $context ) {
985
-							if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
986
-								$html .= '<p><label>' . __( 'Question Category:' , 'woothemes-sensei' ) . '</label> ';
987
-								$html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">' . "\n";
988
-								$html .= '<option value="">' . __( 'None', 'woothemes-sensei' ) . '</option>' . "\n";
989
-								foreach( $question_cats as $cat ) {
990
-									$html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>';
984
+						if ('quiz' == $context) {
985
+							if ( ! empty($question_cats) && ! is_wp_error($question_cats)) {
986
+								$html .= '<p><label>'.__('Question Category:', 'woothemes-sensei').'</label> ';
987
+								$html .= '<select id="add-question-category-options" name="question_category" class="chosen_select widefat question-category-select">'."\n";
988
+								$html .= '<option value="">'.__('None', 'woothemes-sensei').'</option>'."\n";
989
+								foreach ($question_cats as $cat) {
990
+									$html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>';
991 991
 								} // End For Loop
992
-								$html .= '</select></p>' . "\n";
992
+								$html .= '</select></p>'."\n";
993 993
 							}
994 994
 						}
995 995
 
996 996
 	  					// Question grade
997
-						$html .= '<p><label>' . __( 'Question Grade:'  , 'woothemes-sensei' ) . '</label> ';
998
-						$html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>' . "\n";
997
+						$html .= '<p><label>'.__('Question Grade:', 'woothemes-sensei').'</label> ';
998
+						$html .= '<input type="number" id="add-question-grade" name="question_grade" class="small-text" min="0" value="1" /></p>'."\n";
999 999
 
1000 1000
 						// Random order
1001 1001
 						$html .= '<p class="add_question_random_order">';
1002
-			    			$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> ' . __( 'Randomise answer order', 'woothemes-sensei' ) . '</label>';
1002
+			    			$html .= '<label for="add_random_order"><input type="checkbox" name="random_order" class="random_order" id="add_random_order" value="yes" checked="checked" /> '.__('Randomise answer order', 'woothemes-sensei').'</label>';
1003 1003
 			    		$html .= '</p>';
1004 1004
 
1005 1005
 			    		// Question media
1006 1006
 						$html .= '<p>';
1007
-					    	$html .= '<label for="question_add_new_media_button">' . __( 'Question media:', 'woothemes-sensei' ) . '</label><br/>';
1008
-					    	$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="' . __( 'Add file to question', 'woothemes-sensei' ) . '" data-uploader_button_text="' . __( 'Add to question', 'woothemes-sensei' ) . '">' . __( 'Add file', 'woothemes-sensei' ) . '</button>';
1009
-					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">' . __( 'Delete file', 'woothemes-sensei' ) . '</button><br/>';
1007
+					    	$html .= '<label for="question_add_new_media_button">'.__('Question media:', 'woothemes-sensei').'</label><br/>';
1008
+					    	$html .= '<button id="question_add_new_media_button" class="upload_media_file_button button-secondary" data-uploader_title="'.__('Add file to question', 'woothemes-sensei').'" data-uploader_button_text="'.__('Add to question', 'woothemes-sensei').'">'.__('Add file', 'woothemes-sensei').'</button>';
1009
+					    	$html .= '<button id="question_add_new_media_button_delete" class="delete_media_file_button button-secondary hidden">'.__('Delete file', 'woothemes-sensei').'</button><br/>';
1010 1010
 					    	$html .= '<span id="question_add_new_media_link" class="question_media_link hidden"></span>';
1011 1011
 					    	$html .= '<br/><img id="question_add_new_media_preview" class="question_media_preview hidden" src="" /><br/>';
1012 1012
 					    	$html .= '<input type="hidden" id="question_add_new_media" class="question_media" name="question_media" value="" />';
@@ -1015,44 +1015,44 @@  discard block
 block discarded – undo
1015 1015
 					$html .= '</div>';
1016 1016
 				$html .= '</div>';
1017 1017
 
1018
-				foreach ( $question_types as $type => $label ) {
1019
-					$html .= $this->quiz_panel_question_field( $type );
1018
+				foreach ($question_types as $type => $label) {
1019
+					$html .= $this->quiz_panel_question_field($type);
1020 1020
 				}
1021 1021
 
1022
-				if( 'quiz' == $context ) {
1022
+				if ('quiz' == $context) {
1023 1023
 					$html .= '<div class="add-question">';
1024
-			    		$html .= '<a title="' . esc_attr( __( 'Add Question', 'woothemes-sensei' ) ) . '" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">' . esc_html( __( 'Add Question', 'woothemes-sensei' ) ) . '</a>';
1024
+			    		$html .= '<a title="'.esc_attr(__('Add Question', 'woothemes-sensei')).'" href="#add-question-metadata" class="add_question_save button button-primary button-highlighted">'.esc_html(__('Add Question', 'woothemes-sensei')).'</a>';
1025 1025
 		    		$html .= '</div>';
1026 1026
 		    	}
1027 1027
 
1028 1028
 		    $html .= '</div>';
1029 1029
 
1030
-		    if( 'quiz' == $context ) {
1030
+		    if ('quiz' == $context) {
1031 1031
 
1032 1032
 			    $html .= '<div class="tab-content hidden" id="tab-existing-content">';
1033 1033
 
1034
-			    	$html .= '<p><em>' . sprintf( __( 'Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit.php?post_type=question' ) . '">', '</a>' ) . '</em></p>';
1034
+			    	$html .= '<p><em>'.sprintf(__('Add an existing question to this quiz from the %1$squestion bank%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit.php?post_type=question').'">', '</a>').'</em></p>';
1035 1035
 
1036 1036
 			    	$html .= '<div id="existing-filters" class="alignleft actions">
1037 1037
 			    				<select id="existing-status">
1038
-			    					<option value="all">' . __( 'All', 'woothemes-sensei' ) . '</option>
1039
-			    					<option value="unused">' . __( 'Unused', 'woothemes-sensei' ) . '</option>
1040
-			    					<option value="used">' . __( 'Used', 'woothemes-sensei' ) . '</option>
1038
+			    					<option value="all">' . __('All', 'woothemes-sensei').'</option>
1039
+			    					<option value="unused">' . __('Unused', 'woothemes-sensei').'</option>
1040
+			    					<option value="used">' . __('Used', 'woothemes-sensei').'</option>
1041 1041
 			    				</select>
1042 1042
 			    				<select id="existing-type">
1043
-			    					<option value="">' . __( 'All Types', 'woothemes-sensei' ) . '</option>';
1044
-							    	foreach ( $question_types as $type => $label ) {
1045
-										$html .= '<option value="' . esc_attr( $type ) . '">' . esc_html( $label ) . '</option>';
1043
+			    					<option value="">' . __('All Types', 'woothemes-sensei').'</option>';
1044
+							    	foreach ($question_types as $type => $label) {
1045
+										$html .= '<option value="'.esc_attr($type).'">'.esc_html($label).'</option>';
1046 1046
 									}
1047 1047
     				$html .= '</select>
1048 1048
     							<select id="existing-category">
1049
-			    					<option value="">' . __( 'All Categories', 'woothemes-sensei' ) . '</option>';
1050
-				    				foreach( $question_cats as $cat ) {
1051
-										$html .= '<option value="' . esc_attr( $cat->slug ) . '">' . esc_html( $cat->name ) . '</option>';
1049
+			    					<option value="">' . __('All Categories', 'woothemes-sensei').'</option>';
1050
+				    				foreach ($question_cats as $cat) {
1051
+										$html .= '<option value="'.esc_attr($cat->slug).'">'.esc_html($cat->name).'</option>';
1052 1052
 									}
1053 1053
     				$html .= '</select>
1054
-    							<input type="text" id="existing-search" placeholder="' . __( 'Search', 'woothemes-sensei' ) . '" />
1055
-    							<a class="button" id="existing-filter-button">' . __( 'Filter', 'woothemes-sensei' ) . '</a>
1054
+    							<input type="text" id="existing-search" placeholder="' . __('Search', 'woothemes-sensei').'" />
1055
+    							<a class="button" id="existing-filter-button">' . __('Filter', 'woothemes-sensei').'</a>
1056 1056
 			    			</div>';
1057 1057
 
1058 1058
 			    	$html .= '<table id="existing-table" class="widefat">';
@@ -1060,17 +1060,17 @@  discard block
 block discarded – undo
1060 1060
 			    		$html .= '<thead>
1061 1061
 									    <tr>
1062 1062
 									        <th scope="col" class="column-cb check-column"><input type="checkbox" /></th>
1063
-									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
1064
-									        <th scope="col">' . __( 'Type', 'woothemes-sensei' ) . '</th>
1065
-									        <th scope="col">' . __( 'Category', 'woothemes-sensei' ) . '</th>
1063
+									        <th scope="col">' . __('Question', 'woothemes-sensei').'</th>
1064
+									        <th scope="col">' . __('Type', 'woothemes-sensei').'</th>
1065
+									        <th scope="col">' . __('Category', 'woothemes-sensei').'</th>
1066 1066
 									    </tr>
1067 1067
 									</thead>
1068 1068
 									<tfoot>
1069 1069
 									    <tr>
1070 1070
 										    <th scope="col" class="check-column"><input type="checkbox" /></th>
1071
-									        <th scope="col">' . __( 'Question', 'woothemes-sensei' ) . '</th>
1072
-									        <th scope="col">' . __( 'Type', 'woothemes-sensei' ) . '</th>
1073
-									        <th scope="col">' . __( 'Category', 'woothemes-sensei' ) . '</th>
1071
+									        <th scope="col">' . __('Question', 'woothemes-sensei').'</th>
1072
+									        <th scope="col">' . __('Type', 'woothemes-sensei').'</th>
1073
+									        <th scope="col">' . __('Category', 'woothemes-sensei').'</th>
1074 1074
 									    </tr>
1075 1075
 									</tfoot>';
1076 1076
 						$html .= '<tbody id="existing-questions">';
@@ -1078,8 +1078,8 @@  discard block
 block discarded – undo
1078 1078
 						$questions = $this->quiz_panel_get_existing_questions();
1079 1079
 
1080 1080
 						$row = 1;
1081
-						foreach( $questions['questions'] as $question ) {
1082
-							$html .= $this->quiz_panel_add_existing_question( $question->ID, $row );
1081
+						foreach ($questions['questions'] as $question) {
1082
+							$html .= $this->quiz_panel_add_existing_question($question->ID, $row);
1083 1083
 							++$row;
1084 1084
 						}
1085 1085
 
@@ -1088,36 +1088,36 @@  discard block
 block discarded – undo
1088 1088
 			    	$html .= '</table>';
1089 1089
 
1090 1090
 			    	$next_class = '';
1091
-			    	if( $questions['count'] <= 10 ) {
1091
+			    	if ($questions['count'] <= 10) {
1092 1092
 			    		$next_class = 'hidden';
1093 1093
 			    	}
1094 1094
 
1095 1095
 			    	$html .= '<div id="existing-pagination">';
1096 1096
 			    		$html .= '<input type="hidden" id="existing-page" value="1" />';
1097
-			    		$html .= '<a class="prev no-paging">&larr; ' . __( 'Previous', 'woothemes-sensei') . '</a> <a class="next ' . esc_attr( $next_class ) . '">' . __( 'Next', 'woothemes-sensei') . ' &rarr;</a>';
1097
+			    		$html .= '<a class="prev no-paging">&larr; '.__('Previous', 'woothemes-sensei').'</a> <a class="next '.esc_attr($next_class).'">'.__('Next', 'woothemes-sensei').' &rarr;</a>';
1098 1098
 			    	$html .= '</div>';
1099 1099
 
1100 1100
 			    	$html .= '<div class="existing-actions">';
1101
-			    		$html .= '<a title="' . esc_attr( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '" class="add_existing_save button button-primary button-highlighted">' . esc_html( __( 'Add Selected Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1101
+			    		$html .= '<a title="'.esc_attr(__('Add Selected Question(s)', 'woothemes-sensei')).'" class="add_existing_save button button-primary button-highlighted">'.esc_html(__('Add Selected Question(s)', 'woothemes-sensei')).'</a></p>';
1102 1102
 			    	$html .= '</div>';
1103 1103
 
1104 1104
 			    $html .= '</div>';
1105 1105
 
1106
-			    if ( ! empty( $question_cats ) && ! is_wp_error( $question_cats ) ) {
1106
+			    if ( ! empty($question_cats) && ! is_wp_error($question_cats)) {
1107 1107
 				    $html .= '<div class="tab-content hidden" id="tab-multiple-content">';
1108 1108
 
1109
-				    	$html .= '<p><em>' . sprintf( __( 'Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei' ), '<a href="' . admin_url( 'edit-tags.php?taxonomy=question-category&post_type=question' ) . '">', '</a>' ) . '</em></p>';
1109
+				    	$html .= '<p><em>'.sprintf(__('Add any number of questions from a specified category. Edit your question categories %1$shere%2$s.', 'woothemes-sensei'), '<a href="'.admin_url('edit-tags.php?taxonomy=question-category&post_type=question').'">', '</a>').'</em></p>';
1110 1110
 
1111
-						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">' . "\n";
1112
-						$html .= '<option value="">' . __( 'Select a Question Category', 'woothemes-sensei' ) . '</option>' . "\n";
1113
-						foreach( $question_cats as $cat ) {
1114
-							$html .= '<option value="' . esc_attr( $cat->term_id ) . '">' . esc_html( $cat->name ) . '</option>';
1111
+						$html .= '<p><select id="add-multiple-question-category-options" name="multiple_category" class="chosen_select widefat question-category-select">'."\n";
1112
+						$html .= '<option value="">'.__('Select a Question Category', 'woothemes-sensei').'</option>'."\n";
1113
+						foreach ($question_cats as $cat) {
1114
+							$html .= '<option value="'.esc_attr($cat->term_id).'">'.esc_html($cat->name).'</option>';
1115 1115
 						} // End For Loop
1116
-						$html .= '</select></p>' . "\n";
1116
+						$html .= '</select></p>'."\n";
1117 1117
 
1118
-						$html .= '<p>' . __( 'Number of questions:', 'woothemes-sensei' ) . ' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>';
1118
+						$html .= '<p>'.__('Number of questions:', 'woothemes-sensei').' <input type="number" min="1" value="1" max="1" id="add-multiple-question-count" class="small-text"/>';
1119 1119
 
1120
-						$html .= '<a title="' . esc_attr( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '" class="add_multiple_save button button-primary button-highlighted">' . esc_html( __( 'Add Question(s)', 'woothemes-sensei' ) ) . '</a></p>';
1120
+						$html .= '<a title="'.esc_attr(__('Add Question(s)', 'woothemes-sensei')).'" class="add_multiple_save button button-primary button-highlighted">'.esc_html(__('Add Question(s)', 'woothemes-sensei')).'</a></p>';
1121 1121
 
1122 1122
 				    $html .= '</div>';
1123 1123
 				}
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 		return $html;
1129 1129
 	}
1130 1130
 
1131
-	public function quiz_panel_get_existing_questions( $question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1 ) {
1131
+	public function quiz_panel_get_existing_questions($question_status = 'all', $question_type = '', $question_category = '', $question_search = '', $page = 1) {
1132 1132
 
1133 1133
 		$args = array(
1134 1134
 			'post_type' => 'question',
@@ -1137,14 +1137,14 @@  discard block
 block discarded – undo
1137 1137
 			'suppress_filters' => 0,
1138 1138
 		);
1139 1139
 
1140
-		switch( $question_status ) {
1140
+		switch ($question_status) {
1141 1141
 			case 'unused': $quiz_status = 'NOT EXISTS'; break;
1142 1142
 			case 'used': $quiz_status = 'EXISTS'; break;
1143 1143
 			default: $quiz_status = ''; break;
1144 1144
 		}
1145 1145
 
1146
-		if( $quiz_status ) {
1147
-			switch( $quiz_status ) {
1146
+		if ($quiz_status) {
1147
+			switch ($quiz_status) {
1148 1148
 				case 'EXISTS':
1149 1149
 					$args['meta_query'][] = array(
1150 1150
 						'key' => '_quiz_id',
@@ -1162,7 +1162,7 @@  discard block
 block discarded – undo
1162 1162
 			}
1163 1163
 		}
1164 1164
 
1165
-		if( $question_type ) {
1165
+		if ($question_type) {
1166 1166
 			$args['tax_query'][] = array(
1167 1167
 				'taxonomy' => 'question-type',
1168 1168
 				'field' => 'slug',
@@ -1170,7 +1170,7 @@  discard block
 block discarded – undo
1170 1170
 			);
1171 1171
 		}
1172 1172
 
1173
-		if( $question_category ) {
1173
+		if ($question_category) {
1174 1174
 			$args['tax_query'][] = array(
1175 1175
 				'taxonomy' => 'question-category',
1176 1176
 				'field' => 'slug',
@@ -1178,19 +1178,19 @@  discard block
 block discarded – undo
1178 1178
 			);
1179 1179
 		}
1180 1180
 
1181
-		if( $question_type && $question_category ) {
1181
+		if ($question_type && $question_category) {
1182 1182
 			$args['tax_query']['relation'] = 'AND';
1183 1183
 		}
1184 1184
 
1185
-		if( $question_search ) {
1185
+		if ($question_search) {
1186 1186
 			$args['s'] = $question_search;
1187 1187
 		}
1188 1188
 
1189
-		if( $page ) {
1189
+		if ($page) {
1190 1190
 			$args['paged'] = $page;
1191 1191
 		}
1192 1192
 
1193
-		$qry = new WP_Query( $args );
1193
+		$qry = new WP_Query($args);
1194 1194
 
1195 1195
         /**
1196 1196
          * Filter existing questions query
@@ -1199,39 +1199,39 @@  discard block
 block discarded – undo
1199 1199
          *
1200 1200
          * @param WP_Query $wp_query
1201 1201
          */
1202
-        $qry = apply_filters( 'sensei_existing_questions_query_results', $qry );
1202
+        $qry = apply_filters('sensei_existing_questions_query_results', $qry);
1203 1203
 
1204 1204
 		$questions['questions'] = $qry->posts;
1205
-		$questions['count'] = intval( $qry->found_posts );
1205
+		$questions['count'] = intval($qry->found_posts);
1206 1206
 		$questions['page'] = $page;
1207 1207
 
1208 1208
 		return $questions;
1209 1209
 	}
1210 1210
 
1211
-	public function quiz_panel_add_existing_question( $question_id = 0, $row = 1 ) {
1211
+	public function quiz_panel_add_existing_question($question_id = 0, $row = 1) {
1212 1212
 
1213 1213
 		$html = '';
1214 1214
 
1215
-		if( ! $question_id ) {
1215
+		if ( ! $question_id) {
1216 1216
 
1217 1217
             return;
1218 1218
 
1219 1219
         }
1220 1220
 
1221 1221
 		$existing_class = '';
1222
-		if( $row % 2 ) {
1222
+		if ($row % 2) {
1223 1223
             $existing_class = 'alternate';
1224 1224
         }
1225 1225
 
1226
-		$question_type = Sensei()->question->get_question_type( $question_id );
1226
+		$question_type = Sensei()->question->get_question_type($question_id);
1227 1227
 
1228
-		$question_cat_list = strip_tags( get_the_term_list( $question_id, 'question-category', '', ', ', '' ) );
1228
+		$question_cat_list = strip_tags(get_the_term_list($question_id, 'question-category', '', ', ', ''));
1229 1229
 
1230
-		$html .= '<tr class="' . esc_attr( $existing_class ) . '">
1231
-					<td class="cb"><input type="checkbox" value="' . $question_id . '" class="existing-item" /></td>
1232
-					<td>' . get_the_title( $question_id ) . '</td>
1233
-					<td>' . esc_html( $question_type ) . '</td>
1234
-					<td>' . esc_html( $question_cat_list ) . '</td>
1230
+		$html .= '<tr class="'.esc_attr($existing_class).'">
1231
+					<td class="cb"><input type="checkbox" value="' . $question_id.'" class="existing-item" /></td>
1232
+					<td>' . get_the_title($question_id).'</td>
1233
+					<td>' . esc_html($question_type).'</td>
1234
+					<td>' . esc_html($question_cat_list).'</td>
1235 1235
 				  </tr>';
1236 1236
 
1237 1237
 		return $html;
@@ -1244,58 +1244,58 @@  discard block
 block discarded – undo
1244 1244
 
1245 1245
 		//Add nonce security to the request
1246 1246
 		$nonce = '';
1247
-		if( isset( $_POST['filter_existing_questions_nonce'] ) ) {
1248
-			$nonce = esc_html( $_POST['filter_existing_questions_nonce'] );
1247
+		if (isset($_POST['filter_existing_questions_nonce'])) {
1248
+			$nonce = esc_html($_POST['filter_existing_questions_nonce']);
1249 1249
 		} // End If Statement
1250 1250
 
1251
-		if( ! wp_verify_nonce( $nonce, 'filter_existing_questions_nonce' ) ) {
1252
-			die( $return );
1251
+		if ( ! wp_verify_nonce($nonce, 'filter_existing_questions_nonce')) {
1252
+			die($return);
1253 1253
 		} // End If Statement
1254 1254
 
1255 1255
 		// Parse POST data
1256 1256
 		$data = $_POST['data'];
1257 1257
 		$question_data = array();
1258
-		parse_str( $data, $question_data );
1258
+		parse_str($data, $question_data);
1259 1259
 
1260
-		if( 0 < count( $question_data ) ) {
1260
+		if (0 < count($question_data)) {
1261 1261
 
1262 1262
 			$question_status = '';
1263
-			if( isset( $question_data['question_status'] ) ) {
1263
+			if (isset($question_data['question_status'])) {
1264 1264
 				$question_status = $question_data['question_status'];
1265 1265
 			}
1266 1266
 
1267 1267
 			$question_type = '';
1268
-			if( isset( $question_data['question_type'] ) ) {
1268
+			if (isset($question_data['question_type'])) {
1269 1269
 				$question_type = $question_data['question_type'];
1270 1270
 			}
1271 1271
 
1272 1272
 			$question_category = '';
1273
-			if( isset( $question_data['question_category'] ) ) {
1273
+			if (isset($question_data['question_category'])) {
1274 1274
 				$question_category = $question_data['question_category'];
1275 1275
 			}
1276 1276
 
1277 1277
 			$question_search = '';
1278
-			if( isset( $question_data['question_search'] ) ) {
1278
+			if (isset($question_data['question_search'])) {
1279 1279
 				$question_search = $question_data['question_search'];
1280 1280
 			}
1281 1281
 
1282 1282
 			$question_page = 1;
1283
-			if( isset( $question_data['question_page'] ) ) {
1284
-				$question_page = intval( $question_data['question_page'] );
1283
+			if (isset($question_data['question_page'])) {
1284
+				$question_page = intval($question_data['question_page']);
1285 1285
 			}
1286 1286
 
1287
-			$questions = $this->quiz_panel_get_existing_questions( $question_status, $question_type, $question_category, $question_search, $question_page );
1287
+			$questions = $this->quiz_panel_get_existing_questions($question_status, $question_type, $question_category, $question_search, $question_page);
1288 1288
 
1289 1289
 			$row = 1;
1290 1290
 			$html = '';
1291
-			foreach( $questions['questions'] as $question ) {
1292
-				$html .= $this->quiz_panel_add_existing_question( $question->ID, $row );
1291
+			foreach ($questions['questions'] as $question) {
1292
+				$html .= $this->quiz_panel_add_existing_question($question->ID, $row);
1293 1293
 				++$row;
1294 1294
 			}
1295 1295
 
1296
-			if( ! $html ) {
1296
+			if ( ! $html) {
1297 1297
 				$html = '<tr class="alternate">
1298
-								<td class="no-results" colspan="4"><em>' . __( 'There are no questions matching your search.', 'woothemes-sensei' ) . '</em></td>
1298
+								<td class="no-results" colspan="4"><em>' . __('There are no questions matching your search.', 'woothemes-sensei').'</em></td>
1299 1299
 							  </tr>';
1300 1300
 			}
1301 1301
 
@@ -1303,53 +1303,53 @@  discard block
 block discarded – undo
1303 1303
 			$return['count'] = $questions['count'];
1304 1304
 			$return['page'] = $questions['page'];
1305 1305
 
1306
-			wp_send_json( $return );
1306
+			wp_send_json($return);
1307 1307
 		}
1308 1308
 
1309
-		die( $return );
1309
+		die($return);
1310 1310
 	}
1311 1311
 
1312
-	public function quiz_panel_question_field( $question_type = '', $question_id = 0, $question_counter = 0 ) {
1312
+	public function quiz_panel_question_field($question_type = '', $question_id = 0, $question_counter = 0) {
1313 1313
 
1314 1314
 		$html = '';
1315 1315
 
1316
-		if( $question_type ) {
1316
+		if ($question_type) {
1317 1317
 
1318 1318
 			$right_answer = '';
1319 1319
 			$wrong_answers = array();
1320 1320
 			$answer_order_string = '';
1321 1321
 			$answer_order = array();
1322
-			if( $question_id ) {
1323
-				$right_answer = get_post_meta( $question_id, '_question_right_answer', true);
1324
-				$wrong_answers = get_post_meta( $question_id, '_question_wrong_answers', true);
1325
-				$answer_order_string = get_post_meta( $question_id, '_answer_order', true );
1326
-				$answer_order = array_filter( explode( ',', $answer_order_string ) );
1322
+			if ($question_id) {
1323
+				$right_answer = get_post_meta($question_id, '_question_right_answer', true);
1324
+				$wrong_answers = get_post_meta($question_id, '_question_wrong_answers', true);
1325
+				$answer_order_string = get_post_meta($question_id, '_answer_order', true);
1326
+				$answer_order = array_filter(explode(',', $answer_order_string));
1327 1327
 				$question_class = '';
1328 1328
 			} else {
1329 1329
 				$question_id = '';
1330 1330
 				$question_class = 'answer-fields question_required_fields hidden';
1331 1331
 			}
1332 1332
 
1333
-			switch ( $question_type ) {
1333
+			switch ($question_type) {
1334 1334
 				case 'multiple-choice':
1335
-					$html .= '<div class="question_default_fields multiple-choice-answers ' . str_replace( ' hidden', '', $question_class ) . '">';
1335
+					$html .= '<div class="question_default_fields multiple-choice-answers '.str_replace(' hidden', '', $question_class).'">';
1336 1336
 
1337 1337
 						$right_answers = (array) $right_answer;
1338 1338
 						// Calculate total right answers available (defaults to 1)
1339 1339
 						$total_right = 0;
1340
-						if( $question_id ) {
1341
-							$total_right = get_post_meta( $question_id, '_right_answer_count', true );
1340
+						if ($question_id) {
1341
+							$total_right = get_post_meta($question_id, '_right_answer_count', true);
1342 1342
 						}
1343
-						if( 0 == intval( $total_right ) ) {
1343
+						if (0 == intval($total_right)) {
1344 1344
 							$total_right = 1;
1345 1345
 						}
1346
-						for ( $i = 0; $i < $total_right; $i++ ) {
1347
-							if ( !isset( $right_answers[ $i ] ) ) { $right_answers[ $i ] = ''; }
1348
-							$right_answer_id = $this->get_answer_id( $right_answers[ $i ] );
1346
+						for ($i = 0; $i < $total_right; $i++) {
1347
+							if ( ! isset($right_answers[$i])) { $right_answers[$i] = ''; }
1348
+							$right_answer_id = $this->get_answer_id($right_answers[$i]);
1349 1349
 							// Right Answer
1350
-							$right_answer = '<label class="answer" for="question_' . $question_counter . '_right_answer_' . $i . '"><span>' . __( 'Right:' , 'woothemes-sensei' ) . '</span> <input rel="' . esc_attr( $right_answer_id ) . '" type="text" id="question_' . $question_counter . '_right_answer_' . $i . '" name="question_right_answers[]" value="' . esc_attr( $right_answers[ $i ] ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1351
-							if( $question_id ) {
1352
-								$answers[ $right_answer_id ] = $right_answer;
1350
+							$right_answer = '<label class="answer" for="question_'.$question_counter.'_right_answer_'.$i.'"><span>'.__('Right:', 'woothemes-sensei').'</span> <input rel="'.esc_attr($right_answer_id).'" type="text" id="question_'.$question_counter.'_right_answer_'.$i.'" name="question_right_answers[]" value="'.esc_attr($right_answers[$i]).'" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1351
+							if ($question_id) {
1352
+								$answers[$right_answer_id] = $right_answer;
1353 1353
 							} else {
1354 1354
 								$answers[] = $right_answer;
1355 1355
 							}
@@ -1357,23 +1357,23 @@  discard block
 block discarded – undo
1357 1357
 
1358 1358
 				    	// Calculate total wrong answers available (defaults to 4)
1359 1359
 				    	$total_wrong = 0;
1360
-				    	if( $question_id ) {
1361
-				    		$total_wrong = get_post_meta( $question_id, '_wrong_answer_count', true );
1360
+				    	if ($question_id) {
1361
+				    		$total_wrong = get_post_meta($question_id, '_wrong_answer_count', true);
1362 1362
 				    	}
1363
-				    	if( 0 == intval( $total_wrong ) ) {
1363
+				    	if (0 == intval($total_wrong)) {
1364 1364
 				    		$total_wrong = 1;
1365 1365
 				    	}
1366 1366
 
1367 1367
                         // Setup Wrong Answer HTML
1368
-                        foreach ( $wrong_answers as $i => $answer ){
1368
+                        foreach ($wrong_answers as $i => $answer) {
1369 1369
 
1370
-                            $answer_id = $this->get_answer_id( $answer );
1371
-                            $wrong_answer = '<label class="answer" for="question_' . $question_counter . '_wrong_answer_' . $i . '"><span>' . __( 'Wrong:' , 'woothemes-sensei' ) ;
1372
-                            $wrong_answer .= '</span> <input rel="' . esc_attr( $answer_id ) . '" type="text" id="question_' . $question_counter . '_wrong_answer_' . $i ;
1373
-                            $wrong_answer .= '" name="question_wrong_answers[]" value="' . esc_attr( $answer ) . '" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1374
-                            if( $question_id ) {
1370
+                            $answer_id = $this->get_answer_id($answer);
1371
+                            $wrong_answer = '<label class="answer" for="question_'.$question_counter.'_wrong_answer_'.$i.'"><span>'.__('Wrong:', 'woothemes-sensei');
1372
+                            $wrong_answer .= '</span> <input rel="'.esc_attr($answer_id).'" type="text" id="question_'.$question_counter.'_wrong_answer_'.$i;
1373
+                            $wrong_answer .= '" name="question_wrong_answers[]" value="'.esc_attr($answer).'" size="25" class="question_answer widefat" /> <a class="remove_answer_option"></a></label>';
1374
+                            if ($question_id) {
1375 1375
 
1376
-                                $answers[ $answer_id ] = $wrong_answer;
1376
+                                $answers[$answer_id] = $wrong_answer;
1377 1377
 
1378 1378
                             } else {
1379 1379
 
@@ -1384,115 +1384,115 @@  discard block
 block discarded – undo
1384 1384
                         } // end for each
1385 1385
 
1386 1386
 				    	$answers_sorted = $answers;
1387
-				    	if( $question_id && count( $answer_order ) > 0 ) {
1387
+				    	if ($question_id && count($answer_order) > 0) {
1388 1388
 				    		$answers_sorted = array();
1389
-				    		foreach( $answer_order as $answer_id ) {
1390
-				    			if( isset( $answers[ $answer_id ] ) ) {
1391
-				    				$answers_sorted[ $answer_id ] = $answers[ $answer_id ];
1392
-				    				unset( $answers[ $answer_id ] );
1389
+				    		foreach ($answer_order as $answer_id) {
1390
+				    			if (isset($answers[$answer_id])) {
1391
+				    				$answers_sorted[$answer_id] = $answers[$answer_id];
1392
+				    				unset($answers[$answer_id]);
1393 1393
 				    			}
1394 1394
 				    		}
1395 1395
 
1396
-				    		if( count( $answers ) > 0 ) {
1397
-						    	foreach( $answers as $id => $answer ) {
1398
-						    		$answers_sorted[ $id ] = $answer;
1396
+				    		if (count($answers) > 0) {
1397
+						    	foreach ($answers as $id => $answer) {
1398
+						    		$answers_sorted[$id] = $answer;
1399 1399
 						    	}
1400 1400
 						    }
1401 1401
 				    	}
1402 1402
 
1403
-						foreach( $answers_sorted as $id => $answer ) {
1403
+						foreach ($answers_sorted as $id => $answer) {
1404 1404
 				    		$html .= $answer;
1405 1405
 				    	}
1406 1406
 
1407
-				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="' . $answer_order_string . '" />';
1408
-				    	$html .= '<span class="hidden right_answer_count">' . $total_right . '</span>';
1409
-				    	$html .= '<span class="hidden wrong_answer_count">' . $total_wrong . '</span>';
1407
+				    	$html .= '<input type="hidden" class="answer_order" name="answer_order" value="'.$answer_order_string.'" />';
1408
+				    	$html .= '<span class="hidden right_answer_count">'.$total_right.'</span>';
1409
+				    	$html .= '<span class="hidden wrong_answer_count">'.$total_wrong.'</span>';
1410 1410
 
1411 1411
 				    	$html .= '<div class="add_answer_options">';
1412
-					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add right answer', 'woothemes-sensei' ) . '</a>';
1413
-					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="' . $question_counter . '">' . __( 'Add wrong answer', 'woothemes-sensei' ) . '</a>';
1412
+					    	$html .= '<a class="add_right_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add right answer', 'woothemes-sensei').'</a>';
1413
+					    	$html .= '<a class="add_wrong_answer_option add_answer_option button" rel="'.$question_counter.'">'.__('Add wrong answer', 'woothemes-sensei').'</a>';
1414 1414
 				    	$html .= '</div>';
1415 1415
 
1416
-                        $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id , 'multiple-choice' );
1416
+                        $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'multiple-choice');
1417 1417
 
1418 1418
 			    	$html .= '</div>';
1419 1419
 				break;
1420 1420
 				case 'boolean':
1421
-					$html .= '<div class="question_boolean_fields ' . $question_class . '">';
1422
-						if( $question_id ) {
1423
-							$field_name = 'question_' . $question_id . '_right_answer_boolean';
1421
+					$html .= '<div class="question_boolean_fields '.$question_class.'">';
1422
+						if ($question_id) {
1423
+							$field_name = 'question_'.$question_id.'_right_answer_boolean';
1424 1424
 						} else {
1425 1425
 							$field_name = 'question_right_answer_boolean';
1426 1426
 							$right_answer = 'true';
1427 1427
 						}
1428
-						$html .= '<label for="question_' . $question_id . '_boolean_true"><input id="question_' . $question_id . '_boolean_true" type="radio" name="' . $field_name . '" value="true" '. checked( $right_answer, 'true', false ) . ' /> ' . __( 'True', 'woothemes-sensei' ) . '</label>';
1429
-						$html .= '<label for="question_' . $question_id . '_boolean_false"><input id="question_' . $question_id . '_boolean_false" type="radio" name="' . $field_name . '" value="false" '. checked( $right_answer, 'false', false ) . ' /> ' . __( 'False', 'woothemes-sensei' ) . '</label>';
1428
+						$html .= '<label for="question_'.$question_id.'_boolean_true"><input id="question_'.$question_id.'_boolean_true" type="radio" name="'.$field_name.'" value="true" '.checked($right_answer, 'true', false).' /> '.__('True', 'woothemes-sensei').'</label>';
1429
+						$html .= '<label for="question_'.$question_id.'_boolean_false"><input id="question_'.$question_id.'_boolean_false" type="radio" name="'.$field_name.'" value="false" '.checked($right_answer, 'false', false).' /> '.__('False', 'woothemes-sensei').'</label>';
1430 1430
 
1431
-                    $html .= $this->quiz_panel_question_feedback( $question_counter, $question_id, 'boolean' );
1431
+                    $html .= $this->quiz_panel_question_feedback($question_counter, $question_id, 'boolean');
1432 1432
 
1433 1433
 					$html .= '</div>';
1434 1434
 				break;
1435 1435
 				case 'gap-fill':
1436
-					$gapfill_array = explode( '||', $right_answer );
1437
-					if ( isset( $gapfill_array[0] ) ) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; }
1438
-					if ( isset( $gapfill_array[1] ) ) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; }
1439
-					if ( isset( $gapfill_array[2] ) ) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; }
1440
-					$html .= '<div class="question_gapfill_fields ' . $question_class . '">';
1436
+					$gapfill_array = explode('||', $right_answer);
1437
+					if (isset($gapfill_array[0])) { $gapfill_pre = $gapfill_array[0]; } else { $gapfill_pre = ''; }
1438
+					if (isset($gapfill_array[1])) { $gapfill_gap = $gapfill_array[1]; } else { $gapfill_gap = ''; }
1439
+					if (isset($gapfill_array[2])) { $gapfill_post = $gapfill_array[2]; } else { $gapfill_post = ''; }
1440
+					$html .= '<div class="question_gapfill_fields '.$question_class.'">';
1441 1441
 						// Fill in the Gaps
1442
-						$html .= '<label>' . __( 'Text before the Gap:' , 'woothemes-sensei' ) . '</label> ';
1443
-						$html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_pre" name="add_question_right_answer_gapfill_pre" value="' . $gapfill_pre . '" size="25" class="widefat gapfill-field" />';
1444
-	  					$html .= '<label>' . __( 'The Gap:' , 'woothemes-sensei' ) . '</label> ';
1445
-	  					$html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_gap" name="add_question_right_answer_gapfill_gap" value="' . $gapfill_gap . '" size="25" class="widefat gapfill-field" />';
1446
-	  					$html .= '<label>' . __( 'Text after the Gap:' , 'woothemes-sensei' ) . '</label> ';
1447
-	  					$html .= '<input type="text" id="question_' . $question_counter . '_add_question_right_answer_gapfill_post" name="add_question_right_answer_gapfill_post" value="' . $gapfill_post . '" size="25" class="widefat gapfill-field" />';
1448
-	  					$html .= '<label>' . __( 'Preview:' , 'woothemes-sensei' ) . '</label> ';
1449
-	  					$html .= '<p class="gapfill-preview">' . $gapfill_pre . '&nbsp;<u>' . $gapfill_gap . '</u>&nbsp;' . $gapfill_post . '</p>';
1442
+						$html .= '<label>'.__('Text before the Gap:', 'woothemes-sensei').'</label> ';
1443
+						$html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_pre" name="add_question_right_answer_gapfill_pre" value="'.$gapfill_pre.'" size="25" class="widefat gapfill-field" />';
1444
+	  					$html .= '<label>'.__('The Gap:', 'woothemes-sensei').'</label> ';
1445
+	  					$html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_gap" name="add_question_right_answer_gapfill_gap" value="'.$gapfill_gap.'" size="25" class="widefat gapfill-field" />';
1446
+	  					$html .= '<label>'.__('Text after the Gap:', 'woothemes-sensei').'</label> ';
1447
+	  					$html .= '<input type="text" id="question_'.$question_counter.'_add_question_right_answer_gapfill_post" name="add_question_right_answer_gapfill_post" value="'.$gapfill_post.'" size="25" class="widefat gapfill-field" />';
1448
+	  					$html .= '<label>'.__('Preview:', 'woothemes-sensei').'</label> ';
1449
+	  					$html .= '<p class="gapfill-preview">'.$gapfill_pre.'&nbsp;<u>'.$gapfill_gap.'</u>&nbsp;'.$gapfill_post.'</p>';
1450 1450
 	  				$html .= '</div>';
1451 1451
 				break;
1452 1452
 				case 'multi-line':
1453
-					$html .= '<div class="question_multiline_fields ' . $question_class . '">';
1453
+					$html .= '<div class="question_multiline_fields '.$question_class.'">';
1454 1454
 						// Guides for grading
1455
-						if( $question_counter ) {
1456
-							$field_id = 'question_' . $question_counter . '_add_question_right_answer_multiline';
1455
+						if ($question_counter) {
1456
+							$field_id = 'question_'.$question_counter.'_add_question_right_answer_multiline';
1457 1457
 						} else {
1458 1458
 							$field_id = 'add_question_right_answer_multiline';
1459 1459
 						}
1460
-						$html .= '<label>' . __( 'Guide/Teacher Notes for grading the answer' , 'woothemes-sensei' ) . '</label> ';
1461
-						$html .= '<textarea id="' . $field_id . '" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>';
1460
+						$html .= '<label>'.__('Guide/Teacher Notes for grading the answer', 'woothemes-sensei').'</label> ';
1461
+						$html .= '<textarea id="'.$field_id.'" name="add_question_right_answer_multiline" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>';
1462 1462
 					$html .= '</div>';
1463 1463
 				break;
1464 1464
 				case 'single-line':
1465
-					$html .= '<div class="question_singleline_fields ' . $question_class . '">';
1465
+					$html .= '<div class="question_singleline_fields '.$question_class.'">';
1466 1466
 						// Recommended Answer
1467
-						if( $question_counter ) {
1468
-							$field_id = 'question_' . $question_counter . '_add_question_right_answer_singleline';
1467
+						if ($question_counter) {
1468
+							$field_id = 'question_'.$question_counter.'_add_question_right_answer_singleline';
1469 1469
 						} else {
1470 1470
 							$field_id = 'add_question_right_answer_singleline';
1471 1471
 						}
1472
-						$html .= '<label>' . __( 'Recommended Answer' , 'woothemes-sensei' ) . '</label> ';
1473
-						$html .= '<input type="text" id="' . $field_id . '" name="add_question_right_answer_singleline" value="' . $right_answer . '" size="25" class="widefat" />';
1472
+						$html .= '<label>'.__('Recommended Answer', 'woothemes-sensei').'</label> ';
1473
+						$html .= '<input type="text" id="'.$field_id.'" name="add_question_right_answer_singleline" value="'.$right_answer.'" size="25" class="widefat" />';
1474 1474
 					$html .= '</div>';
1475 1475
 				break;
1476 1476
 				case 'file-upload':
1477
-					$html .= '<div class="question_fileupload_fields ' . $question_class . '">';
1478
-						if( $question_counter ) {
1479
-							$right_field_id = 'question_' . $question_counter . '_add_question_right_answer_fileupload';
1480
-							$wrong_field_id = 'question_' . $question_counter . '_add_question_wrong_answer_fileupload';
1477
+					$html .= '<div class="question_fileupload_fields '.$question_class.'">';
1478
+						if ($question_counter) {
1479
+							$right_field_id = 'question_'.$question_counter.'_add_question_right_answer_fileupload';
1480
+							$wrong_field_id = 'question_'.$question_counter.'_add_question_wrong_answer_fileupload';
1481 1481
 						} else {
1482 1482
 							$right_field_id = 'add_question_right_answer_fileupload';
1483 1483
 							$wrong_field_id = 'add_question_wrong_answer_fileupload';
1484 1484
 						}
1485 1485
 
1486 1486
 						$wrong_answer = '';
1487
-						if( isset( $wrong_answers[0] ) ) {
1487
+						if (isset($wrong_answers[0])) {
1488 1488
 							$wrong_answer = $wrong_answers[0];
1489 1489
 						}
1490
-						$html .= '<label>' . __( 'Description for student explaining what needs to be uploaded' , 'woothemes-sensei' ) . '</label> ';
1491
-						$html .= '<textarea id="' . $wrong_field_id . '" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">' . $wrong_answer . '</textarea>';
1490
+						$html .= '<label>'.__('Description for student explaining what needs to be uploaded', 'woothemes-sensei').'</label> ';
1491
+						$html .= '<textarea id="'.$wrong_field_id.'" name="add_question_wrong_answer_fileupload" rows="4" cols="40" class="widefat">'.$wrong_answer.'</textarea>';
1492 1492
 
1493 1493
 						// Guides for grading
1494
-						$html .= '<label>' . __( 'Guide/Teacher Notes for grading the upload' , 'woothemes-sensei' ) . '</label> ';
1495
-						$html .= '<textarea id="' . $right_field_id . '" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">' . $right_answer . '</textarea>';
1494
+						$html .= '<label>'.__('Guide/Teacher Notes for grading the upload', 'woothemes-sensei').'</label> ';
1495
+						$html .= '<textarea id="'.$right_field_id.'" name="add_question_right_answer_fileupload" rows="4" cols="40" class="widefat">'.$right_answer.'</textarea>';
1496 1496
 					$html .= '</div>';
1497 1497
 				break;
1498 1498
 			}
@@ -1501,32 +1501,32 @@  discard block
 block discarded – undo
1501 1501
 		return $html;
1502 1502
 	}
1503 1503
 
1504
-	public function quiz_panel_question_feedback( $question_counter = 0, $question_id = 0, $question_type = '' ) {
1504
+	public function quiz_panel_question_feedback($question_counter = 0, $question_id = 0, $question_type = '') {
1505 1505
 
1506 1506
         // default field name
1507 1507
         $field_name = 'answer_feedback';
1508
-        if( 'boolean' == $question_type ){
1508
+        if ('boolean' == $question_type) {
1509 1509
 
1510 1510
             $field_name = 'answer_feedback_boolean';
1511 1511
 
1512
-        }elseif( 'multiple-choice' == $question_type ){
1512
+        }elseif ('multiple-choice' == $question_type) {
1513 1513
 
1514 1514
             $field_name = 'answer_feedback_multiple_choice';
1515 1515
 
1516 1516
         }// end if
1517 1517
 
1518
-		if( $question_counter ) {
1519
-			$field_name = 'answer_' . $question_counter . '_feedback';
1518
+		if ($question_counter) {
1519
+			$field_name = 'answer_'.$question_counter.'_feedback';
1520 1520
 		}
1521 1521
 
1522 1522
 		$feedback = '';
1523
-		if( $question_id ) {
1524
-			$feedback = get_post_meta( $question_id, '_answer_feedback', true );
1523
+		if ($question_id) {
1524
+			$feedback = get_post_meta($question_id, '_answer_feedback', true);
1525 1525
 		}
1526 1526
 
1527
-		$html = '<p title="' . __( 'This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei' ) . '">';
1528
-		$html .= '<label for="' . $field_name . '">' . __( 'Answer Feedback' , 'woothemes-sensei' ) . ':</label>';
1529
-		$html .= '<textarea id="' . $field_name . '" name="' . $field_name . '" rows="4" cols="40" class="answer_feedback widefat">' . $feedback . '</textarea>';
1527
+		$html = '<p title="'.__('This feedback will be automatically displayed to the student once they have completed the quiz.', 'woothemes-sensei').'">';
1528
+		$html .= '<label for="'.$field_name.'">'.__('Answer Feedback', 'woothemes-sensei').':</label>';
1529
+		$html .= '<textarea id="'.$field_name.'" name="'.$field_name.'" rows="4" cols="40" class="answer_feedback widefat">'.$feedback.'</textarea>';
1530 1530
 		$html .= '</p>';
1531 1531
 
1532 1532
 		return $html;
@@ -1535,19 +1535,19 @@  discard block
 block discarded – undo
1535 1535
 	public function question_get_answer_id() {
1536 1536
 		$data = $_POST['data'];
1537 1537
 		$answer_data = array();
1538
-		parse_str( $data, $answer_data );
1538
+		parse_str($data, $answer_data);
1539 1539
 		$answer = $answer_data['answer_value'];
1540
-		$answer_id = $this->get_answer_id( $answer );
1540
+		$answer_id = $this->get_answer_id($answer);
1541 1541
 		echo $answer_id;
1542 1542
 		die();
1543 1543
 	}
1544 1544
 
1545
-	public function get_answer_id( $answer = '' ) {
1545
+	public function get_answer_id($answer = '') {
1546 1546
 
1547 1547
 		$answer_id = '';
1548 1548
 
1549
-		if( $answer ) {
1550
-			$answer_id = md5( $answer );
1549
+		if ($answer) {
1550
+			$answer_id = md5($answer);
1551 1551
 		}
1552 1552
 
1553 1553
 		return $answer_id;
@@ -1560,17 +1560,17 @@  discard block
 block discarded – undo
1560 1560
 	 * @access public
1561 1561
 	 * @return void
1562 1562
 	 */
1563
-	public function lesson_quiz_meta_box_content () {
1563
+	public function lesson_quiz_meta_box_content() {
1564 1564
 		global $post;
1565 1565
 
1566 1566
 		// Get quiz panel
1567 1567
 		$quiz_id = 0;
1568 1568
 		$quizzes = array();
1569
-		if ( 0 < $post->ID ) {
1570
-			$quiz_id = $this->lesson_quizzes( $post->ID, 'any' );
1569
+		if (0 < $post->ID) {
1570
+			$quiz_id = $this->lesson_quizzes($post->ID, 'any');
1571 1571
 		}
1572 1572
 
1573
-		echo $this->quiz_panel( $quiz_id );
1573
+		echo $this->quiz_panel($quiz_id);
1574 1574
 
1575 1575
 	} // End lesson_quiz_meta_box_content()
1576 1576
 
@@ -1587,53 +1587,53 @@  discard block
 block discarded – undo
1587 1587
 		$quiz_id = 0;
1588 1588
 		$lesson_id = $post->ID;
1589 1589
 		$quizzes = array();
1590
-		if ( 0 < $lesson_id ) {
1591
-			$quiz_id = $this->lesson_quizzes( $lesson_id, 'any' );
1590
+		if (0 < $lesson_id) {
1591
+			$quiz_id = $this->lesson_quizzes($lesson_id, 'any');
1592 1592
 		}
1593 1593
 
1594
-		if( $quiz_id ) {
1595
-			$html .= $this->quiz_settings_panel( $lesson_id, $quiz_id );
1594
+		if ($quiz_id) {
1595
+			$html .= $this->quiz_settings_panel($lesson_id, $quiz_id);
1596 1596
 		} else {
1597
-			$html .= '<p><em>' . __( 'There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei' ) . '</em></p>';
1597
+			$html .= '<p><em>'.__('There is no quiz for this lesson yet - please add one in the \'Quiz Questions\' box.', 'woothemes-sensei').'</em></p>';
1598 1598
 		}
1599 1599
 
1600 1600
 		echo $html;
1601 1601
 	}
1602 1602
 
1603
-	public function quiz_settings_panel( $lesson_id = 0, $quiz_id = 0 ) {
1603
+	public function quiz_settings_panel($lesson_id = 0, $quiz_id = 0) {
1604 1604
 
1605 1605
 
1606 1606
 		$html = '';
1607 1607
 
1608
-		if( ! $lesson_id && ! $quiz_id ) return $html;
1608
+		if ( ! $lesson_id && ! $quiz_id) return $html;
1609 1609
 
1610
-		$settings = $this->get_quiz_settings( $quiz_id );
1610
+		$settings = $this->get_quiz_settings($quiz_id);
1611 1611
 
1612
-		$html = Sensei()->admin->render_settings( $settings, $quiz_id, 'quiz-settings' );
1612
+		$html = Sensei()->admin->render_settings($settings, $quiz_id, 'quiz-settings');
1613 1613
 
1614 1614
 		return $html;
1615 1615
 
1616 1616
 	}
1617 1617
 
1618
-	public function get_quiz_settings( $quiz_id = 0 ) {
1618
+	public function get_quiz_settings($quiz_id = 0) {
1619 1619
 
1620 1620
 		$disable_passmark = '';
1621
-		$pass_required = get_post_meta( $quiz_id, '_pass_required', true );
1622
-		if( ! $pass_required ) {
1621
+		$pass_required = get_post_meta($quiz_id, '_pass_required', true);
1622
+		if ( ! $pass_required) {
1623 1623
 			$disable_passmark = 'hidden';
1624 1624
 		}
1625 1625
 
1626 1626
 		// Setup Questions Query
1627 1627
 		$questions = array();
1628
-		if ( 0 < $quiz_id ) {
1629
-			$questions = $this->lesson_quiz_questions( $quiz_id );
1628
+		if (0 < $quiz_id) {
1629
+			$questions = $this->lesson_quiz_questions($quiz_id);
1630 1630
 		}
1631 1631
 
1632 1632
 		// Count questions
1633 1633
 		$question_count = 0;
1634
-		foreach( $questions as $question ) {
1635
-			if( $question->post_type == 'multiple_question' ) {
1636
-				$question_number = get_post_meta( $question->ID, 'number', true );
1634
+		foreach ($questions as $question) {
1635
+			if ($question->post_type == 'multiple_question') {
1636
+				$question_number = get_post_meta($question->ID, 'number', true);
1637 1637
 				$question_count += $question_number;
1638 1638
 			} else {
1639 1639
 				++$question_count;
@@ -1643,15 +1643,15 @@  discard block
 block discarded – undo
1643 1643
 		$settings = array(
1644 1644
 			array(
1645 1645
 				'id' 			=> 'pass_required',
1646
-				'label'			=> __( 'Pass required to complete lesson', 'woothemes-sensei' ),
1647
-				'description'	=> __( 'The passmark must be achieved before the lesson is complete.', 'woothemes-sensei' ),
1646
+				'label'			=> __('Pass required to complete lesson', 'woothemes-sensei'),
1647
+				'description'	=> __('The passmark must be achieved before the lesson is complete.', 'woothemes-sensei'),
1648 1648
 				'type'			=> 'checkbox',
1649 1649
 				'default'		=> '',
1650 1650
 				'checked'		=> 'on',
1651 1651
 			),
1652 1652
 			array(
1653 1653
 				'id' 			=> 'quiz_passmark',
1654
-				'label'			=> __( 'Quiz passmark percentage', 'woothemes-sensei' ),
1654
+				'label'			=> __('Quiz passmark percentage', 'woothemes-sensei'),
1655 1655
 				'description'	=> '',
1656 1656
 				'type'			=> 'number',
1657 1657
 				'default'		=> 0,
@@ -1662,17 +1662,17 @@  discard block
 block discarded – undo
1662 1662
 			),
1663 1663
 			array(
1664 1664
 				'id' 			=> 'show_questions',
1665
-				'label'			=> __( 'Number of questions to show', 'woothemes-sensei' ),
1666
-				'description'	=> __( 'Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei' ),
1665
+				'label'			=> __('Number of questions to show', 'woothemes-sensei'),
1666
+				'description'	=> __('Show a random selection of questions from this quiz each time a student views it.', 'woothemes-sensei'),
1667 1667
 				'type'			=> 'number',
1668 1668
 				'default'		=> '',
1669
-				'placeholder'	=> __( 'All', 'woothemes-sensei' ),
1669
+				'placeholder'	=> __('All', 'woothemes-sensei'),
1670 1670
 				'min'			=> 1,
1671 1671
 				'max'			=> $question_count,
1672 1672
 			),
1673 1673
 			array(
1674 1674
 				'id' 			=> 'random_question_order',
1675
-				'label'			=> __( 'Randomise question order', 'woothemes-sensei' ),
1675
+				'label'			=> __('Randomise question order', 'woothemes-sensei'),
1676 1676
 				'description'	=> '',
1677 1677
 				'type'			=> 'checkbox',
1678 1678
 				'default'		=> 'no',
@@ -1680,23 +1680,23 @@  discard block
 block discarded – undo
1680 1680
 			),
1681 1681
 			array(
1682 1682
 				'id' 			=> 'quiz_grade_type',
1683
-				'label'			=> __( 'Grade quiz automatically', 'woothemes-sensei' ),
1684
-				'description'	=> __( 'Grades quiz and displays answer explanation immediately after completion. Only applicable if quiz is limited to Multiple Choice, True/False and Gap Fill questions. Questions that have a grade of zero are skipped during autograding.', 'woothemes-sensei' ),
1683
+				'label'			=> __('Grade quiz automatically', 'woothemes-sensei'),
1684
+				'description'	=> __('Grades quiz and displays answer explanation immediately after completion. Only applicable if quiz is limited to Multiple Choice, True/False and Gap Fill questions. Questions that have a grade of zero are skipped during autograding.', 'woothemes-sensei'),
1685 1685
 				'type'			=> 'checkbox',
1686 1686
 				'default'		=> 'auto',
1687 1687
 				'checked'		=> 'auto',
1688 1688
 			),
1689 1689
 			array(
1690 1690
 				'id' 			=> 'enable_quiz_reset',
1691
-				'label'			=> __( 'Allow user to retake the quiz', 'woothemes-sensei' ),
1692
-				'description'	=> __( 'Enables the quiz reset button.', 'woothemes-sensei' ),
1691
+				'label'			=> __('Allow user to retake the quiz', 'woothemes-sensei'),
1692
+				'description'	=> __('Enables the quiz reset button.', 'woothemes-sensei'),
1693 1693
 				'type'			=> 'checkbox',
1694 1694
 				'default'		=> '',
1695 1695
 				'checked'		=> 'on',
1696 1696
 			),
1697 1697
 		);
1698 1698
 
1699
-		return apply_filters( 'sensei_quiz_settings', $settings );
1699
+		return apply_filters('sensei_quiz_settings', $settings);
1700 1700
 	}
1701 1701
 
1702 1702
 	/**
@@ -1705,38 +1705,38 @@  discard block
 block discarded – undo
1705 1705
 	 * @access public
1706 1706
 	 * @return void
1707 1707
 	 */
1708
-	public function enqueue_scripts( $hook ) {
1708
+	public function enqueue_scripts($hook) {
1709 1709
 		global  $post_type;
1710 1710
 
1711
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question' ) );
1712
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
1713
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order' ) );
1711
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question'));
1712
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
1713
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings', 'lesson-order'));
1714 1714
 
1715 1715
 		// Test for Write Panel Pages
1716
-		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
1716
+		if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) {
1717 1717
 
1718
-			$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
1718
+			$suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
1719 1719
 
1720 1720
 			// Load the lessons script
1721 1721
             wp_enqueue_media();
1722
-			wp_enqueue_script( 'sensei-lesson-metadata', Sensei()->plugin_url . 'assets/js/lesson-metadata' . $suffix . '.js', array( 'jquery', 'select2' ,'jquery-ui-sortable' ), Sensei()->version, true );
1723
-			wp_enqueue_script( 'sensei-lesson-chosen', Sensei()->plugin_url . 'assets/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1724
-			wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery' . $suffix . '.js', array( 'jquery', 'sensei-lesson-chosen' ), Sensei()->version, true );
1722
+			wp_enqueue_script('sensei-lesson-metadata', Sensei()->plugin_url.'assets/js/lesson-metadata'.$suffix.'.js', array('jquery', 'select2', 'jquery-ui-sortable'), Sensei()->version, true);
1723
+			wp_enqueue_script('sensei-lesson-chosen', Sensei()->plugin_url.'assets/chosen/chosen.jquery'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1724
+			wp_enqueue_script('sensei-chosen-ajax', Sensei()->plugin_url.'assets/chosen/ajax-chosen.jquery'.$suffix.'.js', array('jquery', 'sensei-lesson-chosen'), Sensei()->version, true);
1725 1725
 
1726 1726
             // Load the bulk edit screen script
1727
-            if( 'edit.php' == $hook && 'lesson'==$_GET['post_type'] ) {
1728
-                wp_enqueue_script( 'sensei-lessons-bulk-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-bulk-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version , true);
1727
+            if ('edit.php' == $hook && 'lesson' == $_GET['post_type']) {
1728
+                wp_enqueue_script('sensei-lessons-bulk-edit', Sensei()->plugin_url.'assets/js/admin/lesson-bulk-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1729 1729
             }
1730 1730
 
1731 1731
 			// Localise script
1732
-			$translation_strings = array( 'right_colon' => __( 'Right:', 'woothemes-sensei' ), 'wrong_colon' => __( 'Wrong:', 'woothemes-sensei' ), 'add_file' => __( 'Add file', 'woothemes-sensei' ), 'change_file' => __( 'Change file', 'woothemes-sensei' ), 'confirm_remove' => __( 'Are you sure you want to remove this question?', 'woothemes-sensei' ), 'confirm_remove_multiple' => __( 'Are you sure you want to remove these questions?', 'woothemes-sensei' ), 'too_many_for_cat' => __( 'You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei' ) );
1733
-			$ajax_vars = array( 'lesson_update_question_nonce' => wp_create_nonce( 'lesson_update_question_nonce' ), 'lesson_add_course_nonce' => wp_create_nonce( 'lesson_add_course_nonce' ), 'lesson_update_grade_type_nonce' => wp_create_nonce( 'lesson_update_grade_type_nonce' ), 'lesson_update_question_order_nonce' => wp_create_nonce( 'lesson_update_question_order_nonce' ), 'lesson_update_question_order_random_nonce' => wp_create_nonce( 'lesson_update_question_order_random_nonce' ), 'lesson_add_multiple_questions_nonce' => wp_create_nonce( 'lesson_add_multiple_questions_nonce' ), 'lesson_remove_multiple_questions_nonce' => wp_create_nonce( 'lesson_remove_multiple_questions_nonce' ), 'lesson_add_existing_questions_nonce' => wp_create_nonce( 'lesson_add_existing_questions_nonce' ), 'filter_existing_questions_nonce' => wp_create_nonce( 'filter_existing_questions_nonce' ) );
1734
-			$data = array_merge( $translation_strings, $ajax_vars );
1735
-			wp_localize_script( 'sensei-lesson-metadata', 'woo_localized_data', $data );
1732
+			$translation_strings = array('right_colon' => __('Right:', 'woothemes-sensei'), 'wrong_colon' => __('Wrong:', 'woothemes-sensei'), 'add_file' => __('Add file', 'woothemes-sensei'), 'change_file' => __('Change file', 'woothemes-sensei'), 'confirm_remove' => __('Are you sure you want to remove this question?', 'woothemes-sensei'), 'confirm_remove_multiple' => __('Are you sure you want to remove these questions?', 'woothemes-sensei'), 'too_many_for_cat' => __('You have selected more questions than this category contains - please reduce the number of questions that you are adding.', 'woothemes-sensei'));
1733
+			$ajax_vars = array('lesson_update_question_nonce' => wp_create_nonce('lesson_update_question_nonce'), 'lesson_add_course_nonce' => wp_create_nonce('lesson_add_course_nonce'), 'lesson_update_grade_type_nonce' => wp_create_nonce('lesson_update_grade_type_nonce'), 'lesson_update_question_order_nonce' => wp_create_nonce('lesson_update_question_order_nonce'), 'lesson_update_question_order_random_nonce' => wp_create_nonce('lesson_update_question_order_random_nonce'), 'lesson_add_multiple_questions_nonce' => wp_create_nonce('lesson_add_multiple_questions_nonce'), 'lesson_remove_multiple_questions_nonce' => wp_create_nonce('lesson_remove_multiple_questions_nonce'), 'lesson_add_existing_questions_nonce' => wp_create_nonce('lesson_add_existing_questions_nonce'), 'filter_existing_questions_nonce' => wp_create_nonce('filter_existing_questions_nonce'));
1734
+			$data = array_merge($translation_strings, $ajax_vars);
1735
+			wp_localize_script('sensei-lesson-metadata', 'woo_localized_data', $data);
1736 1736
 
1737 1737
 			// Chosen RTL
1738
-			if ( is_rtl() ) {
1739
-				wp_enqueue_script( 'sensei-chosen-rtl', Sensei()->plugin_url . 'assets/chosen/chosen-rtl' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
1738
+			if (is_rtl()) {
1739
+				wp_enqueue_script('sensei-chosen-rtl', Sensei()->plugin_url.'assets/chosen/chosen-rtl'.$suffix.'.js', array('jquery'), Sensei()->version, true);
1740 1740
 			}
1741 1741
 
1742 1742
 		}
@@ -1750,16 +1750,16 @@  discard block
 block discarded – undo
1750 1750
 	 * @since  1.4.0
1751 1751
 	 * @return void
1752 1752
 	 */
1753
-	public function enqueue_styles ( $hook ) {
1753
+	public function enqueue_styles($hook) {
1754 1754
 		global  $post_type;
1755 1755
 
1756
-		$allowed_post_types = apply_filters( 'sensei_scripts_allowed_post_types', array( 'lesson', 'course', 'question', 'sensei_message' ) );
1757
-		$allowed_post_type_pages = apply_filters( 'sensei_scripts_allowed_post_type_pages', array( 'edit.php', 'post-new.php', 'post.php', 'edit-tags.php' ) );
1758
-		$allowed_pages = apply_filters( 'sensei_scripts_allowed_pages', array( 'sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings' ) );
1756
+		$allowed_post_types = apply_filters('sensei_scripts_allowed_post_types', array('lesson', 'course', 'question', 'sensei_message'));
1757
+		$allowed_post_type_pages = apply_filters('sensei_scripts_allowed_post_type_pages', array('edit.php', 'post-new.php', 'post.php', 'edit-tags.php'));
1758
+		$allowed_pages = apply_filters('sensei_scripts_allowed_pages', array('sensei_grading', 'sensei_analysis', 'sensei_learners', 'sensei_updates', 'woothemes-sensei-settings'));
1759 1759
 
1760 1760
 		// Test for Write Panel Pages
1761
-		if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) {
1762
-			wp_enqueue_style( 'woothemes-sensei-settings-api', esc_url( Sensei()->plugin_url . 'assets/css/settings.css' ), '', Sensei()->version );
1761
+		if (((isset($post_type) && in_array($post_type, $allowed_post_types)) && (isset($hook) && in_array($hook, $allowed_post_type_pages))) || (isset($_GET['page']) && in_array($_GET['page'], $allowed_pages))) {
1762
+			wp_enqueue_style('woothemes-sensei-settings-api', esc_url(Sensei()->plugin_url.'assets/css/settings.css'), '', Sensei()->version);
1763 1763
 		}
1764 1764
 
1765 1765
 	} // End enqueue_styles()
@@ -1771,12 +1771,12 @@  discard block
 block discarded – undo
1771 1771
 	 * @param  array $defaults
1772 1772
 	 * @return array $new_columns
1773 1773
 	 */
1774
-	public function add_column_headings ( $defaults ) {
1774
+	public function add_column_headings($defaults) {
1775 1775
 		$new_columns['cb'] = '<input type="checkbox" />';
1776
-		$new_columns['title'] = _x( 'Lesson Title', 'column name', 'woothemes-sensei' );
1777
-		$new_columns['lesson-course'] = _x( 'Course', 'column name', 'woothemes-sensei' );
1778
-		$new_columns['lesson-prerequisite'] = _x( 'Pre-requisite Lesson', 'column name', 'woothemes-sensei' );
1779
-		if ( isset( $defaults['date'] ) ) {
1776
+		$new_columns['title'] = _x('Lesson Title', 'column name', 'woothemes-sensei');
1777
+		$new_columns['lesson-course'] = _x('Course', 'column name', 'woothemes-sensei');
1778
+		$new_columns['lesson-prerequisite'] = _x('Pre-requisite Lesson', 'column name', 'woothemes-sensei');
1779
+		if (isset($defaults['date'])) {
1780 1780
 			$new_columns['date'] = $defaults['date'];
1781 1781
 		}
1782 1782
 		return $new_columns;
@@ -1790,23 +1790,23 @@  discard block
 block discarded – undo
1790 1790
 	 * @param  int $id
1791 1791
 	 * @return void
1792 1792
 	 */
1793
-	public function add_column_data ( $column_name, $id ) {
1793
+	public function add_column_data($column_name, $id) {
1794 1794
 		global $wpdb, $post;
1795 1795
 
1796
-		switch ( $column_name ) {
1796
+		switch ($column_name) {
1797 1797
 			case 'id':
1798 1798
 				echo $id;
1799 1799
 			break;
1800 1800
 			case 'lesson-course':
1801
-				$lesson_course_id = get_post_meta( $id, '_lesson_course', true);
1802
-				if ( 0 < absint( $lesson_course_id ) ) {
1803
-					echo '<a href="' . esc_url( get_edit_post_link( absint( $lesson_course_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $lesson_course_id ) ) ) ) . '">' . get_the_title( absint( $lesson_course_id ) ) . '</a>';
1801
+				$lesson_course_id = get_post_meta($id, '_lesson_course', true);
1802
+				if (0 < absint($lesson_course_id)) {
1803
+					echo '<a href="'.esc_url(get_edit_post_link(absint($lesson_course_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($lesson_course_id)))).'">'.get_the_title(absint($lesson_course_id)).'</a>';
1804 1804
 				} // End If Statement
1805 1805
 			break;
1806 1806
 			case 'lesson-prerequisite':
1807
-				$lesson_prerequisite_id = get_post_meta( $id, '_lesson_prerequisite', true);
1808
-				if ( 0 < absint( $lesson_prerequisite_id ) ) {
1809
-					echo '<a href="' . esc_url( get_edit_post_link( absint( $lesson_prerequisite_id ) ) ) . '" title="' . esc_attr( sprintf( __( 'Edit %s', 'woothemes-sensei' ), get_the_title( absint( $lesson_prerequisite_id ) ) ) ) . '">' . get_the_title( absint( $lesson_prerequisite_id ) ) . '</a>';
1807
+				$lesson_prerequisite_id = get_post_meta($id, '_lesson_prerequisite', true);
1808
+				if (0 < absint($lesson_prerequisite_id)) {
1809
+					echo '<a href="'.esc_url(get_edit_post_link(absint($lesson_prerequisite_id))).'" title="'.esc_attr(sprintf(__('Edit %s', 'woothemes-sensei'), get_the_title(absint($lesson_prerequisite_id)))).'">'.get_the_title(absint($lesson_prerequisite_id)).'</a>';
1810 1810
 				} // End If Statement
1811 1811
 			break;
1812 1812
 			default:
@@ -1820,14 +1820,14 @@  discard block
 block discarded – undo
1820 1820
 	 * @access public
1821 1821
 	 * @return void
1822 1822
 	 */
1823
-	public function lesson_add_course () {
1823
+	public function lesson_add_course() {
1824 1824
 		global $current_user;
1825 1825
 		//Add nonce security to the request
1826
-		if ( isset($_POST['lesson_add_course_nonce']) ) {
1827
-			$nonce = esc_html( $_POST['lesson_add_course_nonce'] );
1826
+		if (isset($_POST['lesson_add_course_nonce'])) {
1827
+			$nonce = esc_html($_POST['lesson_add_course_nonce']);
1828 1828
 		} // End If Statement
1829
-		if ( ! wp_verify_nonce( $nonce, 'lesson_add_course_nonce' )
1830
-            || ! current_user_can( 'edit_lessons' ) ) {
1829
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_course_nonce')
1830
+            || ! current_user_can('edit_lessons')) {
1831 1831
 			die('');
1832 1832
 		} // End If Statement
1833 1833
 		// Parse POST data
@@ -1849,14 +1849,14 @@  discard block
 block discarded – undo
1849 1849
 	 * @access public
1850 1850
 	 * @return void
1851 1851
 	 */
1852
-	public function lesson_update_question () {
1852
+	public function lesson_update_question() {
1853 1853
 		global $current_user;
1854 1854
 		//Add nonce security to the request
1855
-		if ( isset($_POST['lesson_update_question_nonce']) ) {
1856
-			$nonce = esc_html( $_POST['lesson_update_question_nonce'] );
1855
+		if (isset($_POST['lesson_update_question_nonce'])) {
1856
+			$nonce = esc_html($_POST['lesson_update_question_nonce']);
1857 1857
 		} // End If Statement
1858
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_nonce' )
1859
-            ||  ! current_user_can( 'edit_questions' )) {
1858
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_nonce')
1859
+            ||  ! current_user_can('edit_questions')) {
1860 1860
 
1861 1861
 			die('');
1862 1862
 
@@ -1866,30 +1866,30 @@  discard block
 block discarded – undo
1866 1866
 		// WP slashes all incoming data regardless of Magic Quotes setting (see wp_magic_quotes()), which means that
1867 1867
 		// even the $_POST['data'] encoded with encodeURIComponent has it's apostrophes slashed.
1868 1868
 		// So first restore the original unslashed apostrophes by removing those slashes
1869
-		$data = wp_unslash( $_POST['data'] );
1869
+		$data = wp_unslash($_POST['data']);
1870 1870
 		// Then parse the string to an array (note that parse_str automatically urldecodes all the variables)
1871 1871
 		$question_data = array();
1872 1872
 		parse_str($data, $question_data);
1873 1873
 		// Finally re-slash all elements to ensure consistancy for lesson_save_question()
1874
-		$question_data = wp_slash( $question_data );
1874
+		$question_data = wp_slash($question_data);
1875 1875
 		// Save the question
1876 1876
 		$return = false;
1877 1877
 		// Question Save and Delete logic
1878
-		if ( isset( $question_data['action'] ) && ( $question_data['action'] == 'delete' ) ) {
1878
+		if (isset($question_data['action']) && ($question_data['action'] == 'delete')) {
1879 1879
 			// Delete the Question
1880 1880
 			$return = $this->lesson_delete_question($question_data);
1881 1881
 		} else {
1882 1882
 			// Save the Question
1883
-			if ( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) {
1883
+			if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) {
1884 1884
 				$current_user = wp_get_current_user();
1885 1885
 				$question_data['post_author'] = $current_user->ID;
1886
-				$question_id = $this->lesson_save_question( $question_data );
1887
-				$question_type = Sensei()->question->get_question_type( $question_id );
1886
+				$question_id = $this->lesson_save_question($question_data);
1887
+				$question_type = Sensei()->question->get_question_type($question_id);
1888 1888
 
1889
-				$question_count = intval( $question_data['question_count'] );
1889
+				$question_count = intval($question_data['question_count']);
1890 1890
 				++$question_count;
1891 1891
 
1892
-				$return = $this->quiz_panel_question( $question_type, $question_count, $question_id );
1892
+				$return = $this->quiz_panel_question($question_type, $question_count, $question_id);
1893 1893
 			} // End If Statement
1894 1894
 		} // End If Statement
1895 1895
 
@@ -1904,49 +1904,49 @@  discard block
 block discarded – undo
1904 1904
 
1905 1905
 		//Add nonce security to the request
1906 1906
 		$nonce = '';
1907
-		if( isset( $_POST['lesson_add_multiple_questions_nonce'] ) ) {
1908
-			$nonce = esc_html( $_POST['lesson_add_multiple_questions_nonce'] );
1907
+		if (isset($_POST['lesson_add_multiple_questions_nonce'])) {
1908
+			$nonce = esc_html($_POST['lesson_add_multiple_questions_nonce']);
1909 1909
 		} // End If Statement
1910 1910
 
1911
-		if( ! wp_verify_nonce( $nonce, 'lesson_add_multiple_questions_nonce' )
1912
-            || ! current_user_can( 'edit_lessons' ) ) {
1913
-			die( $return );
1911
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_multiple_questions_nonce')
1912
+            || ! current_user_can('edit_lessons')) {
1913
+			die($return);
1914 1914
 		} // End If Statement
1915 1915
 
1916 1916
 		// Parse POST data
1917 1917
 		$data = $_POST['data'];
1918 1918
 		$question_data = array();
1919
-		parse_str( $data, $question_data );
1919
+		parse_str($data, $question_data);
1920 1920
 
1921
-		if( is_array( $question_data ) ) {
1922
-			if( isset( $question_data['quiz_id'] ) && ( 0 < absint( $question_data['quiz_id'] ) ) ) {
1921
+		if (is_array($question_data)) {
1922
+			if (isset($question_data['quiz_id']) && (0 < absint($question_data['quiz_id']))) {
1923 1923
 
1924
-				$quiz_id = intval( $question_data['quiz_id'] );
1925
-				$question_number = intval( $question_data['question_number'] );
1926
-				$question_category = intval( $question_data['question_category'] );
1924
+				$quiz_id = intval($question_data['quiz_id']);
1925
+				$question_number = intval($question_data['question_number']);
1926
+				$question_category = intval($question_data['question_category']);
1927 1927
 
1928
-				$question_counter = intval( $question_data['question_count'] );
1928
+				$question_counter = intval($question_data['question_count']);
1929 1929
 				++$question_counter;
1930 1930
 
1931
-				$cat = get_term( $question_category, 'question-category' );
1931
+				$cat = get_term($question_category, 'question-category');
1932 1932
 
1933 1933
 				$post_data = array(
1934 1934
 					'post_content' => '',
1935 1935
 					'post_status' => 'publish',
1936
-					'post_title' => sprintf( __( '%1$s Question(s) from %2$s', 'woothemes-sensei' ), $question_number, $cat->name ),
1936
+					'post_title' => sprintf(__('%1$s Question(s) from %2$s', 'woothemes-sensei'), $question_number, $cat->name),
1937 1937
 					'post_type' => 'multiple_question'
1938 1938
 				);
1939 1939
 
1940
-				$multiple_id = wp_insert_post( $post_data );
1940
+				$multiple_id = wp_insert_post($post_data);
1941 1941
 
1942
-				if( $multiple_id && ! is_wp_error( $multiple_id ) ) {
1943
-					add_post_meta( $multiple_id, 'category', $question_category );
1944
-					add_post_meta( $multiple_id, 'number', $question_number );
1945
-					add_post_meta( $multiple_id, '_quiz_id', $quiz_id, false );
1946
-					add_post_meta( $multiple_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_counter );
1947
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
1948
-					update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
1949
-					$return = $this->quiz_panel_question( 'category', $question_counter, $multiple_id, 'quiz', array( $cat->name, $question_number ) );
1942
+				if ($multiple_id && ! is_wp_error($multiple_id)) {
1943
+					add_post_meta($multiple_id, 'category', $question_category);
1944
+					add_post_meta($multiple_id, 'number', $question_number);
1945
+					add_post_meta($multiple_id, '_quiz_id', $quiz_id, false);
1946
+					add_post_meta($multiple_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_counter);
1947
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
1948
+					update_post_meta($lesson_id, '_quiz_has_questions', '1');
1949
+					$return = $this->quiz_panel_question('category', $question_counter, $multiple_id, 'quiz', array($cat->name, $question_number));
1950 1950
 				}
1951 1951
 			}
1952 1952
 		}
@@ -1960,25 +1960,25 @@  discard block
 block discarded – undo
1960 1960
 
1961 1961
 		//Add nonce security to the request
1962 1962
 		$nonce = '';
1963
-		if( isset( $_POST['lesson_remove_multiple_questions_nonce'] ) ) {
1964
-			$nonce = esc_html( $_POST['lesson_remove_multiple_questions_nonce'] );
1963
+		if (isset($_POST['lesson_remove_multiple_questions_nonce'])) {
1964
+			$nonce = esc_html($_POST['lesson_remove_multiple_questions_nonce']);
1965 1965
 		} // End If Statement
1966 1966
 
1967
-		if( ! wp_verify_nonce( $nonce, 'lesson_remove_multiple_questions_nonce' )
1968
-        || ! current_user_can( 'edit_lessons' ) ) {
1967
+		if ( ! wp_verify_nonce($nonce, 'lesson_remove_multiple_questions_nonce')
1968
+        || ! current_user_can('edit_lessons')) {
1969 1969
 			die('');
1970 1970
 		} // End If Statement
1971 1971
 
1972 1972
 		// Parse POST data
1973 1973
 		$data = $_POST['data'];
1974 1974
 		$question_data = array();
1975
-		parse_str( $data, $question_data );
1975
+		parse_str($data, $question_data);
1976 1976
 
1977
-		if( is_array( $question_data ) ) {
1978
-			wp_delete_post( $question_data['question_id'], true );
1977
+		if (is_array($question_data)) {
1978
+			wp_delete_post($question_data['question_id'], true);
1979 1979
 		}
1980 1980
 
1981
-		die( 'Deleted' );
1981
+		die('Deleted');
1982 1982
 	}
1983 1983
 
1984 1984
 	public function get_question_category_limit() {
@@ -1989,11 +1989,11 @@  discard block
 block discarded – undo
1989 1989
 		// Parse POST data
1990 1990
 		$data = $_POST['data'];
1991 1991
 		$cat_data = array();
1992
-		parse_str( $data, $cat_data );
1992
+		parse_str($data, $cat_data);
1993 1993
 
1994
-		if( isset( $cat_data['cat'] ) && '' != $cat_data['cat'] ) {
1995
-			$cat = get_term( $cat_data['cat'], 'question-category' );
1996
-			if( isset( $cat->count ) ) {
1994
+		if (isset($cat_data['cat']) && '' != $cat_data['cat']) {
1995
+			$cat = get_term($cat_data['cat'], 'question-category');
1996
+			if (isset($cat->count)) {
1997 1997
 				$return = $cat->count;
1998 1998
 			}
1999 1999
 		}
@@ -2007,45 +2007,45 @@  discard block
 block discarded – undo
2007 2007
 
2008 2008
 		//Add nonce security to the request
2009 2009
 		$nonce = '';
2010
-		if( isset( $_POST['lesson_add_existing_questions_nonce'] ) ) {
2011
-			$nonce = esc_html( $_POST['lesson_add_existing_questions_nonce'] );
2010
+		if (isset($_POST['lesson_add_existing_questions_nonce'])) {
2011
+			$nonce = esc_html($_POST['lesson_add_existing_questions_nonce']);
2012 2012
 		} // End If Statement
2013 2013
 
2014
-		if( ! wp_verify_nonce( $nonce, 'lesson_add_existing_questions_nonce' )
2015
-        || ! current_user_can( 'edit_lessons' ) ) {
2014
+		if ( ! wp_verify_nonce($nonce, 'lesson_add_existing_questions_nonce')
2015
+        || ! current_user_can('edit_lessons')) {
2016 2016
 			die('');
2017 2017
 		} // End If Statement
2018 2018
 
2019 2019
 		// Parse POST data
2020 2020
 		$data = $_POST['data'];
2021 2021
 		$question_data = array();
2022
-		parse_str( $data, $question_data );
2022
+		parse_str($data, $question_data);
2023 2023
 
2024 2024
 		$return = '';
2025 2025
 
2026
-		if( is_array( $question_data ) ) {
2026
+		if (is_array($question_data)) {
2027 2027
 
2028
-			if( isset( $question_data['questions'] ) && '' != $question_data['questions'] ) {
2028
+			if (isset($question_data['questions']) && '' != $question_data['questions']) {
2029 2029
 
2030
-				$questions = explode( ',', trim( $question_data['questions'], ',' ) );
2030
+				$questions = explode(',', trim($question_data['questions'], ','));
2031 2031
 				$quiz_id = $question_data['quiz_id'];
2032
-				$question_count = intval( $question_data['question_count'] );
2032
+				$question_count = intval($question_data['question_count']);
2033 2033
 
2034
-				foreach( $questions as $question_id ) {
2034
+				foreach ($questions as $question_id) {
2035 2035
 
2036 2036
 					++$question_count;
2037 2037
 
2038
-					$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2039
-					if( ! in_array( $quiz_id, $quizzes ) ) {
2040
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2041
-						$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2042
-						update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2038
+					$quizzes = get_post_meta($question_id, '_quiz_id', false);
2039
+					if ( ! in_array($quiz_id, $quizzes)) {
2040
+			    		add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2041
+						$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
2042
+						update_post_meta($lesson_id, '_quiz_has_questions', '1');
2043 2043
 			    	}
2044 2044
 
2045
-			    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2046
-					$question_type = Sensei()->question->get_question_type( $question_id );
2045
+			    	add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count);
2046
+					$question_type = Sensei()->question->get_question_type($question_id);
2047 2047
 
2048
-					$return .= $this->quiz_panel_question( $question_type, $question_count, $question_id );
2048
+					$return .= $this->quiz_panel_question($question_type, $question_count, $question_id);
2049 2049
 				}
2050 2050
 			}
2051 2051
 		}
@@ -2057,14 +2057,14 @@  discard block
 block discarded – undo
2057 2057
 
2058 2058
 	public function lesson_update_grade_type() {
2059 2059
 		//Add nonce security to the request
2060
-		if ( isset($_POST['lesson_update_grade_type_nonce']) ) {
2060
+		if (isset($_POST['lesson_update_grade_type_nonce'])) {
2061 2061
 
2062
-			$nonce = esc_html( $_POST['lesson_update_grade_type_nonce'] );
2062
+			$nonce = esc_html($_POST['lesson_update_grade_type_nonce']);
2063 2063
 
2064 2064
 		} // End If Statement
2065 2065
 
2066
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_grade_type_nonce' )
2067
-        || ! current_user_can( 'edit_lessons' ) ) {
2066
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_grade_type_nonce')
2067
+        || ! current_user_can('edit_lessons')) {
2068 2068
 
2069 2069
 			die('');
2070 2070
 
@@ -2074,18 +2074,18 @@  discard block
 block discarded – undo
2074 2074
 		$data = $_POST['data'];
2075 2075
 		$quiz_data = array();
2076 2076
 		parse_str($data, $quiz_data);
2077
-		update_post_meta( $quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type'] );
2077
+		update_post_meta($quiz_data['quiz_id'], '_quiz_grade_type', $quiz_data['quiz_grade_type']);
2078 2078
 		die();
2079 2079
 	}
2080 2080
 
2081 2081
 	public function lesson_update_question_order() {
2082 2082
 		// Add nonce security to the request
2083
-		if ( isset($_POST['lesson_update_question_order_nonce']) ) {
2084
-			$nonce = esc_html( $_POST['lesson_update_question_order_nonce'] );
2083
+		if (isset($_POST['lesson_update_question_order_nonce'])) {
2084
+			$nonce = esc_html($_POST['lesson_update_question_order_nonce']);
2085 2085
 		} // End If Statement
2086 2086
 
2087
-        if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_nonce' )
2088
-            ||! current_user_can( 'edit_lessons' ) ) {
2087
+        if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_nonce')
2088
+            ||! current_user_can('edit_lessons')) {
2089 2089
 			die('');
2090 2090
 		} // End If Statement
2091 2091
 
@@ -2093,25 +2093,25 @@  discard block
 block discarded – undo
2093 2093
 		$data = $_POST['data'];
2094 2094
 		$quiz_data = array();
2095 2095
 		parse_str($data, $quiz_data);
2096
-		if( strlen( $quiz_data['question_order'] ) > 0 ) {
2097
-			$questions = explode( ',', $quiz_data['question_order'] );
2096
+		if (strlen($quiz_data['question_order']) > 0) {
2097
+			$questions = explode(',', $quiz_data['question_order']);
2098 2098
 			$o = 1;
2099
-			foreach( $questions as $question_id ) {
2100
-				update_post_meta( $question_id, '_quiz_question_order' . $quiz_data['quiz_id'], $quiz_data['quiz_id'] . '000' . $o );
2099
+			foreach ($questions as $question_id) {
2100
+				update_post_meta($question_id, '_quiz_question_order'.$quiz_data['quiz_id'], $quiz_data['quiz_id'].'000'.$o);
2101 2101
 				++$o;
2102 2102
 			}
2103
-			update_post_meta( $quiz_data['quiz_id'], '_question_order', $questions );
2103
+			update_post_meta($quiz_data['quiz_id'], '_question_order', $questions);
2104 2104
 		}
2105 2105
 		die();
2106 2106
 	}
2107 2107
 
2108 2108
 	public function lesson_update_question_order_random() {
2109 2109
 		//Add nonce security to the request
2110
-		if ( isset($_POST['lesson_update_question_order_random_nonce']) ) {
2111
-			$nonce = esc_html( $_POST['lesson_update_question_order_random_nonce'] );
2110
+		if (isset($_POST['lesson_update_question_order_random_nonce'])) {
2111
+			$nonce = esc_html($_POST['lesson_update_question_order_random_nonce']);
2112 2112
 		} // End If Statement
2113
-		if ( ! wp_verify_nonce( $nonce, 'lesson_update_question_order_random_nonce' )
2114
-            || ! current_user_can( 'edit_lessons' ) ) {
2113
+		if ( ! wp_verify_nonce($nonce, 'lesson_update_question_order_random_nonce')
2114
+            || ! current_user_can('edit_lessons')) {
2115 2115
 
2116 2116
 			die('');
2117 2117
 
@@ -2120,7 +2120,7 @@  discard block
 block discarded – undo
2120 2120
 		$data = $_POST['data'];
2121 2121
 		$quiz_data = array();
2122 2122
 		parse_str($data, $quiz_data);
2123
-		update_post_meta( $quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order'] );
2123
+		update_post_meta($quiz_data['quiz_id'], '_random_question_order', $quiz_data['random_question_order']);
2124 2124
 		die();
2125 2125
 	}
2126 2126
 
@@ -2131,7 +2131,7 @@  discard block
 block discarded – undo
2131 2131
 	 * @param array $data (default: array())
2132 2132
 	 * @return integer|boolean $course_id or false
2133 2133
 	 */
2134
-	private function lesson_save_course( $data = array() ) {
2134
+	private function lesson_save_course($data = array()) {
2135 2135
 		global $current_user;
2136 2136
 		$return = false;
2137 2137
 		// Setup the course data
@@ -2140,58 +2140,58 @@  discard block
 block discarded – undo
2140 2140
 		$course_title = '';
2141 2141
 		$course_prerequisite = 0;
2142 2142
 		$course_category = 0;
2143
-		if ( isset( $data[ 'course_id' ] ) && ( 0 < absint( $data[ 'course_id' ] ) ) ) {
2144
-			$course_id = absint( $data[ 'course_id' ] );
2143
+		if (isset($data['course_id']) && (0 < absint($data['course_id']))) {
2144
+			$course_id = absint($data['course_id']);
2145 2145
 		} // End If Statement
2146
-		if ( isset( $data[ 'course_title' ] ) && ( '' != $data[ 'course_title' ] ) ) {
2147
-			$course_title = $data[ 'course_title' ];
2146
+		if (isset($data['course_title']) && ('' != $data['course_title'])) {
2147
+			$course_title = $data['course_title'];
2148 2148
 		} // End If Statement
2149 2149
 		$post_title = $course_title;
2150
-		if ( isset($data[ 'post_author' ]) ) {
2151
-			$post_author = $data[ 'post_author' ];
2150
+		if (isset($data['post_author'])) {
2151
+			$post_author = $data['post_author'];
2152 2152
 		} else {
2153 2153
 			$current_user = wp_get_current_user();
2154 2154
 			$post_author = $current_user->ID;
2155 2155
 		} // End If Statement
2156 2156
 		$post_status = 'publish';
2157 2157
 		$post_type = 'course';
2158
-		if ( isset( $data[ 'course_content' ] ) && ( '' != $data[ 'course_content' ] ) ) {
2159
-			$course_content = $data[ 'course_content' ];
2158
+		if (isset($data['course_content']) && ('' != $data['course_content'])) {
2159
+			$course_content = $data['course_content'];
2160 2160
 		} // End If Statement
2161 2161
 		$post_content = $course_content;
2162 2162
 		// Course Query Arguments
2163
-		$post_type_args = array(	'post_content' => $post_content,
2163
+		$post_type_args = array('post_content' => $post_content,
2164 2164
   		    						'post_status' => $post_status,
2165 2165
   		    						'post_title' => $post_title,
2166 2166
   		    						'post_type' => $post_type
2167 2167
   		    						);
2168 2168
   		// Only save if there is a valid title
2169
-  		if ( $post_title != '' ) {
2169
+  		if ($post_title != '') {
2170 2170
   		    // Check for prerequisite courses & product id
2171
-  		    $course_prerequisite_id = absint( $data[ 'course_prerequisite' ] );
2172
-  		    $course_woocommerce_product_id = absint( $data[ 'course_woocommerce_product' ] );
2173
-  		    $course_category_id = absint( $data[ 'course_category' ] );
2174
-  		    if ( 0 == $course_woocommerce_product_id ) { $course_woocommerce_product_id = '-'; }
2171
+  		    $course_prerequisite_id = absint($data['course_prerequisite']);
2172
+  		    $course_woocommerce_product_id = absint($data['course_woocommerce_product']);
2173
+  		    $course_category_id = absint($data['course_category']);
2174
+  		    if (0 == $course_woocommerce_product_id) { $course_woocommerce_product_id = '-'; }
2175 2175
   		    // Insert or Update the Lesson Quiz
2176
-		    if ( 0 < $course_id ) {
2177
-		    	$post_type_args[ 'ID' ] = $course_id;
2176
+		    if (0 < $course_id) {
2177
+		    	$post_type_args['ID'] = $course_id;
2178 2178
 		    	$course_id = wp_update_post($post_type_args);
2179
-		    	update_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2180
-		    	update_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2181
-		    	if ( 0 < $course_category_id ) {
2182
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2179
+		    	update_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id);
2180
+		    	update_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id);
2181
+		    	if (0 < $course_category_id) {
2182
+		    		wp_set_object_terms($course_id, $course_category_id, 'course-category');
2183 2183
 		    	} // End If Statement
2184 2184
 		    } else {
2185 2185
 		    	$course_id = wp_insert_post($post_type_args);
2186
-		    	add_post_meta( $course_id, '_course_prerequisite', $course_prerequisite_id );
2187
-		    	add_post_meta( $course_id, '_course_woocommerce_product', $course_woocommerce_product_id );
2188
-		    	if ( 0 < $course_category_id ) {
2189
-		    		wp_set_object_terms( $course_id, $course_category_id, 'course-category' );
2186
+		    	add_post_meta($course_id, '_course_prerequisite', $course_prerequisite_id);
2187
+		    	add_post_meta($course_id, '_course_woocommerce_product', $course_woocommerce_product_id);
2188
+		    	if (0 < $course_category_id) {
2189
+		    		wp_set_object_terms($course_id, $course_category_id, 'course-category');
2190 2190
 		    	} // End If Statement
2191 2191
 		    } // End If Statement
2192 2192
 		} // End If Statement
2193 2193
   		// Check that the insert or update saved by testing the post id
2194
-  		if ( 0 < $course_id ) {
2194
+  		if (0 < $course_id) {
2195 2195
   			$return = $course_id;
2196 2196
   		} // End If Statement
2197 2197
   		return $return;
@@ -2205,7 +2205,7 @@  discard block
 block discarded – undo
2205 2205
 	 * @param array $data (default: array())
2206 2206
 	 * @return integer|boolean $question_id or false
2207 2207
 	 */
2208
-	public function lesson_save_question( $data = array(), $context = 'quiz' ) {
2208
+	public function lesson_save_question($data = array(), $context = 'quiz') {
2209 2209
 		$return = false;
2210 2210
 		// Save the Questions
2211 2211
 		// Setup the Question data
@@ -2217,130 +2217,130 @@  discard block
 block discarded – undo
2217 2217
 		$question_category = '';
2218 2218
 
2219 2219
 		// Handle Question Type
2220
-		if ( isset( $data[ 'question_type' ] ) && ( '' != $data[ 'question_type' ] ) ) {
2221
-			$question_type = $data[ 'question_type' ];
2220
+		if (isset($data['question_type']) && ('' != $data['question_type'])) {
2221
+			$question_type = $data['question_type'];
2222 2222
 		} // End If Statement
2223 2223
 
2224
-		if ( isset( $data[ 'question_category' ] ) && ( '' != $data[ 'question_category' ] ) ) {
2225
-			$question_category = $data[ 'question_category' ];
2224
+		if (isset($data['question_category']) && ('' != $data['question_category'])) {
2225
+			$question_category = $data['question_category'];
2226 2226
 		} // End If Statement
2227 2227
 
2228
-		if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) {
2229
-			$question_id = absint( $data[ 'question_id' ] );
2228
+		if (isset($data['question_id']) && (0 < absint($data['question_id']))) {
2229
+			$question_id = absint($data['question_id']);
2230 2230
 		} // End If Statement
2231
-		if ( isset( $data[ 'question' ] ) && ( '' != $data[ 'question' ] ) ) {
2232
-			$question_text = $data[ 'question' ];
2231
+		if (isset($data['question']) && ('' != $data['question'])) {
2232
+			$question_text = $data['question'];
2233 2233
 		} // End If Statement
2234 2234
 		$post_title = $question_text;
2235 2235
 		// Handle Default Fields (multiple choice)
2236
-		if ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answers' ] ) && ( '' != $data[ 'question_right_answers' ] ) ) {
2237
-			$question_right_answers = $data[ 'question_right_answers' ];
2236
+		if ('multiple-choice' == $question_type && isset($data['question_right_answers']) && ('' != $data['question_right_answers'])) {
2237
+			$question_right_answers = $data['question_right_answers'];
2238 2238
 		} // End If Statement
2239
-		elseif ( 'multiple-choice' == $question_type && isset( $data[ 'question_right_answer' ] ) && ( '' != $data[ 'question_right_answer' ] ) ) {
2240
-			$question_right_answer = $data[ 'question_right_answer' ];
2239
+		elseif ('multiple-choice' == $question_type && isset($data['question_right_answer']) && ('' != $data['question_right_answer'])) {
2240
+			$question_right_answer = $data['question_right_answer'];
2241 2241
 		} // End If Statement
2242
-		if ( 'multiple-choice' == $question_type && isset( $data[ 'question_wrong_answers' ] ) && ( '' != $data[ 'question_wrong_answers' ] ) ) {
2243
-			$question_wrong_answers = $data[ 'question_wrong_answers' ];
2242
+		if ('multiple-choice' == $question_type && isset($data['question_wrong_answers']) && ('' != $data['question_wrong_answers'])) {
2243
+			$question_wrong_answers = $data['question_wrong_answers'];
2244 2244
 		} // End If Statement
2245 2245
 		// Handle Boolean Fields - Edit
2246
-		if ( 'boolean' == $question_type && isset( $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) && ( '' != $data[ 'question_' . $question_id . '_right_answer_boolean' ] ) ) {
2247
-			$question_right_answer = $data[ 'question_' . $question_id . '_right_answer_boolean' ];
2246
+		if ('boolean' == $question_type && isset($data['question_'.$question_id.'_right_answer_boolean']) && ('' != $data['question_'.$question_id.'_right_answer_boolean'])) {
2247
+			$question_right_answer = $data['question_'.$question_id.'_right_answer_boolean'];
2248 2248
 		} // End If Statement
2249 2249
 		// Handle Boolean Fields - Add
2250
-		if ( 'boolean' == $question_type && isset( $data[ 'question_right_answer_boolean' ] ) && ( '' != $data[ 'question_right_answer_boolean' ] ) ) {
2251
-			$question_right_answer = $data[ 'question_right_answer_boolean' ];
2250
+		if ('boolean' == $question_type && isset($data['question_right_answer_boolean']) && ('' != $data['question_right_answer_boolean'])) {
2251
+			$question_right_answer = $data['question_right_answer_boolean'];
2252 2252
 		} // End If Statement
2253 2253
 		// Handle Gap Fill Fields
2254
-		if ( 'gap-fill' == $question_type && isset( $data[ 'add_question_right_answer_gapfill_gap' ] ) && '' != $data[ 'add_question_right_answer_gapfill_gap' ] ) {
2255
-			$question_right_answer = $data[ 'add_question_right_answer_gapfill_pre' ] . '||' . $data[ 'add_question_right_answer_gapfill_gap' ] . '||' . $data[ 'add_question_right_answer_gapfill_post' ];
2254
+		if ('gap-fill' == $question_type && isset($data['add_question_right_answer_gapfill_gap']) && '' != $data['add_question_right_answer_gapfill_gap']) {
2255
+			$question_right_answer = $data['add_question_right_answer_gapfill_pre'].'||'.$data['add_question_right_answer_gapfill_gap'].'||'.$data['add_question_right_answer_gapfill_post'];
2256 2256
 		} // End If Statement
2257 2257
 		// Handle Multi Line Fields
2258
-		if ( 'multi-line' == $question_type && isset( $data[ 'add_question_right_answer_multiline' ] ) && ( '' != $data[ 'add_question_right_answer_multiline' ] ) ) {
2259
-			$question_right_answer = $data[ 'add_question_right_answer_multiline' ];
2258
+		if ('multi-line' == $question_type && isset($data['add_question_right_answer_multiline']) && ('' != $data['add_question_right_answer_multiline'])) {
2259
+			$question_right_answer = $data['add_question_right_answer_multiline'];
2260 2260
 		} // End If Statement
2261 2261
 		// Handle Single Line Fields
2262
-		if ( 'single-line' == $question_type && isset( $data[ 'add_question_right_answer_singleline' ] ) && ( '' != $data[ 'add_question_right_answer_singleline' ] ) ) {
2263
-			$question_right_answer = $data[ 'add_question_right_answer_singleline' ];
2262
+		if ('single-line' == $question_type && isset($data['add_question_right_answer_singleline']) && ('' != $data['add_question_right_answer_singleline'])) {
2263
+			$question_right_answer = $data['add_question_right_answer_singleline'];
2264 2264
 		} // End If Statement
2265 2265
 		// Handle File Upload Fields
2266
-		if ( 'file-upload' == $question_type && isset( $data[ 'add_question_right_answer_fileupload' ] ) && ( '' != $data[ 'add_question_right_answer_fileupload' ] ) ) {
2267
-			$question_right_answer = $data[ 'add_question_right_answer_fileupload' ];
2266
+		if ('file-upload' == $question_type && isset($data['add_question_right_answer_fileupload']) && ('' != $data['add_question_right_answer_fileupload'])) {
2267
+			$question_right_answer = $data['add_question_right_answer_fileupload'];
2268 2268
 		} // End If Statement
2269
-		if ( 'file-upload' == $question_type && isset( $data[ 'add_question_wrong_answer_fileupload' ] ) && ( '' != $data[ 'add_question_wrong_answer_fileupload' ] ) ) {
2270
-			$question_wrong_answers = array( $data[ 'add_question_wrong_answer_fileupload' ] );
2269
+		if ('file-upload' == $question_type && isset($data['add_question_wrong_answer_fileupload']) && ('' != $data['add_question_wrong_answer_fileupload'])) {
2270
+			$question_wrong_answers = array($data['add_question_wrong_answer_fileupload']);
2271 2271
 		} // End If Statement
2272 2272
 
2273 2273
 		// Handle Question Grade
2274
-		if ( isset( $data[ 'question_grade' ] ) && ( '' != $data[ 'question_grade' ] ) ) {
2275
-			$question_grade = $data[ 'question_grade' ];
2274
+		if (isset($data['question_grade']) && ('' != $data['question_grade'])) {
2275
+			$question_grade = $data['question_grade'];
2276 2276
 		} // End If Statement
2277 2277
 
2278 2278
 		// Handle Answer Feedback
2279 2279
 		$answer_feedback = '';
2280
-		if ( isset( $data[ 'answer_feedback_boolean' ] ) && !empty( $data[ 'answer_feedback_boolean' ] ) ) {
2280
+		if (isset($data['answer_feedback_boolean']) && ! empty($data['answer_feedback_boolean'])) {
2281 2281
 
2282
-            $answer_feedback = $data[ 'answer_feedback_boolean' ];
2282
+            $answer_feedback = $data['answer_feedback_boolean'];
2283 2283
 
2284
-		}elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){
2284
+		}elseif (isset($data['answer_feedback_multiple_choice']) && ! empty($data['answer_feedback_multiple_choice'])) {
2285 2285
 
2286
-            $answer_feedback = $data[ 'answer_feedback_multiple_choice' ];
2286
+            $answer_feedback = $data['answer_feedback_multiple_choice'];
2287 2287
 
2288
-        }elseif( isset( $data[ 'answer_feedback' ] )  ){
2288
+        }elseif (isset($data['answer_feedback'])) {
2289 2289
 
2290
-            $answer_feedback = $data[ 'answer_feedback' ];
2290
+            $answer_feedback = $data['answer_feedback'];
2291 2291
 
2292 2292
         } // End If Statement
2293 2293
 
2294 2294
 		$post_title = $question_text;
2295
-		$post_author = $data[ 'post_author' ];
2295
+		$post_author = $data['post_author'];
2296 2296
 		$post_status = 'publish';
2297 2297
 		$post_type = 'question';
2298 2298
 		// Handle the extended question text
2299
-		if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) {
2300
-			$post_content = $data[ 'question_description' ];
2299
+		if (isset($data['question_description']) && ('' != $data['question_description'])) {
2300
+			$post_content = $data['question_description'];
2301 2301
 		}
2302 2302
 		else {
2303 2303
 			$post_content = '';
2304 2304
 		}
2305 2305
 		// Question Query Arguments
2306
-		$post_type_args = array(	'post_content' => $post_content,
2306
+		$post_type_args = array('post_content' => $post_content,
2307 2307
   		    						'post_status' => $post_status,
2308 2308
   		    						'post_title' => $post_title,
2309 2309
   		    						'post_type' => $post_type
2310 2310
   		    						);
2311 2311
 
2312 2312
   		// Remove empty values and reindex the array
2313
-  		if ( is_array( $question_right_answers ) && 0 < count($question_right_answers) ) {
2314
-  			$question_right_answers_array = array_values( array_filter( $question_right_answers, 'strlen' ) );
2313
+  		if (is_array($question_right_answers) && 0 < count($question_right_answers)) {
2314
+  			$question_right_answers_array = array_values(array_filter($question_right_answers, 'strlen'));
2315 2315
   			$question_right_answers = array();
2316 2316
 
2317
-  			foreach( $question_right_answers_array as $answer ) {
2318
-  				if( ! in_array( $answer, $question_right_answers ) ) {
2317
+  			foreach ($question_right_answers_array as $answer) {
2318
+  				if ( ! in_array($answer, $question_right_answers)) {
2319 2319
   					$question_right_answers[] = $answer;
2320 2320
   				}
2321 2321
   			}
2322
-  			if ( 0 < count($question_right_answers) ) {
2322
+  			if (0 < count($question_right_answers)) {
2323 2323
   				$question_right_answer = $question_right_answers;
2324 2324
   			}
2325 2325
   		} // End If Statement
2326
-  		$right_answer_count = count( $question_right_answer );
2326
+  		$right_answer_count = count($question_right_answer);
2327 2327
 
2328 2328
 		// Remove empty values and reindex the array
2329
-  		if ( is_array( $question_wrong_answers ) ) {
2330
-  			$question_wrong_answers_array = array_values( array_filter( $question_wrong_answers, 'strlen' ) );
2329
+  		if (is_array($question_wrong_answers)) {
2330
+  			$question_wrong_answers_array = array_values(array_filter($question_wrong_answers, 'strlen'));
2331 2331
   			$question_wrong_answers = array();
2332 2332
   		} // End If Statement
2333 2333
 
2334
-  		foreach( $question_wrong_answers_array as $answer ) {
2335
-  			if( ! in_array( $answer, $question_wrong_answers ) ) {
2334
+  		foreach ($question_wrong_answers_array as $answer) {
2335
+  			if ( ! in_array($answer, $question_wrong_answers)) {
2336 2336
   				$question_wrong_answers[] = $answer;
2337 2337
   			}
2338 2338
   		}
2339 2339
 
2340
-  		$wrong_answer_count = count( $question_wrong_answers );
2340
+  		$wrong_answer_count = count($question_wrong_answers);
2341 2341
 
2342 2342
   		// Only save if there is a valid title
2343
-  		if ( $post_title != '' ) {
2343
+  		if ($post_title != '') {
2344 2344
 
2345 2345
   			// Get Quiz ID for the question
2346 2346
   		    $quiz_id = $data['quiz_id'];
@@ -2350,86 +2350,86 @@  discard block
 block discarded – undo
2350 2350
 
2351 2351
   		    // Get answer order
2352 2352
   		    $answer_order = '';
2353
-  		    if( isset( $data['answer_order'] ) ) {
2353
+  		    if (isset($data['answer_order'])) {
2354 2354
 				$answer_order = $data['answer_order'];
2355 2355
 			}
2356 2356
 
2357 2357
 			// Get random order selection
2358 2358
 			$random_order = 'no';
2359
-			if( isset( $data['random_order'] ) ) {
2359
+			if (isset($data['random_order'])) {
2360 2360
 				$random_order = $data['random_order'];
2361 2361
 			}
2362 2362
 
2363 2363
   		    // Insert or Update the question
2364
-  		    if ( 0 < $question_id ) {
2364
+  		    if (0 < $question_id) {
2365 2365
 
2366
-  		    	$post_type_args[ 'ID' ] = $question_id;
2367
-		    	$question_id = wp_update_post( $post_type_args );
2366
+  		    	$post_type_args['ID'] = $question_id;
2367
+		    	$question_id = wp_update_post($post_type_args);
2368 2368
 
2369 2369
 		    	// Update poast meta
2370
-		    	if( 'quiz' == $context ) {
2371
-		    		$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2372
-		    		if( ! in_array( $quiz_id, $quizzes ) ) {
2373
-			    		add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2370
+		    	if ('quiz' == $context) {
2371
+		    		$quizzes = get_post_meta($question_id, '_quiz_id', false);
2372
+		    		if ( ! in_array($quiz_id, $quizzes)) {
2373
+			    		add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2374 2374
 			    	}
2375 2375
 		    	}
2376 2376
 
2377
-		    	update_post_meta( $question_id, '_question_grade', $question_grade );
2378
-		    	update_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2379
-		    	update_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2380
-		    	update_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2381
-		    	update_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2382
-		    	update_post_meta( $question_id, '_question_media', $question_media );
2383
-		    	update_post_meta( $question_id, '_answer_order', $answer_order );
2384
-		    	update_post_meta( $question_id, '_random_order', $random_order );
2385
-
2386
-		    	if( 'quiz' != $context ) {
2387
-		    		wp_set_post_terms( $question_id, array( $question_type ), 'question-type', false );
2377
+		    	update_post_meta($question_id, '_question_grade', $question_grade);
2378
+		    	update_post_meta($question_id, '_question_right_answer', $question_right_answer);
2379
+		    	update_post_meta($question_id, '_right_answer_count', $right_answer_count);
2380
+		    	update_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers);
2381
+		    	update_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count);
2382
+		    	update_post_meta($question_id, '_question_media', $question_media);
2383
+		    	update_post_meta($question_id, '_answer_order', $answer_order);
2384
+		    	update_post_meta($question_id, '_random_order', $random_order);
2385
+
2386
+		    	if ('quiz' != $context) {
2387
+		    		wp_set_post_terms($question_id, array($question_type), 'question-type', false);
2388 2388
 		    	}
2389 2389
 				// Don't store empty value, no point
2390
-				if ( !empty($answer_feedback) ) {
2391
-					update_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2390
+				if ( ! empty($answer_feedback)) {
2391
+					update_post_meta($question_id, '_answer_feedback', $answer_feedback);
2392 2392
 				}
2393 2393
 
2394 2394
 		    } else {
2395
-				$question_id = wp_insert_post( $post_type_args );
2396
-				$question_count = intval( $data['question_count'] );
2395
+				$question_id = wp_insert_post($post_type_args);
2396
+				$question_count = intval($data['question_count']);
2397 2397
 				++$question_count;
2398 2398
 
2399 2399
 				// Set post meta
2400
-				if( 'quiz' == $context ) {
2401
-					add_post_meta( $question_id, '_quiz_id', $quiz_id, false );
2402
-					$lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true );
2403
-					update_post_meta( $lesson_id, '_quiz_has_questions', '1' );
2400
+				if ('quiz' == $context) {
2401
+					add_post_meta($question_id, '_quiz_id', $quiz_id, false);
2402
+					$lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true);
2403
+					update_post_meta($lesson_id, '_quiz_has_questions', '1');
2404 2404
 				}
2405 2405
 
2406
-				if( isset( $question_grade ) ) {
2407
-		    		add_post_meta( $question_id, '_question_grade', $question_grade );
2406
+				if (isset($question_grade)) {
2407
+		    		add_post_meta($question_id, '_question_grade', $question_grade);
2408 2408
 		    	}
2409
-		    	add_post_meta( $question_id, '_question_right_answer', $question_right_answer );
2410
-		    	add_post_meta( $question_id, '_right_answer_count', $right_answer_count );
2411
-		    	add_post_meta( $question_id, '_question_wrong_answers', $question_wrong_answers );
2412
-		    	add_post_meta( $question_id, '_wrong_answer_count', $wrong_answer_count );
2413
-		    	add_post_meta( $question_id, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $question_count );
2414
-		    	add_post_meta( $question_id, '_question_media', $question_media );
2415
-		    	add_post_meta( $question_id, '_answer_order', $answer_order );
2416
-		    	add_post_meta( $question_id, '_random_order', $random_order );
2409
+		    	add_post_meta($question_id, '_question_right_answer', $question_right_answer);
2410
+		    	add_post_meta($question_id, '_right_answer_count', $right_answer_count);
2411
+		    	add_post_meta($question_id, '_question_wrong_answers', $question_wrong_answers);
2412
+		    	add_post_meta($question_id, '_wrong_answer_count', $wrong_answer_count);
2413
+		    	add_post_meta($question_id, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$question_count);
2414
+		    	add_post_meta($question_id, '_question_media', $question_media);
2415
+		    	add_post_meta($question_id, '_answer_order', $answer_order);
2416
+		    	add_post_meta($question_id, '_random_order', $random_order);
2417 2417
 				// Don't store empty value, no point
2418
-				if ( !empty($answer_feedback) ) {
2419
-					add_post_meta( $question_id, '_answer_feedback', $answer_feedback );
2418
+				if ( ! empty($answer_feedback)) {
2419
+					add_post_meta($question_id, '_answer_feedback', $answer_feedback);
2420 2420
 				}
2421 2421
 
2422 2422
 		    	// Set the post terms for question-type
2423
-			    wp_set_post_terms( $question_id, array( $question_type ), 'question-type' );
2423
+			    wp_set_post_terms($question_id, array($question_type), 'question-type');
2424 2424
 
2425
-			    if( $question_category ) {
2426
-	    			wp_set_post_terms( $question_id, array( $question_category ), 'question-category' );
2425
+			    if ($question_category) {
2426
+	    			wp_set_post_terms($question_id, array($question_category), 'question-category');
2427 2427
 	    		}
2428 2428
 
2429 2429
 		    } // End If Statement
2430 2430
 		} // End If Statement
2431 2431
   		// Check that the insert or update saved by testing the post id
2432
-  		if ( 0 < $question_id ) {
2432
+  		if (0 < $question_id) {
2433 2433
   			$return = $question_id;
2434 2434
   		} // End If Statement
2435 2435
   		return $return;
@@ -2443,20 +2443,20 @@  discard block
 block discarded – undo
2443 2443
 	 * @param array $data (default: array())
2444 2444
 	 * @return boolean
2445 2445
 	 */
2446
-	private function lesson_delete_question( $data = array() ) {
2446
+	private function lesson_delete_question($data = array()) {
2447 2447
 
2448 2448
 		// Get which question to delete
2449 2449
 		$question_id = 0;
2450
-		if ( isset( $data[ 'question_id' ] ) && ( 0 < absint( $data[ 'question_id' ] ) ) ) {
2451
-			$question_id = absint( $data[ 'question_id' ] );
2450
+		if (isset($data['question_id']) && (0 < absint($data['question_id']))) {
2451
+			$question_id = absint($data['question_id']);
2452 2452
 		} // End If Statement
2453 2453
 		// Delete the question
2454
-		if ( 0 < $question_id ) {
2455
-			$quizzes = get_post_meta( $question_id, '_quiz_id', false );
2454
+		if (0 < $question_id) {
2455
+			$quizzes = get_post_meta($question_id, '_quiz_id', false);
2456 2456
 
2457
-			foreach( $quizzes as $quiz_id ) {
2458
-				if( $quiz_id == $data['quiz_id'] ) {
2459
-					delete_post_meta( $question_id, '_quiz_id', $quiz_id );
2457
+			foreach ($quizzes as $quiz_id) {
2458
+				if ($quiz_id == $data['quiz_id']) {
2459
+					delete_post_meta($question_id, '_quiz_id', $quiz_id);
2460 2460
 				}
2461 2461
 			}
2462 2462
 
@@ -2475,9 +2475,9 @@  discard block
 block discarded – undo
2475 2475
 	public function lesson_complexities() {
2476 2476
 
2477 2477
 		// V2 - make filter for this array
2478
-        $lesson_complexities = array( 	'easy' => __( 'Easy', 'woothemes-sensei' ),
2479
-									'std' => __( 'Standard', 'woothemes-sensei' ),
2480
-									'hard' => __( 'Hard', 'woothemes-sensei' )
2478
+        $lesson_complexities = array('easy' => __('Easy', 'woothemes-sensei'),
2479
+									'std' => __('Standard', 'woothemes-sensei'),
2480
+									'hard' => __('Hard', 'woothemes-sensei')
2481 2481
 									);
2482 2482
 
2483 2483
 		return $lesson_complexities;
@@ -2492,9 +2492,9 @@  discard block
 block discarded – undo
2492 2492
 	 * @param string $post_status (default: 'publish')
2493 2493
 	 * @return int
2494 2494
 	 */
2495
-	public function lesson_count( $post_status = 'publish', $course_id = false ) {
2495
+	public function lesson_count($post_status = 'publish', $course_id = false) {
2496 2496
 
2497
-		$post_args = array(	'post_type'         => 'lesson',
2497
+		$post_args = array('post_type'         => 'lesson',
2498 2498
 							'posts_per_page'    => -1,
2499 2499
 //							'orderby'           => 'menu_order date',
2500 2500
 //							'order'             => 'ASC',
@@ -2502,7 +2502,7 @@  discard block
 block discarded – undo
2502 2502
 							'suppress_filters'  => 0,
2503 2503
 							'fields'            => 'ids',
2504 2504
 							);
2505
-		if( $course_id ) {
2505
+		if ($course_id) {
2506 2506
 			$post_args['meta_query'][] = array(
2507 2507
 				'key' => '_lesson_course',
2508 2508
 				'value' => $course_id,
@@ -2519,10 +2519,10 @@  discard block
 block discarded – undo
2519 2519
 
2520 2520
 		// Allow WP to generate the complex final query, just shortcut to only do an overall count
2521 2521
 //		add_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
2522
-		$lessons_query = new WP_Query( apply_filters( 'sensei_lesson_count', $post_args ) );
2522
+		$lessons_query = new WP_Query(apply_filters('sensei_lesson_count', $post_args));
2523 2523
 //		remove_filter( 'posts_clauses', array( 'WooThemes_Sensei_Utils', 'get_posts_count_only_filter' ) );
2524 2524
 
2525
-		return count( $lessons_query->posts );
2525
+		return count($lessons_query->posts);
2526 2526
 	} // End lesson_count()
2527 2527
 
2528 2528
 
@@ -2535,11 +2535,11 @@  discard block
 block discarded – undo
2535 2535
 	 * @param string $fields (default: 'ids')
2536 2536
 	 * @return int $quiz_id
2537 2537
 	 */
2538
-	public function lesson_quizzes( $lesson_id = 0, $post_status = 'any', $fields = 'ids' ) {
2538
+	public function lesson_quizzes($lesson_id = 0, $post_status = 'any', $fields = 'ids') {
2539 2539
 
2540 2540
 		$posts_array = array();
2541 2541
 
2542
-		$post_args = array(	'post_type' 		=> 'quiz',
2542
+		$post_args = array('post_type' 		=> 'quiz',
2543 2543
 							'posts_per_page' 		=> 1,
2544 2544
 							'orderby'         	=> 'title',
2545 2545
     						'order'           	=> 'DESC',
@@ -2548,7 +2548,7 @@  discard block
 block discarded – undo
2548 2548
 							'suppress_filters' 	=> 0,
2549 2549
 							'fields'            => $fields
2550 2550
 							);
2551
-		$posts_array = get_posts( $post_args );
2551
+		$posts_array = get_posts($post_args);
2552 2552
         $quiz_id = array_shift($posts_array);
2553 2553
 
2554 2554
 		return $quiz_id;
@@ -2571,37 +2571,37 @@  discard block
 block discarded – undo
2571 2571
      *
2572 2572
 	 * @return array $questions { $question type WP_Post }
2573 2573
 	 */
2574
-	public function lesson_quiz_questions( $quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC' ) {
2574
+	public function lesson_quiz_questions($quiz_id = 0, $post_status = 'any', $orderby = 'meta_value_num title', $order = 'ASC') {
2575 2575
 
2576 2576
 		$quiz_id = (string) $quiz_id;
2577
-        $quiz_lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id );
2577
+        $quiz_lesson_id = Sensei()->quiz->get_lesson_id($quiz_id);
2578 2578
 
2579 2579
         // setup the user id
2580
-        if( is_admin() ) {
2581
-            $user_id = isset( $_GET['user'] ) ? $_GET['user'] : '' ;
2580
+        if (is_admin()) {
2581
+            $user_id = isset($_GET['user']) ? $_GET['user'] : '';
2582 2582
         } else {
2583 2583
             $user_id = get_current_user_id();
2584 2584
         }
2585 2585
 
2586 2586
         // get the users current status on the lesson
2587
-        $user_lesson_status = Sensei_Utils::user_lesson_status( $quiz_lesson_id, $user_id );
2587
+        $user_lesson_status = Sensei_Utils::user_lesson_status($quiz_lesson_id, $user_id);
2588 2588
 
2589 2589
 		// Set the default question order if it has not already been set for this quiz
2590
-		$this->set_default_question_order( $quiz_id );
2590
+		$this->set_default_question_order($quiz_id);
2591 2591
 
2592 2592
 		// If viewing quiz on the frontend then show questions in random order if set
2593
-		if ( ! is_admin() ) {
2594
-			$random_order = get_post_meta( $quiz_id, '_random_question_order', true );
2595
-			if( $random_order && $random_order == 'yes' ) {
2593
+		if ( ! is_admin()) {
2594
+			$random_order = get_post_meta($quiz_id, '_random_question_order', true);
2595
+			if ($random_order && $random_order == 'yes') {
2596 2596
 				$orderby = 'rand';
2597 2597
 			}
2598 2598
 		}
2599 2599
 
2600 2600
 		// Get all questions and multiple questions
2601 2601
 		$question_query_args = array(
2602
-			'post_type' 		=> array( 'question', 'multiple_question' ),
2602
+			'post_type' 		=> array('question', 'multiple_question'),
2603 2603
 			'posts_per_page' 	=> -1,
2604
-			'meta_key'        	=> '_quiz_question_order' . $quiz_id,
2604
+			'meta_key'        	=> '_quiz_question_order'.$quiz_id,
2605 2605
 			'orderby'         	=> $orderby,
2606 2606
 			'order'           	=> $order,
2607 2607
 			'meta_query'		=> array(
@@ -2615,7 +2615,7 @@  discard block
 block discarded – undo
2615 2615
 		);
2616 2616
 
2617 2617
         //query the questions
2618
-		$questions_query = new WP_Query( $question_query_args );
2618
+		$questions_query = new WP_Query($question_query_args);
2619 2619
 
2620 2620
         // Set return array to initially include all items
2621 2621
         $questions = $questions_query->posts;
@@ -2625,20 +2625,20 @@  discard block
 block discarded – undo
2625 2625
 
2626 2626
 		// If viewing quiz on frontend or in grading then only single questions must be shown
2627 2627
 		$selected_questions = false;
2628
-		if( ! is_admin() || ( is_admin() && isset( $_GET['page'] ) && 'sensei_grading' == $_GET['page'] && isset( $_GET['user'] ) && isset( $_GET['quiz_id'] ) ) ) {
2628
+		if ( ! is_admin() || (is_admin() && isset($_GET['page']) && 'sensei_grading' == $_GET['page'] && isset($_GET['user']) && isset($_GET['quiz_id']))) {
2629 2629
 
2630 2630
 			// Fetch the questions that the user was asked in their quiz if they have already completed it
2631
-			$questions_asked_string = !empty( $user_lesson_status->comment_ID) ? get_comment_meta( $user_lesson_status->comment_ID, 'questions_asked', true ) : false;
2632
-			if( !empty($questions_asked_string) ) {
2631
+			$questions_asked_string = ! empty($user_lesson_status->comment_ID) ? get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true) : false;
2632
+			if ( ! empty($questions_asked_string)) {
2633 2633
 
2634
-				$selected_questions = explode( ',', $questions_asked_string );
2634
+				$selected_questions = explode(',', $questions_asked_string);
2635 2635
 
2636 2636
 				// Fetch each question in the order in which they were asked
2637 2637
 				$questions = array();
2638
-				foreach( $selected_questions as $question_id ) {
2639
-					if( ! $question_id ) continue;
2640
-					$question = get_post( $question_id );
2641
-					if( ! isset( $question ) || ! isset( $question->ID ) ) continue;
2638
+				foreach ($selected_questions as $question_id) {
2639
+					if ( ! $question_id) continue;
2640
+					$question = get_post($question_id);
2641
+					if ( ! isset($question) || ! isset($question->ID)) continue;
2642 2642
 					$questions[] = $question;
2643 2643
 				}
2644 2644
 
@@ -2650,24 +2650,24 @@  discard block
 block discarded – undo
2650 2650
 				$existing_questions = array();
2651 2651
 
2652 2652
 				// Set array of questions that already exist so we can prevent duplicates from appearing
2653
-				foreach( $questions_array as $question ) {
2654
-					if( 'question' != $question->post_type ) continue;
2653
+				foreach ($questions_array as $question) {
2654
+					if ('question' != $question->post_type) continue;
2655 2655
 					$existing_questions[] = $question->ID;
2656 2656
 				}
2657 2657
 
2658 2658
 				// Include only single questions in the return array
2659 2659
 				$questions_loop = $questions_array;
2660 2660
 				$questions_array = array();
2661
-				foreach( $questions_loop as $k => $question ) {
2661
+				foreach ($questions_loop as $k => $question) {
2662 2662
 
2663 2663
 					// If this is a single question then include it
2664
-					if( 'question' == $question->post_type ) {
2664
+					if ('question' == $question->post_type) {
2665 2665
 						$questions_array[] = $question;
2666 2666
 					} else {
2667 2667
 
2668 2668
 						// If this is a multiple question then get the specified amount of questions from the specified category
2669
-						$question_cat = intval( get_post_meta( $question->ID, 'category', true ) );
2670
-						$question_number = intval( get_post_meta( $question->ID, 'number', true ) );
2669
+						$question_cat = intval(get_post_meta($question->ID, 'category', true));
2670
+						$question_number = intval(get_post_meta($question->ID, 'number', true));
2671 2671
 
2672 2672
 						$qargs = array(
2673 2673
 							'post_type' 		=> 'question',
@@ -2684,14 +2684,14 @@  discard block
 block discarded – undo
2684 2684
 							'suppress_filters' 	=> 0,
2685 2685
 							'post__not_in'		=> $existing_questions,
2686 2686
 						);
2687
-						$cat_questions = get_posts( $qargs );
2687
+						$cat_questions = get_posts($qargs);
2688 2688
 
2689 2689
 						// Merge results into return array
2690
-						$questions_array = array_merge( $questions_array, $cat_questions );
2690
+						$questions_array = array_merge($questions_array, $cat_questions);
2691 2691
 
2692 2692
 						// Add selected questions to existing questions array to prevent duplicates from being added
2693
-						foreach( $questions_array as $cat_question ) {
2694
-							if( in_array( $cat_question->ID, $existing_questions ) ) continue;
2693
+						foreach ($questions_array as $cat_question) {
2694
+							if (in_array($cat_question->ID, $existing_questions)) continue;
2695 2695
 							$existing_questions[] = $cat_question->ID;
2696 2696
 						}
2697 2697
 					}
@@ -2703,29 +2703,29 @@  discard block
 block discarded – undo
2703 2703
 		}
2704 2704
 
2705 2705
 		// If user has not already taken the quiz and a limited number of questions are to be shown, then show a random selection of the specified amount of questions
2706
-		if( ! $selected_questions ) {
2706
+		if ( ! $selected_questions) {
2707 2707
 
2708 2708
 			// Only limit questions like this on the frontend
2709
-			if( ! is_admin() ) {
2709
+			if ( ! is_admin()) {
2710 2710
 
2711 2711
 				// Get number of questions to show
2712
-				$show_questions = intval( get_post_meta( $quiz_id, '_show_questions', true ) );
2713
-				if( $show_questions ) {
2712
+				$show_questions = intval(get_post_meta($quiz_id, '_show_questions', true));
2713
+				if ($show_questions) {
2714 2714
 
2715 2715
 					// Get random set of array keys from selected questions array
2716
-					$selected_questions = array_rand( $questions_array, $show_questions );
2716
+					$selected_questions = array_rand($questions_array, $show_questions);
2717 2717
 
2718 2718
 					// Loop through all questions and pick the the ones to be shown based on the random key selection
2719 2719
 					$questions = array();
2720
-					foreach( $questions_array as $k => $question ) {
2720
+					foreach ($questions_array as $k => $question) {
2721 2721
 
2722 2722
 						// Random keys will always be an array, unless only one question is to be shown
2723
-						if( is_array( $selected_questions ) ) {
2724
-							if( in_array( $k, $selected_questions ) ) {
2723
+						if (is_array($selected_questions)) {
2724
+							if (in_array($k, $selected_questions)) {
2725 2725
 								$questions[] = $question;
2726 2726
 							}
2727
-						} elseif( 1 == $show_questions ) {
2728
-							if ( $selected_questions == $k ) {
2727
+						} elseif (1 == $show_questions) {
2728
+							if ($selected_questions == $k) {
2729 2729
 								$questions[] = $question;
2730 2730
 							}
2731 2731
 						}
@@ -2736,12 +2736,12 @@  discard block
 block discarded – undo
2736 2736
 
2737 2737
         // Save the questions that will be asked for the current user
2738 2738
         // this happens only once per user/quiz, unless the user resets the quiz
2739
-        if( ! is_admin() ){
2739
+        if ( ! is_admin()) {
2740 2740
 
2741
-            if( $user_lesson_status ) {
2741
+            if ($user_lesson_status) {
2742 2742
 
2743 2743
                 $questions_asked = get_comment_meta($user_lesson_status->comment_ID, 'questions_asked', true);
2744
-                if ( empty($questions_asked) && $user_lesson_status) {
2744
+                if (empty($questions_asked) && $user_lesson_status) {
2745 2745
 
2746 2746
                     $questions_asked = array();
2747 2747
                     foreach ($questions as $question) {
@@ -2764,7 +2764,7 @@  discard block
 block discarded – undo
2764 2764
          * @hooked Sensei_Teacher::allow_teacher_access_to_questions
2765 2765
          * @since 1.8.0
2766 2766
          */
2767
-		return apply_filters( 'sensei_lesson_quiz_questions', $questions,  $quiz_id  );
2767
+		return apply_filters('sensei_lesson_quiz_questions', $questions, $quiz_id);
2768 2768
 
2769 2769
 	} // End lesson_quiz_questions()
2770 2770
 
@@ -2772,13 +2772,13 @@  discard block
 block discarded – undo
2772 2772
 	 * Set the default quiz order
2773 2773
 	 * @param integer $quiz_id ID of quiz
2774 2774
 	 */
2775
-	public function set_default_question_order( $quiz_id = 0 ) {
2775
+	public function set_default_question_order($quiz_id = 0) {
2776 2776
 
2777
-		if( $quiz_id ) {
2777
+		if ($quiz_id) {
2778 2778
 
2779
-			$question_order = get_post_meta( $quiz_id, '_question_order', true );
2779
+			$question_order = get_post_meta($quiz_id, '_question_order', true);
2780 2780
 
2781
-			if( ! $question_order ) {
2781
+			if ( ! $question_order) {
2782 2782
 
2783 2783
 				$args = array(
2784 2784
 					'post_type' 		=> 'question',
@@ -2794,11 +2794,11 @@  discard block
 block discarded – undo
2794 2794
 					'post_status'		=> 'any',
2795 2795
 					'suppress_filters' 	=> 0
2796 2796
 				);
2797
-				$questions = get_posts( $args );
2797
+				$questions = get_posts($args);
2798 2798
 
2799 2799
 				$o = 1;
2800
-				foreach( $questions as $question ) {
2801
-					add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '000' . $o, true );
2800
+				foreach ($questions as $question) {
2801
+					add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'000'.$o, true);
2802 2802
 					$o++;
2803 2803
 				}
2804 2804
 			}
@@ -2817,36 +2817,36 @@  discard block
 block discarded – undo
2817 2817
 	 * @param string $height (default: '100')
2818 2818
 	 * @return string
2819 2819
 	 */
2820
-	public function lesson_image( $lesson_id = 0, $width = '100', $height = '100', $widget = false ) {
2820
+	public function lesson_image($lesson_id = 0, $width = '100', $height = '100', $widget = false) {
2821 2821
 
2822 2822
 		$html = '';
2823 2823
 
2824 2824
 		// Get Width and Height settings
2825
-		if ( ( $width == '100' ) && ( $height == '100' ) ) {
2825
+		if (($width == '100') && ($height == '100')) {
2826 2826
 
2827
-			if ( is_singular( 'lesson' ) ) {
2827
+			if (is_singular('lesson')) {
2828 2828
 
2829
-				if ( ! $widget && ! Sensei()->settings->settings[ 'lesson_single_image_enable' ] ) {
2829
+				if ( ! $widget && ! Sensei()->settings->settings['lesson_single_image_enable']) {
2830 2830
 
2831 2831
 					return '';
2832 2832
 
2833 2833
 				} // End If Statement
2834 2834
 
2835 2835
 				$image_thumb_size = 'lesson_single_image';
2836
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
2836
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
2837 2837
 				$width = $dimensions['width'];
2838 2838
 				$height = $dimensions['height'];
2839 2839
 				$crop = $dimensions['crop'];
2840 2840
 
2841 2841
 			} else {
2842 2842
 
2843
-				if ( ! $widget && ! Sensei()->settings->settings[ 'course_lesson_image_enable' ] ) {
2843
+				if ( ! $widget && ! Sensei()->settings->settings['course_lesson_image_enable']) {
2844 2844
 
2845 2845
 					return '';
2846 2846
 				} // End If Statement
2847 2847
 
2848 2848
 				$image_thumb_size = 'lesson_archive_image';
2849
-				$dimensions = Sensei()->get_image_size( $image_thumb_size );
2849
+				$dimensions = Sensei()->get_image_size($image_thumb_size);
2850 2850
 				$width = $dimensions['width'];
2851 2851
 				$height = $dimensions['height'];
2852 2852
 				$crop = $dimensions['crop'];
@@ -2857,23 +2857,23 @@  discard block
 block discarded – undo
2857 2857
 
2858 2858
 		$img_url = '';
2859 2859
 
2860
-		if ( has_post_thumbnail( $lesson_id ) ) {
2860
+		if (has_post_thumbnail($lesson_id)) {
2861 2861
 
2862 2862
    			// Get Featured Image
2863
-   			$img_url = get_the_post_thumbnail( $lesson_id, array( $width, $height ), array( 'class' => 'woo-image thumbnail alignleft') );
2863
+   			$img_url = get_the_post_thumbnail($lesson_id, array($width, $height), array('class' => 'woo-image thumbnail alignleft'));
2864 2864
 
2865 2865
  		} else {
2866 2866
 
2867 2867
  			// Display Image Placeholder if none
2868
-			if ( Sensei()->settings->settings[ 'placeholder_images_enable' ] ) {
2868
+			if (Sensei()->settings->settings['placeholder_images_enable']) {
2869 2869
 
2870
-                $img_url = apply_filters( 'sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/' . $width . 'x' . $height . '" class="woo-image thumbnail alignleft" />' );
2870
+                $img_url = apply_filters('sensei_lesson_placeholder_image_url', '<img src="http://placehold.it/'.$width.'x'.$height.'" class="woo-image thumbnail alignleft" />');
2871 2871
 
2872 2872
 			} // End If Statement
2873 2873
 
2874 2874
 		} // End If Statement
2875 2875
 
2876
-		$html .= '<a href="' . get_permalink( $lesson_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $lesson_id ) ) . '">' . $img_url . '</a>';
2876
+		$html .= '<a href="'.get_permalink($lesson_id).'" title="'.esc_attr(get_post_field('post_title', $lesson_id)).'">'.$img_url.'</a>';
2877 2877
 
2878 2878
 		return $html;
2879 2879
 
@@ -2885,9 +2885,9 @@  discard block
 block discarded – undo
2885 2885
      * @since 1.9.0
2886 2886
      * @param integer $lesson_id
2887 2887
      */
2888
-    public static function the_lesson_image( $lesson_id = 0 ){
2888
+    public static function the_lesson_image($lesson_id = 0) {
2889 2889
 
2890
-        echo Sensei()->lesson->lesson_image( $lesson_id );
2890
+        echo Sensei()->lesson->lesson_image($lesson_id);
2891 2891
 
2892 2892
     }
2893 2893
 
@@ -2898,17 +2898,17 @@  discard block
 block discarded – undo
2898 2898
      * @param bool $add_p_tags should the excerpt be wrapped by calling wpautop()
2899 2899
 	 * @return string
2900 2900
 	 */
2901
-	public static function lesson_excerpt( $lesson = null, $add_p_tags = true ) {
2901
+	public static function lesson_excerpt($lesson = null, $add_p_tags = true) {
2902 2902
 		$html = '';
2903
-		if ( is_a( $lesson, 'WP_Post' ) && 'lesson' == $lesson->post_type ) {
2903
+		if (is_a($lesson, 'WP_Post') && 'lesson' == $lesson->post_type) {
2904 2904
 
2905
-            $excerpt =  $lesson->post_excerpt;
2905
+            $excerpt = $lesson->post_excerpt;
2906 2906
 
2907 2907
             // if $add_p_tags true wrap with <p> else return the excerpt as is
2908
-            $html =  $add_p_tags ? wpautop( $excerpt ) : $excerpt;
2908
+            $html = $add_p_tags ? wpautop($excerpt) : $excerpt;
2909 2909
 
2910 2910
 		}
2911
-		return apply_filters( 'sensei_lesson_excerpt', $html );
2911
+		return apply_filters('sensei_lesson_excerpt', $html);
2912 2912
 
2913 2913
 	} // End lesson_excerpt()
2914 2914
 
@@ -2921,20 +2921,20 @@  discard block
 block discarded – undo
2921 2921
      * @param int $lesson_id
2922 2922
      * @return int|bool $course_id or bool when nothing is found.
2923 2923
      */
2924
-     public function get_course_id( $lesson_id ){
2924
+     public function get_course_id($lesson_id) {
2925 2925
 
2926
-         if( ! isset( $lesson_id ) || empty( $lesson_id )
2927
-         ||  'lesson' != get_post_type( $lesson_id ) ){
2926
+         if ( ! isset($lesson_id) || empty($lesson_id)
2927
+         ||  'lesson' != get_post_type($lesson_id)) {
2928 2928
              return false;
2929 2929
          }
2930 2930
 
2931
-         $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true);
2931
+         $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
2932 2932
 
2933 2933
          // make sure the course id is valid
2934
-         if( empty( $lesson_course_id )
2935
-             || is_array( $lesson_course_id )
2936
-             || intval( $lesson_course_id ) < 1
2937
-             || 'course' != get_post_type( $lesson_course_id ) ){
2934
+         if (empty($lesson_course_id)
2935
+             || is_array($lesson_course_id)
2936
+             || intval($lesson_course_id) < 1
2937
+             || 'course' != get_post_type($lesson_course_id)) {
2938 2938
 
2939 2939
              return false;
2940 2940
 
@@ -2961,11 +2961,11 @@  discard block
 block discarded – undo
2961 2961
      * @param string $post_type
2962 2962
      * @return void
2963 2963
      */
2964
-    public function all_lessons_edit_fields( $column_name, $post_type ) {
2964
+    public function all_lessons_edit_fields($column_name, $post_type) {
2965 2965
 
2966 2966
         // only show these options ont he lesson post type edit screen
2967
-        if( 'lesson' != $post_type || 'lesson-course' != $column_name
2968
-            || ! current_user_can( 'edit_lessons' ) ) {
2967
+        if ('lesson' != $post_type || 'lesson-course' != $column_name
2968
+            || ! current_user_can('edit_lessons')) {
2969 2969
             return;
2970 2970
         }
2971 2971
 
@@ -2973,41 +2973,41 @@  discard block
 block discarded – undo
2973 2973
         <fieldset class="sensei-edit-field-set inline-edit-lesson">
2974 2974
             <div class="sensei-inline-edit-col column-<?php echo $column_name ?>">
2975 2975
                     <?php
2976
-                    echo '<h4>' . __('Lesson Information', 'woothemes-sensei') . '</h4>';
2976
+                    echo '<h4>'.__('Lesson Information', 'woothemes-sensei').'</h4>';
2977 2977
                     // create a nonce field to be  used as a security measure when saving the data
2978
-                    wp_nonce_field( 'bulk-edit-lessons', '_edit_lessons_nonce' );
2979
-                    wp_nonce_field( 'sensei-save-post-meta','woo_' . $this->token . '_nonce'  );
2978
+                    wp_nonce_field('bulk-edit-lessons', '_edit_lessons_nonce');
2979
+                    wp_nonce_field('sensei-save-post-meta', 'woo_'.$this->token.'_nonce');
2980 2980
 
2981 2981
                     // unchanged option - we need this in because
2982 2982
                     // the default option in bulk edit should not be empty. If it is
2983 2983
                     // the user will erase data they didn't want to touch.
2984
-                    $no_change_text = '-- ' . __('No Change', 'woothemes-sensei') . ' --';
2984
+                    $no_change_text = '-- '.__('No Change', 'woothemes-sensei').' --';
2985 2985
 
2986 2986
                     //
2987 2987
                     //course selection
2988 2988
                     //
2989
-                    $courses =  WooThemes_Sensei_Course::get_all_courses();
2989
+                    $courses = WooThemes_Sensei_Course::get_all_courses();
2990 2990
                     $course_options = array();
2991
-                    if ( count( $courses ) > 0 ) {
2992
-                        foreach ($courses as $course ){
2993
-                            $course_options[ $course->ID ] = get_the_title( $course->ID );
2991
+                    if (count($courses) > 0) {
2992
+                        foreach ($courses as $course) {
2993
+                            $course_options[$course->ID] = get_the_title($course->ID);
2994 2994
                         }
2995 2995
                     }
2996 2996
                     //pre-append the no change option
2997
-                    $course_options['-1']=  $no_change_text;
2998
-                    $course_attributes = array( 'name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course' , 'class'=>' ' );
2999
-                    $course_field =  Sensei_Utils::generate_drop_down( '-1', $course_options, $course_attributes );
3000
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Course', 'woothemes-sensei'),   $course_field  );
2997
+                    $course_options['-1'] = $no_change_text;
2998
+                    $course_attributes = array('name'=> 'lesson_course', 'id'=>'sensei-edit-lesson-course', 'class'=>' ');
2999
+                    $course_field = Sensei_Utils::generate_drop_down('-1', $course_options, $course_attributes);
3000
+                    echo $this->generate_all_lessons_edit_field(__('Lesson Course', 'woothemes-sensei'), $course_field);
3001 3001
 
3002 3002
                     //
3003 3003
                     // lesson complexity selection
3004 3004
                     //
3005
-                    $lesson_complexities =  $this->lesson_complexities();
3005
+                    $lesson_complexities = $this->lesson_complexities();
3006 3006
                     //pre-append the no change option
3007
-                    $lesson_complexities['-1']=  $no_change_text;
3008
-                    $complexity_dropdown_attributes = array( 'name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity' , 'class'=>' ');
3009
-                    $complexity_filed =  Sensei_Utils::generate_drop_down( '-1', $lesson_complexities, $complexity_dropdown_attributes );
3010
-                    echo $this->generate_all_lessons_edit_field( __('Lesson Complexity', 'woothemes-sensei'),   $complexity_filed  );
3007
+                    $lesson_complexities['-1'] = $no_change_text;
3008
+                    $complexity_dropdown_attributes = array('name'=> 'lesson_complexity', 'id'=>'sensei-edit-lesson-complexity', 'class'=>' ');
3009
+                    $complexity_filed = Sensei_Utils::generate_drop_down('-1', $lesson_complexities, $complexity_dropdown_attributes);
3010
+                    echo $this->generate_all_lessons_edit_field(__('Lesson Complexity', 'woothemes-sensei'), $complexity_filed);
3011 3011
 
3012 3012
                     ?>
3013 3013
 
@@ -3020,34 +3020,34 @@  discard block
 block discarded – undo
3020 3020
                     //
3021 3021
                     $pass_required_options = array(
3022 3022
                         '-1' => $no_change_text,
3023
-                         '0' => __('No','woothemes'),
3024
-                         '1' => __('Yes','woothemes'),
3023
+                         '0' => __('No', 'woothemes'),
3024
+                         '1' => __('Yes', 'woothemes'),
3025 3025
                     );
3026 3026
 
3027
-                    $pass_required_select_attributes = array( 'name'=> 'pass_required',
3027
+                    $pass_required_select_attributes = array('name'=> 'pass_required',
3028 3028
                                                                 'id'=> 'sensei-edit-lesson-pass-required',
3029
-                                                                'class'=>' '   );
3030
-                    $require_pass_field =  Sensei_Utils::generate_drop_down( '-1', $pass_required_options, $pass_required_select_attributes, false );
3031
-                    echo $this->generate_all_lessons_edit_field( __('Pass required', 'woothemes-sensei'),   $require_pass_field  );
3029
+                                                                'class'=>' ');
3030
+                    $require_pass_field = Sensei_Utils::generate_drop_down('-1', $pass_required_options, $pass_required_select_attributes, false);
3031
+                    echo $this->generate_all_lessons_edit_field(__('Pass required', 'woothemes-sensei'), $require_pass_field);
3032 3032
 
3033 3033
                     //
3034 3034
                     // Quiz pass percentage
3035 3035
                     //
3036 3036
                     $quiz_pass_percentage_field = '<input name="quiz_passmark" id="sensei-edit-quiz-pass-percentage" type="number" />';
3037
-                    echo $this->generate_all_lessons_edit_field( __('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field  );
3037
+                    echo $this->generate_all_lessons_edit_field(__('Pass Percentage', 'woothemes-sensei'), $quiz_pass_percentage_field);
3038 3038
 
3039 3039
                     //
3040 3040
                     // Enable quiz reset button
3041 3041
                     //
3042 3042
                     $quiz_reset_select__options = array(
3043 3043
                         '-1' => $no_change_text,
3044
-                        '0' => __('No','woothemes'),
3045
-                        '1' => __('Yes','woothemes'),
3044
+                        '0' => __('No', 'woothemes'),
3045
+                        '1' => __('Yes', 'woothemes'),
3046 3046
                     );
3047 3047
                     $quiz_reset_name_id = 'sensei-edit-enable-quiz-reset';
3048
-                    $quiz_reset_select_attributes = array( 'name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ' );
3049
-                    $quiz_reset_field =  Sensei_Utils::generate_drop_down( '-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false );
3050
-                    echo $this->generate_all_lessons_edit_field( __('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field  );
3048
+                    $quiz_reset_select_attributes = array('name'=> 'enable_quiz_reset', 'id'=>$quiz_reset_name_id, 'class'=>' ');
3049
+                    $quiz_reset_field = Sensei_Utils::generate_drop_down('-1', $quiz_reset_select__options, $quiz_reset_select_attributes, false);
3050
+                    echo $this->generate_all_lessons_edit_field(__('Enable quiz reset button', 'woothemes-sensei'), $quiz_reset_field);
3051 3051
 
3052 3052
                     ?>
3053 3053
             </div>
@@ -3066,17 +3066,17 @@  discard block
 block discarded – undo
3066 3066
      * @param string $field type markup for the field that must be wrapped.
3067 3067
      * @return string $field_html
3068 3068
      */
3069
-    public function generate_all_lessons_edit_field( $title  ,$field ){
3069
+    public function generate_all_lessons_edit_field($title, $field) {
3070 3070
 
3071 3071
         $html = '';
3072 3072
         $html = '<div class="inline-edit-group" >';
3073
-        $html .=  '<span class="title">'. $title .'</span> ';
3073
+        $html .= '<span class="title">'.$title.'</span> ';
3074 3074
         $html .= '<span class="input-text-wrap">';
3075 3075
         $html .= $field;
3076 3076
         $html .= '</span>';
3077 3077
         $html .= '</label></div>';
3078 3078
 
3079
-        return $html ;
3079
+        return $html;
3080 3080
 
3081 3081
     }//end generate_all_lessons_edit_field
3082 3082
 
@@ -3090,48 +3090,48 @@  discard block
 block discarded – undo
3090 3090
     function save_all_lessons_edit_fields() {
3091 3091
 
3092 3092
         // verify all the data before attempting to save
3093
-        if( ! isset( $_POST['security'] ) || ! check_ajax_referer( 'bulk-edit-lessons', 'security' )
3094
-            ||  empty( $_POST[ 'post_ids' ] )  || ! is_array( $_POST[ 'post_ids' ] ) ) {
3093
+        if ( ! isset($_POST['security']) || ! check_ajax_referer('bulk-edit-lessons', 'security')
3094
+            ||  empty($_POST['post_ids']) || ! is_array($_POST['post_ids'])) {
3095 3095
             die();
3096 3096
         }
3097 3097
 
3098 3098
         // get our variables
3099
-        $new_course = sanitize_text_field(  $_POST['sensei_edit_lesson_course'] );
3100
-        $new_complexity = sanitize_text_field(  $_POST['sensei_edit_complexity'] );
3101
-        $new_pass_required = sanitize_text_field(  $_POST['sensei_edit_pass_required'] );
3102
-        $new_pass_percentage = sanitize_text_field(  $_POST['sensei_edit_pass_percentage'] );
3103
-        $new_enable_quiz_reset = sanitize_text_field(  $_POST['sensei_edit_enable_quiz_reset'] );
3099
+        $new_course = sanitize_text_field($_POST['sensei_edit_lesson_course']);
3100
+        $new_complexity = sanitize_text_field($_POST['sensei_edit_complexity']);
3101
+        $new_pass_required = sanitize_text_field($_POST['sensei_edit_pass_required']);
3102
+        $new_pass_percentage = sanitize_text_field($_POST['sensei_edit_pass_percentage']);
3103
+        $new_enable_quiz_reset = sanitize_text_field($_POST['sensei_edit_enable_quiz_reset']);
3104 3104
         // store the values for all selected posts
3105
-        foreach( $_POST[ 'post_ids' ] as $lesson_id ) {
3105
+        foreach ($_POST['post_ids'] as $lesson_id) {
3106 3106
 
3107 3107
             // get the quiz id needed for the quiz meta
3108
-            $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id );
3108
+            $quiz_id = Sensei()->lesson->lesson_quizzes($lesson_id);
3109 3109
 
3110 3110
             // do not save the items if the value is -1 as this
3111 3111
             // means it was not changed
3112 3112
 
3113 3113
             // update lesson course
3114
-            if( -1 != $new_course ){
3115
-                update_post_meta( $lesson_id, '_lesson_course', $new_course );
3114
+            if ( -1 != $new_course ) {
3115
+                update_post_meta($lesson_id, '_lesson_course', $new_course);
3116 3116
             }
3117 3117
             // update lesson complexity
3118
-            if( -1 != $new_complexity ){
3119
-                update_post_meta( $lesson_id, '_lesson_complexity', $new_complexity );
3118
+            if ( -1 != $new_complexity ) {
3119
+                update_post_meta($lesson_id, '_lesson_complexity', $new_complexity);
3120 3120
             }
3121 3121
 
3122 3122
             // Quiz Related settings
3123
-            if( isset( $quiz_id) && 0 < intval( $quiz_id ) ) {
3123
+            if (isset($quiz_id) && 0 < intval($quiz_id)) {
3124 3124
 
3125 3125
                 // update pass required
3126 3126
                 if (-1 != $new_pass_required) {
3127 3127
 
3128
-                    $checked = $new_pass_required  ? 'on' : '';
3128
+                    $checked = $new_pass_required ? 'on' : '';
3129 3129
                     update_post_meta($quiz_id, '_pass_required', $checked);
3130
-                    unset( $checked );
3130
+                    unset($checked);
3131 3131
                 }
3132 3132
 
3133 3133
                 // update pass percentage
3134
-                if( !empty( $new_pass_percentage) && is_numeric( $new_pass_percentage ) ){
3134
+                if ( ! empty($new_pass_percentage) && is_numeric($new_pass_percentage)) {
3135 3135
 
3136 3136
                         update_post_meta($quiz_id, '_quiz_passmark', $new_pass_percentage);
3137 3137
 
@@ -3142,9 +3142,9 @@  discard block
 block discarded – undo
3142 3142
                 //
3143 3143
                 if (-1 != $new_enable_quiz_reset ) {
3144 3144
 
3145
-                    $checked = $new_enable_quiz_reset ? 'on' : ''  ;
3145
+                    $checked = $new_enable_quiz_reset ? 'on' : '';
3146 3146
                     update_post_meta($quiz_id, '_enable_quiz_reset', $checked);
3147
-                    unset( $checked );
3147
+                    unset($checked);
3148 3148
 
3149 3149
                 }
3150 3150
 
@@ -3168,31 +3168,31 @@  discard block
 block discarded – undo
3168 3168
      * @since 1.8.0
3169 3169
      * @return void
3170 3170
      */
3171
-    public function set_quick_edit_admin_defaults( $column_name, $post_id ){
3171
+    public function set_quick_edit_admin_defaults($column_name, $post_id) {
3172 3172
 
3173
-        if( 'lesson-course' != $column_name ){
3173
+        if ('lesson-course' != $column_name) {
3174 3174
             return;
3175 3175
         }
3176 3176
         // load the script
3177
-        $suffix = defined( 'SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3178
-        wp_enqueue_script( 'sensei-lesson-quick-edit', Sensei()->plugin_url . 'assets/js/admin/lesson-quick-edit' . $suffix . '.js', array( 'jquery' ), Sensei()->version, true );
3177
+        $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min';
3178
+        wp_enqueue_script('sensei-lesson-quick-edit', Sensei()->plugin_url.'assets/js/admin/lesson-quick-edit'.$suffix.'.js', array('jquery'), Sensei()->version, true);
3179 3179
 
3180 3180
         // setup the values for all meta fields
3181 3181
         $data = array();
3182
-        foreach( $this->meta_fields as $field ){
3182
+        foreach ($this->meta_fields as $field) {
3183 3183
 
3184
-            $data[$field] =  get_post_meta( $post_id, '_'.$field, true );
3184
+            $data[$field] = get_post_meta($post_id, '_'.$field, true);
3185 3185
 
3186 3186
         }
3187 3187
         // add quiz meta fields
3188
-        $quiz_id = Sensei()->lesson->lesson_quizzes( $post_id );
3189
-        foreach( Sensei()->quiz->meta_fields as $field ){
3188
+        $quiz_id = Sensei()->lesson->lesson_quizzes($post_id);
3189
+        foreach (Sensei()->quiz->meta_fields as $field) {
3190 3190
 
3191
-            $data[$field] =  get_post_meta( $quiz_id, '_'.$field, true );
3191
+            $data[$field] = get_post_meta($quiz_id, '_'.$field, true);
3192 3192
 
3193 3193
         }
3194 3194
 
3195
-        wp_localize_script( 'sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data );
3195
+        wp_localize_script('sensei-lesson-quick-edit', 'sensei_quick_edit_'.$post_id, $data);
3196 3196
 
3197 3197
     }// end quick edit admin defaults
3198 3198
 
@@ -3205,19 +3205,19 @@  discard block
 block discarded – undo
3205 3205
      * @param array $classes
3206 3206
      * @return array $classes
3207 3207
      */
3208
-    public static function single_course_lessons_classes( $classes ){
3208
+    public static function single_course_lessons_classes($classes) {
3209 3209
 
3210
-        if(  is_singular('course') ){
3210
+        if (is_singular('course')) {
3211 3211
 
3212 3212
             global $post;
3213 3213
             $course_id = $post->ID;
3214 3214
 
3215
-            $lesson_classes = array( 'course', 'post' );
3216
-            if ( is_user_logged_in() ) {
3215
+            $lesson_classes = array('course', 'post');
3216
+            if (is_user_logged_in()) {
3217 3217
 
3218 3218
                 // Check if Lesson is complete
3219
-                $single_lesson_complete = Sensei_Utils::user_completed_lesson( get_the_ID(), get_current_user_id() );
3220
-                if ( $single_lesson_complete ) {
3219
+                $single_lesson_complete = Sensei_Utils::user_completed_lesson(get_the_ID(), get_current_user_id());
3220
+                if ($single_lesson_complete) {
3221 3221
 
3222 3222
                     $lesson_classes[] = 'lesson-completed';
3223 3223
 
@@ -3225,14 +3225,14 @@  discard block
 block discarded – undo
3225 3225
 
3226 3226
             } // End If Statement
3227 3227
 
3228
-            $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3229
-            if (  Sensei_Utils::is_preview_lesson( get_the_ID() ) && !$is_user_taking_course ) {
3228
+            $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
3229
+            if (Sensei_Utils::is_preview_lesson(get_the_ID()) && ! $is_user_taking_course) {
3230 3230
 
3231 3231
                 $lesson_classes[] = 'lesson-preview';
3232 3232
 
3233 3233
             }
3234 3234
 
3235
-            $classes = array_merge( $classes, $lesson_classes  );
3235
+            $classes = array_merge($classes, $lesson_classes);
3236 3236
 
3237 3237
         }
3238 3238
 
@@ -3246,56 +3246,56 @@  discard block
 block discarded – undo
3246 3246
      * @since 1.9.0
3247 3247
      * @param $lesson_id
3248 3248
      */
3249
-    public static function the_lesson_meta( $lesson_id ){
3249
+    public static function the_lesson_meta($lesson_id) {
3250 3250
 
3251 3251
         global $wp_query;
3252 3252
         $loop_lesson_number = $wp_query->current_post + 1;
3253 3253
 
3254
-        $course_id = Sensei()->lesson->get_course_id( $lesson_id );
3254
+        $course_id = Sensei()->lesson->get_course_id($lesson_id);
3255 3255
         $single_lesson_complete = false;
3256
-        $is_user_taking_course = Sensei_Utils::user_started_course( $course_id, get_current_user_id() );
3256
+        $is_user_taking_course = Sensei_Utils::user_started_course($course_id, get_current_user_id());
3257 3257
 
3258 3258
         // Get Lesson data
3259 3259
         $complexity_array = Sensei()->lesson->lesson_complexities();
3260 3260
 
3261
-        $lesson_complexity = get_post_meta( $lesson_id, '_lesson_complexity', true );
3262
-        if ( '' != $lesson_complexity ) {
3261
+        $lesson_complexity = get_post_meta($lesson_id, '_lesson_complexity', true);
3262
+        if ('' != $lesson_complexity) {
3263 3263
 
3264 3264
             $lesson_complexity = $complexity_array[$lesson_complexity];
3265 3265
 
3266 3266
         }
3267
-        $user_info = get_userdata( absint( get_post()->post_author ) );
3268
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id);
3267
+        $user_info = get_userdata(absint(get_post()->post_author));
3268
+        $is_preview = Sensei_Utils::is_preview_lesson($lesson_id);
3269 3269
         $preview_label = '';
3270
-        if ( $is_preview && !$is_user_taking_course ) {
3270
+        if ($is_preview && ! $is_user_taking_course) {
3271 3271
 
3272
-            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text( $lesson_id);
3273
-            $preview_label = '<span class="preview-heading">' . $preview_label . '</span>';
3272
+            $preview_label = Sensei()->frontend->sensei_lesson_preview_title_text($lesson_id);
3273
+            $preview_label = '<span class="preview-heading">'.$preview_label.'</span>';
3274 3274
 
3275 3275
         }
3276 3276
 
3277 3277
 
3278
-        $count_markup= '';
3278
+        $count_markup = '';
3279 3279
         /**
3280 3280
          * Filter for if you want the $lesson_count to show next to the lesson.
3281 3281
          *
3282 3282
          * @since 1.0
3283 3283
          * @param bool default false.
3284 3284
          */
3285
-        if( apply_filters( 'sensei_show_lesson_numbers', false ) ) {
3285
+        if (apply_filters('sensei_show_lesson_numbers', false)) {
3286 3286
 
3287
-            $count_markup =  '<span class="lesson-number">' . $loop_lesson_number. '</span>';
3287
+            $count_markup = '<span class="lesson-number">'.$loop_lesson_number.'</span>';
3288 3288
 
3289 3289
         }
3290 3290
 
3291
-        $heading_link_title = sprintf( __( 'Start %s', 'woothemes-sensei' ), get_the_title( $lesson_id ) );
3291
+        $heading_link_title = sprintf(__('Start %s', 'woothemes-sensei'), get_the_title($lesson_id));
3292 3292
 
3293 3293
         ?>
3294 3294
         <header>
3295 3295
             <h2>
3296
-                <a href="<?php echo esc_url_raw( get_permalink( $lesson_id ) ) ?>"
3297
-                   title="<?php esc_attr_e( $heading_link_title ) ?>" >
3298
-                    <?php echo $count_markup. get_the_title( $lesson_id ) . $preview_label; ?>
3296
+                <a href="<?php echo esc_url_raw(get_permalink($lesson_id)) ?>"
3297
+                   title="<?php esc_attr_e($heading_link_title) ?>" >
3298
+                    <?php echo $count_markup.get_the_title($lesson_id).$preview_label; ?>
3299 3299
                 </a>
3300 3300
             </h2>
3301 3301
 
@@ -3304,33 +3304,33 @@  discard block
 block discarded – undo
3304 3304
                 <?php
3305 3305
 
3306 3306
                 $meta_html = '';
3307
-                $user_lesson_status = Sensei_Utils::user_lesson_status( get_the_ID(), get_current_user_id() );
3307
+                $user_lesson_status = Sensei_Utils::user_lesson_status(get_the_ID(), get_current_user_id());
3308 3308
 
3309
-                $lesson_length = get_post_meta( $lesson_id, '_lesson_length', true );
3310
-                if ( '' != $lesson_length ) {
3309
+                $lesson_length = get_post_meta($lesson_id, '_lesson_length', true);
3310
+                if ('' != $lesson_length) {
3311 3311
 
3312
-                    $meta_html .= '<span class="lesson-length">' .  __( 'Length: ', 'woothemes-sensei' ) . $lesson_length . __( ' minutes', 'woothemes-sensei' ) . '</span>';
3312
+                    $meta_html .= '<span class="lesson-length">'.__('Length: ', 'woothemes-sensei').$lesson_length.__(' minutes', 'woothemes-sensei').'</span>';
3313 3313
 
3314 3314
                 }
3315 3315
 
3316
-                if ( Sensei()->settings->get( 'lesson_author' ) ) {
3316
+                if (Sensei()->settings->get('lesson_author')) {
3317 3317
 
3318
-                    $meta_html .= '<span class="lesson-author">' .  __( 'Author: ', 'woothemes-sensei' ) . '<a href="' . get_author_posts_url( absint( get_post()->post_author ) ) . '" title="' . esc_attr( $user_info->display_name ) . '">' . esc_html( $user_info->display_name ) . '</a></span>';
3318
+                    $meta_html .= '<span class="lesson-author">'.__('Author: ', 'woothemes-sensei').'<a href="'.get_author_posts_url(absint(get_post()->post_author)).'" title="'.esc_attr($user_info->display_name).'">'.esc_html($user_info->display_name).'</a></span>';
3319 3319
 
3320 3320
                 } // End If Statement
3321
-                if ( '' != $lesson_complexity ) {
3321
+                if ('' != $lesson_complexity) {
3322 3322
 
3323
-                    $meta_html .= '<span class="lesson-complexity">' .  __( 'Complexity: ', 'woothemes-sensei' ) . $lesson_complexity .'</span>';
3323
+                    $meta_html .= '<span class="lesson-complexity">'.__('Complexity: ', 'woothemes-sensei').$lesson_complexity.'</span>';
3324 3324
 
3325 3325
                 }
3326 3326
 
3327
-                if ( $single_lesson_complete ) {
3327
+                if ($single_lesson_complete) {
3328 3328
 
3329
-                    $meta_html .= '<span class="lesson-status complete">' .__( 'Complete', 'woothemes-sensei' ) .'</span>';
3329
+                    $meta_html .= '<span class="lesson-status complete">'.__('Complete', 'woothemes-sensei').'</span>';
3330 3330
 
3331
-                } elseif ( $user_lesson_status ) {
3331
+                } elseif ($user_lesson_status) {
3332 3332
 
3333
-                    $meta_html .= '<span class="lesson-status in-progress">' . __( 'In Progress', 'woothemes-sensei' ) .'</span>';
3333
+                    $meta_html .= '<span class="lesson-status in-progress">'.__('In Progress', 'woothemes-sensei').'</span>';
3334 3334
 
3335 3335
                 } // End If Statement
3336 3336
 
@@ -3353,19 +3353,19 @@  discard block
 block discarded – undo
3353 3353
      *
3354 3354
      * @param $lesson_id
3355 3355
      */
3356
-    public static function the_lesson_thumbnail( $lesson_id ){
3356
+    public static function the_lesson_thumbnail($lesson_id) {
3357 3357
 
3358
-        if( empty( $lesson_id ) ){
3358
+        if (empty($lesson_id)) {
3359 3359
 
3360 3360
             $lesson_id = get_the_ID();
3361 3361
 
3362 3362
         }
3363 3363
 
3364
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3364
+        if ('lesson' != get_post_type($lesson_id)) {
3365 3365
             return;
3366 3366
         }
3367 3367
 
3368
-        echo Sensei()->lesson->lesson_image( $lesson_id );
3368
+        echo Sensei()->lesson->lesson_image($lesson_id);
3369 3369
     }
3370 3370
 
3371 3371
 
@@ -3376,14 +3376,14 @@  discard block
 block discarded – undo
3376 3376
      * @param string $excerpt
3377 3377
      * @return string $excerpt
3378 3378
      */
3379
-    public static function alter_the_lesson_excerpt( $excerpt ) {
3379
+    public static function alter_the_lesson_excerpt($excerpt) {
3380 3380
 
3381
-        if ('lesson' == get_post_type(get_the_ID())){
3381
+        if ('lesson' == get_post_type(get_the_ID())) {
3382 3382
 
3383 3383
             // remove this hooks to avoid an infinite loop.
3384
-            remove_filter( 'get_the_excerpt', array( 'WooThemes_Sensei_Lesson','alter_the_lesson_excerpt') );
3384
+            remove_filter('get_the_excerpt', array('WooThemes_Sensei_Lesson', 'alter_the_lesson_excerpt'));
3385 3385
 
3386
-            return WooThemes_Sensei_Lesson::lesson_excerpt( get_post( get_the_ID() ) );
3386
+            return WooThemes_Sensei_Lesson::lesson_excerpt(get_post(get_the_ID()));
3387 3387
         }
3388 3388
 
3389 3389
         return $excerpt;
@@ -3398,20 +3398,20 @@  discard block
 block discarded – undo
3398 3398
      * @param $current_lesson_id
3399 3399
      * @return mixed | bool | int $prerequisite_lesson_id or false
3400 3400
      */
3401
-    public static function get_lesson_prerequisite_id( $current_lesson_id  ){
3401
+    public static function get_lesson_prerequisite_id($current_lesson_id) {
3402 3402
 
3403
-        $prerequisite_lesson_id = get_post_meta( $current_lesson_id , '_lesson_prerequisite', true );
3403
+        $prerequisite_lesson_id = get_post_meta($current_lesson_id, '_lesson_prerequisite', true);
3404 3404
 
3405 3405
         // set ti to false if not a valid prerequisite lesson id
3406
-        if(  empty( $prerequisite_lesson_id )
3407
-            || 'lesson' != get_post_type( $prerequisite_lesson_id )
3408
-            || $prerequisite_lesson_id == $current_lesson_id  ) {
3406
+        if (empty($prerequisite_lesson_id)
3407
+            || 'lesson' != get_post_type($prerequisite_lesson_id)
3408
+            || $prerequisite_lesson_id == $current_lesson_id) {
3409 3409
 
3410 3410
             $prerequisite_lesson_id = false;
3411 3411
 
3412 3412
         }
3413 3413
 
3414
-        return apply_filters( 'sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id );
3414
+        return apply_filters('sensei_lesson_prerequisite', $prerequisite_lesson_id, $current_lesson_id);
3415 3415
 
3416 3416
     }
3417 3417
 
@@ -3426,27 +3426,27 @@  discard block
 block discarded – undo
3426 3426
      * @param $user_id
3427 3427
      * @return bool
3428 3428
      */
3429
-    public  static function is_prerequisite_complete( $lesson_id, $user_id  ){
3429
+    public  static function is_prerequisite_complete($lesson_id, $user_id) {
3430 3430
 
3431
-        if( empty( $lesson_id ) || empty( $user_id )
3432
-        || 'lesson' != get_post_type( $lesson_id )
3433
-        ||  ! is_a( get_user_by( 'id', $user_id ), 'WP_User' )){
3431
+        if (empty($lesson_id) || empty($user_id)
3432
+        || 'lesson' != get_post_type($lesson_id)
3433
+        ||  ! is_a(get_user_by('id', $user_id), 'WP_User')) {
3434 3434
 
3435 3435
             return false;
3436 3436
 
3437 3437
         }
3438 3438
 
3439
-        $pre_requisite_id = (string) self::get_lesson_prerequisite_id( $lesson_id );
3439
+        $pre_requisite_id = (string) self::get_lesson_prerequisite_id($lesson_id);
3440 3440
 
3441 3441
         // not a valid pre-requisite so pre-requisite is completed
3442
-        if( 'lesson' != get_post_type( $pre_requisite_id )
3443
-            || ! is_numeric( $pre_requisite_id ) ){
3442
+        if ('lesson' != get_post_type($pre_requisite_id)
3443
+            || ! is_numeric($pre_requisite_id)) {
3444 3444
 
3445 3445
             return true;
3446 3446
 
3447 3447
         }
3448 3448
 
3449
-        return  Sensei_Utils::user_completed_lesson( $pre_requisite_id, $user_id );
3449
+        return  Sensei_Utils::user_completed_lesson($pre_requisite_id, $user_id);
3450 3450
 
3451 3451
     }// end is_prerequisite_complete
3452 3452
 
@@ -3455,20 +3455,20 @@  discard block
 block discarded – undo
3455 3455
      *
3456 3456
      * @since 1.9.0
3457 3457
      */
3458
-    public  static function user_not_taking_course_message(){
3458
+    public  static function user_not_taking_course_message() {
3459 3459
 
3460 3460
         $lesson_id = get_the_ID();
3461 3461
 
3462
-        if( 'lesson' != get_post_type( $lesson_id ) ){
3462
+        if ('lesson' != get_post_type($lesson_id)) {
3463 3463
             return;
3464 3464
         }
3465 3465
 
3466
-        $is_preview = Sensei_Utils::is_preview_lesson( $lesson_id );
3467
-        $pre_requisite_complete = self::is_prerequisite_complete( $lesson_id , get_current_user_id() );
3468
-        $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true );
3469
-        $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id() );
3466
+        $is_preview = Sensei_Utils::is_preview_lesson($lesson_id);
3467
+        $pre_requisite_complete = self::is_prerequisite_complete($lesson_id, get_current_user_id());
3468
+        $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true);
3469
+        $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id());
3470 3470
 
3471
-        if ( $pre_requisite_complete && $is_preview && !$user_taking_course ) {
3471
+        if ($pre_requisite_complete && $is_preview && ! $user_taking_course) {
3472 3472
             ?>
3473 3473
 
3474 3474
             <div class="sensei-message alert">
@@ -3488,11 +3488,11 @@  discard block
 block discarded – undo
3488 3488
      *
3489 3489
      * @since 1.9.0
3490 3490
      */
3491
-    public static function course_signup_link( ){
3491
+    public static function course_signup_link( ) {
3492 3492
 
3493
-        $course_id =  Sensei()->lesson->get_course_id( get_the_ID() );
3493
+        $course_id = Sensei()->lesson->get_course_id(get_the_ID());
3494 3494
 
3495
-        if ( empty( $course_id ) || 'course' != get_post_type( $course_id ) || sensei_all_access() ) {
3495
+        if (empty($course_id) || 'course' != get_post_type($course_id) || sensei_all_access()) {
3496 3496
 
3497 3497
             return;
3498 3498
 
@@ -3502,24 +3502,24 @@  discard block
 block discarded – undo
3502 3502
         <section class="course-signup lesson-meta">
3503 3503
 
3504 3504
             <?php
3505
-            $wc_post_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true );
3505
+            $wc_post_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true);
3506 3506
 
3507
-            if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) {
3507
+            if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) {
3508 3508
 
3509 3509
                 global $current_user;
3510
-                if( is_user_logged_in() ) {
3510
+                if (is_user_logged_in()) {
3511 3511
                     wp_get_current_user();
3512 3512
 
3513
-                    $course_purchased = Sensei_Utils::sensei_customer_bought_product( $current_user->user_email, $current_user->ID, $wc_post_id );
3513
+                    $course_purchased = Sensei_Utils::sensei_customer_bought_product($current_user->user_email, $current_user->ID, $wc_post_id);
3514 3514
 
3515
-                    if( $course_purchased ) {
3515
+                    if ($course_purchased) {
3516 3516
 
3517
-                        $prereq_course_id = get_post_meta( $course_id, '_course_prerequisite',true );
3518
-                        $course_link = '<a href="' . esc_url( get_permalink( $prereq_course_id ) ) . '" title="' . esc_attr( get_the_title( $prereq_course_id ) ) . '">' . __( 'the previous course', 'woothemes-sensei' )  . '</a>';
3517
+                        $prereq_course_id = get_post_meta($course_id, '_course_prerequisite', true);
3518
+                        $course_link = '<a href="'.esc_url(get_permalink($prereq_course_id)).'" title="'.esc_attr(get_the_title($prereq_course_id)).'">'.__('the previous course', 'woothemes-sensei').'</a>';
3519 3519
                         ?>
3520 3520
                             <div class="sensei-message info">
3521 3521
 
3522
-                                <?php  echo sprintf( __( 'Please complete %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); ?>
3522
+                                <?php  echo sprintf(__('Please complete %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); ?>
3523 3523
 
3524 3524
                             </div>
3525 3525
 
@@ -3528,12 +3528,12 @@  discard block
 block discarded – undo
3528 3528
                         <div class="sensei-message info">
3529 3529
 
3530 3530
                             <?php
3531
-                            $course_link = '<a href="' . esc_url( get_permalink( $course_id ) )
3532
-                                            . '"title="' . __( 'Sign Up', 'woothemes-sensei' )
3533
-                                            . '">' . __( 'course', 'woothemes-sensei' )
3531
+                            $course_link = '<a href="'.esc_url(get_permalink($course_id))
3532
+                                            . '"title="'.__('Sign Up', 'woothemes-sensei')
3533
+                                            . '">'.__('course', 'woothemes-sensei')
3534 3534
                                             . '</a>';
3535 3535
 
3536
-                            echo  sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link );
3536
+                            echo  sprintf(__('Please purchase the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
3537 3537
 
3538 3538
                             ?>
3539 3539
 
@@ -3542,23 +3542,23 @@  discard block
 block discarded – undo
3542 3542
 
3543 3543
                 <?php } else { ?>
3544 3544
 
3545
-                    <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>
3545
+                    <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>
3546 3546
 
3547 3547
                 <?php } ?>
3548 3548
 
3549 3549
             <?php } else { ?>
3550 3550
 
3551
-            <?php if( ! Sensei_Utils::user_started_course( $course_id, get_current_user_id() ) &&  sensei_is_login_required() )  : ?>
3551
+            <?php if ( ! Sensei_Utils::user_started_course($course_id, get_current_user_id()) && sensei_is_login_required())  : ?>
3552 3552
 
3553 3553
                 <div class="sensei-message info">
3554 3554
                     <?php
3555
-                    $course_link =  '<a href="'
3556
-                                        . esc_url( get_permalink( $course_id ) )
3557
-                                        . '" title="' . __( 'Sign Up', 'woothemes-sensei' )
3558
-                                        . '">' . __( 'course', 'woothemes-sensei' )
3555
+                    $course_link = '<a href="'
3556
+                                        . esc_url(get_permalink($course_id))
3557
+                                        . '" title="'.__('Sign Up', 'woothemes-sensei')
3558
+                                        . '">'.__('course', 'woothemes-sensei')
3559 3559
                                     . '</a>';
3560 3560
 
3561
-                    echo sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ),  $course_link );
3561
+                    echo sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link);
3562 3562
                     ?>
3563 3563
                 </div>
3564 3564
 
@@ -3576,14 +3576,14 @@  discard block
 block discarded – undo
3576 3576
      *
3577 3577
      * @since 1.9.0
3578 3578
      */
3579
-    public  static function prerequisite_complete_message(){
3579
+    public  static function prerequisite_complete_message() {
3580 3580
 
3581
-        $lesson_prerequisite =  WooThemes_Sensei_Lesson::get_lesson_prerequisite_id( get_the_ID() );
3581
+        $lesson_prerequisite = WooThemes_Sensei_Lesson::get_lesson_prerequisite_id(get_the_ID());
3582 3582
         $lesson_has_pre_requisite = $lesson_prerequisite > 0;
3583
-        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(  get_the_ID(), get_current_user_id() ) && $lesson_has_pre_requisite ) {
3583
+        if ( ! WooThemes_Sensei_Lesson::is_prerequisite_complete(get_the_ID(), get_current_user_id()) && $lesson_has_pre_requisite) {
3584 3584
 
3585
-            $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>';
3586
-            echo sprintf( __( 'You must first complete %1$s before viewing this Lesson', 'woothemes-sensei' ), $prerequisite_lesson_link );
3585
+            $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>';
3586
+            echo sprintf(__('You must first complete %1$s before viewing this Lesson', 'woothemes-sensei'), $prerequisite_lesson_link);
3587 3587
 
3588 3588
         }
3589 3589
 
@@ -3595,7 +3595,7 @@  discard block
 block discarded – undo
3595 3595
      *
3596 3596
      * @deprecated since 1.9.0
3597 3597
      */
3598
-    public static function deprecate_sensei_lesson_archive_header_hook(){
3598
+    public static function deprecate_sensei_lesson_archive_header_hook() {
3599 3599
 
3600 3600
         sensei_do_deprecated_action('sensei_lesson_archive_header', '1.9.0', 'sensei_loop_lesson_inside_before');
3601 3601
 
@@ -3611,9 +3611,9 @@  discard block
 block discarded – undo
3611 3611
 
3612 3612
         $before_html = '<header class="archive-header"><h1>';
3613 3613
         $after_html = '</h1></header>';
3614
-        $html = $before_html .  __( 'Lessons Archive', 'woothemes-sensei' ) . $after_html;
3614
+        $html = $before_html.__('Lessons Archive', 'woothemes-sensei').$after_html;
3615 3615
 
3616
-        echo apply_filters( 'sensei_lesson_archive_title', $html );
3616
+        echo apply_filters('sensei_lesson_archive_title', $html);
3617 3617
 
3618 3618
     } // sensei_course_archive_header()
3619 3619
 
@@ -3623,7 +3623,7 @@  discard block
 block discarded – undo
3623 3623
      * @global $post
3624 3624
      * @since 1.9.0
3625 3625
      */
3626
-    public static function the_title(){
3626
+    public static function the_title() {
3627 3627
 
3628 3628
         global $post;
3629 3629
 
@@ -3636,7 +3636,7 @@  discard block
 block discarded – undo
3636 3636
                 /**
3637 3637
                  * Filter documented in class-sensei-messages.php the_title
3638 3638
                  */
3639
-                echo apply_filters( 'sensei_single_title', get_the_title( $post ), $post->post_type );
3639
+                echo apply_filters('sensei_single_title', get_the_title($post), $post->post_type);
3640 3640
                 ?>
3641 3641
 
3642 3642
             </h1>
@@ -3654,16 +3654,16 @@  discard block
 block discarded – undo
3654 3654
      *
3655 3655
      * @param $post_id
3656 3656
      */
3657
-    public static function flush_rewrite_rules( $post_id ){
3657
+    public static function flush_rewrite_rules($post_id) {
3658 3658
 
3659
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE){
3659
+        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
3660 3660
 
3661 3661
             return;
3662 3662
 
3663 3663
         }
3664 3664
 
3665 3665
 
3666
-        if( 'lesson' == get_post_type( $post_id )  ){
3666
+        if ('lesson' == get_post_type($post_id)) {
3667 3667
 
3668 3668
             Sensei()->initiate_rewrite_rules_flush();
3669 3669
 
@@ -3680,21 +3680,21 @@  discard block
 block discarded – undo
3680 3680
      * @param int $lesson_id
3681 3681
      * @param int $user_id
3682 3682
      */
3683
-    public static function footer_quiz_call_to_action( $lesson_id = 0, $user_id = 0 ) {
3683
+    public static function footer_quiz_call_to_action($lesson_id = 0, $user_id = 0) {
3684 3684
 
3685 3685
 
3686
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3687
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3688
-        $lesson_prerequisite       = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true );
3689
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3690
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3691
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3686
+        $lesson_id                 = empty($lesson_id) ? get_the_ID() : $lesson_id;
3687
+        $user_id                   = empty($lesson_id) ? get_current_user_id() : $user_id;
3688
+        $lesson_prerequisite       = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true);
3689
+        $lesson_course_id          = (int) get_post_meta($lesson_id, '_lesson_course', true);
3690
+        $quiz_id                   = Sensei()->lesson->lesson_quizzes($lesson_id);
3691
+        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id);
3692 3692
         $show_actions              = is_user_logged_in() ? true : false;
3693 3693
 
3694
-        if( intval( $lesson_prerequisite ) > 0 ) {
3694
+        if (intval($lesson_prerequisite) > 0) {
3695 3695
 
3696 3696
             // If the user hasn't completed the prereq then hide the current actions
3697
-            $show_actions = Sensei_Utils::user_completed_lesson( $lesson_prerequisite, $user_id );
3697
+            $show_actions = Sensei_Utils::user_completed_lesson($lesson_prerequisite, $user_id);
3698 3698
 
3699 3699
         }
3700 3700
         ?>
@@ -3702,19 +3702,19 @@  discard block
 block discarded – undo
3702 3702
         <footer>
3703 3703
 
3704 3704
             <?php
3705
-            if( $show_actions && $quiz_id && Sensei()->access_settings() ) {
3705
+            if ($show_actions && $quiz_id && Sensei()->access_settings()) {
3706 3706
 
3707
-                $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3708
-                if( $has_quiz_questions ) {
3707
+                $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
3708
+                if ($has_quiz_questions) {
3709 3709
                     ?>
3710 3710
 
3711 3711
                     <p>
3712 3712
 
3713 3713
                         <a class="button"
3714
-                           href="<?php echo esc_url_raw( get_permalink( $quiz_id ) ); ?>"
3715
-                           title="<?php _e( 'View the Lesson Quiz', 'woothemes-sensei'  ); ?>">
3714
+                           href="<?php echo esc_url_raw(get_permalink($quiz_id)); ?>"
3715
+                           title="<?php _e('View the Lesson Quiz', 'woothemes-sensei'); ?>">
3716 3716
 
3717
-                            <?php  _e( 'View the Lesson Quiz', 'woothemes-sensei' ); ?>
3717
+                            <?php  _e('View the Lesson Quiz', 'woothemes-sensei'); ?>
3718 3718
 
3719 3719
                         </a>
3720 3720
 
@@ -3725,11 +3725,11 @@  discard block
 block discarded – undo
3725 3725
 
3726 3726
             } // End If Statement
3727 3727
 
3728
-            if ( $show_actions && ! $has_user_completed_lesson ) {
3728
+            if ($show_actions && ! $has_user_completed_lesson) {
3729 3729
 
3730 3730
                 sensei_complete_lesson_button();
3731 3731
 
3732
-            } elseif( $show_actions ) {
3732
+            } elseif ($show_actions) {
3733 3733
 
3734 3734
                 sensei_reset_lesson_button();
3735 3735
 
@@ -3746,20 +3746,20 @@  discard block
 block discarded – undo
3746 3746
      *
3747 3747
      * @since 1.9.0
3748 3748
      */
3749
-    public static function output_comments(){
3749
+    public static function output_comments() {
3750 3750
 
3751
-        if( ! is_user_logged_in() ){
3751
+        if ( ! is_user_logged_in()) {
3752 3752
             return;
3753 3753
         }
3754 3754
 
3755
-        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete( get_the_ID(), get_current_user_id() );
3756
-        $course_id = Sensei()->lesson->get_course_id( get_the_ID() );
3757
-        $allow_comments = Sensei()->settings->settings[ 'lesson_comments' ];
3758
-        $user_taking_course = Sensei_Utils::user_started_course($course_id );
3755
+        $pre_requisite_complete = Sensei()->lesson->is_prerequisite_complete(get_the_ID(), get_current_user_id());
3756
+        $course_id = Sensei()->lesson->get_course_id(get_the_ID());
3757
+        $allow_comments = Sensei()->settings->settings['lesson_comments'];
3758
+        $user_taking_course = Sensei_Utils::user_started_course($course_id);
3759 3759
 
3760
-        $lesson_allow_comments = $allow_comments && $pre_requisite_complete  && $user_taking_course;
3760
+        $lesson_allow_comments = $allow_comments && $pre_requisite_complete && $user_taking_course;
3761 3761
 
3762
-        if (  $lesson_allow_comments || is_singular( 'sensei_message' ) ) {
3762
+        if ($lesson_allow_comments || is_singular('sensei_message')) {
3763 3763
 
3764 3764
             comments_template();
3765 3765
 
@@ -3775,26 +3775,26 @@  discard block
 block discarded – undo
3775 3775
      *
3776 3776
      * @since 1.9.0
3777 3777
      */
3778
-    public static function user_lesson_quiz_status_message( $lesson_id = 0, $user_id = 0){
3778
+    public static function user_lesson_quiz_status_message($lesson_id = 0, $user_id = 0) {
3779 3779
 
3780
-        $lesson_id                 =  empty( $lesson_id ) ?  get_the_ID() : $lesson_id;
3781
-        $user_id                   = empty( $lesson_id ) ?  get_current_user_id() : $user_id;
3782
-        $lesson_course_id          = (int) get_post_meta( $lesson_id, '_lesson_course', true );
3783
-        $quiz_id                   = Sensei()->lesson->lesson_quizzes( $lesson_id );
3784
-        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson( intval( $lesson_id ), $user_id );
3780
+        $lesson_id                 = empty($lesson_id) ? get_the_ID() : $lesson_id;
3781
+        $user_id                   = empty($lesson_id) ? get_current_user_id() : $user_id;
3782
+        $lesson_course_id          = (int) get_post_meta($lesson_id, '_lesson_course', true);
3783
+        $quiz_id                   = Sensei()->lesson->lesson_quizzes($lesson_id);
3784
+        $has_user_completed_lesson = Sensei_Utils::user_completed_lesson(intval($lesson_id), $user_id);
3785 3785
 
3786 3786
 
3787
-        if ( $quiz_id && is_user_logged_in()
3788
-            && Sensei_Utils::user_started_course( $lesson_course_id, $user_id ) ) {
3787
+        if ($quiz_id && is_user_logged_in()
3788
+            && Sensei_Utils::user_started_course($lesson_course_id, $user_id)) {
3789 3789
 
3790 3790
             $no_quiz_count = 0;
3791
-            $has_quiz_questions = get_post_meta( $lesson_id, '_quiz_has_questions', true );
3791
+            $has_quiz_questions = get_post_meta($lesson_id, '_quiz_has_questions', true);
3792 3792
 
3793 3793
             // Display lesson quiz status message
3794
-            if ( $has_user_completed_lesson || $has_quiz_questions ) {
3795
-                $status = Sensei_Utils::sensei_user_quiz_status_message( $lesson_id, $user_id, true );
3796
-                echo '<div class="sensei-message ' . $status['box_class'] . '">' . $status['message'] . '</div>';
3797
-                if( $has_quiz_questions ) {
3794
+            if ($has_user_completed_lesson || $has_quiz_questions) {
3795
+                $status = Sensei_Utils::sensei_user_quiz_status_message($lesson_id, $user_id, true);
3796
+                echo '<div class="sensei-message '.$status['box_class'].'">'.$status['message'].'</div>';
3797
+                if ($has_quiz_questions) {
3798 3798
                    // echo $status['extra'];
3799 3799
                 } // End If Statement
3800 3800
             } // End If Statement
@@ -3810,4 +3810,4 @@  discard block
 block discarded – undo
3810 3810
  * @ignore only for backward compatibility
3811 3811
  * @since 1.9.0
3812 3812
  */
3813
-class WooThemes_Sensei_Lesson extends Sensei_Lesson{}
3813
+class WooThemes_Sensei_Lesson extends Sensei_Lesson {}
Please login to merge, or discard this patch.
includes/class-sensei-analysis-user-profile-list-table.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -201,7 +201,7 @@
 block discarded – undo
201 201
 
202 202
 		if( 'complete' == $item->comment_approved ) {
203 203
 
204
-            $status =  __( 'Completed', 'woothemes-sensei' );
204
+			$status =  __( 'Completed', 'woothemes-sensei' );
205 205
 			$status_class = 'graded';
206 206
 
207 207
 			$course_end_date = $item->comment_date;
Please login to merge, or discard this patch.
Braces   +4 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,8 @@
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined( 'ABSPATH' ) ) {
3
+	exit;
4
+}
5
+// Exit if accessed directly
3 6
 
4 7
 /**
5 8
  * Sensei Analysis User Profile List Table Class
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
2
+if ( ! defined('ABSPATH')) exit; // Exit if accessed directly
3 3
 
4 4
 /**
5 5
  * Analysis User Profile Data Table in Sensei.
@@ -18,17 +18,17 @@  discard block
 block discarded – undo
18 18
 	 * @since  1.2.0
19 19
 	 * @return  void
20 20
 	 */
21
-	public function __construct ( $user_id = 0 ) {
22
-		$this->user_id = intval( $user_id );
21
+	public function __construct($user_id = 0) {
22
+		$this->user_id = intval($user_id);
23 23
 
24 24
 		// Load Parent token into constructor
25
-		parent::__construct( 'analysis_user_profile' );
25
+		parent::__construct('analysis_user_profile');
26 26
 
27 27
 		// Actions
28
-		add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) );
29
-		add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) );
28
+		add_action('sensei_before_list_table', array($this, 'data_table_header'));
29
+		add_action('sensei_after_list_table', array($this, 'data_table_footer'));
30 30
 
31
-		add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) );
31
+		add_filter('sensei_list_table_search_button_text', array($this, 'search_button'));
32 32
 	} // End __construct()
33 33
 
34 34
 	/**
@@ -38,14 +38,14 @@  discard block
 block discarded – undo
38 38
 	 */
39 39
 	function get_columns() {
40 40
 		$columns = array(
41
-			'title' => __( 'Course', 'woothemes-sensei' ),
42
-			'started' => __( 'Date Started', 'woothemes-sensei' ),
43
-			'completed' => __( 'Date Completed', 'woothemes-sensei' ),
44
-			'status' => __( 'Status', 'woothemes-sensei' ),
41
+			'title' => __('Course', 'woothemes-sensei'),
42
+			'started' => __('Date Started', 'woothemes-sensei'),
43
+			'completed' => __('Date Completed', 'woothemes-sensei'),
44
+			'status' => __('Status', 'woothemes-sensei'),
45 45
 //			'grade' => __( 'Grade', 'woothemes-sensei' ),
46
-			'percent' => __( 'Percent Complete', 'woothemes-sensei' ),
46
+			'percent' => __('Percent Complete', 'woothemes-sensei'),
47 47
 		);
48
-		$columns = apply_filters( 'sensei_analysis_user_profile_columns', $columns );
48
+		$columns = apply_filters('sensei_analysis_user_profile_columns', $columns);
49 49
 		return $columns;
50 50
 	}
51 51
 
@@ -56,14 +56,14 @@  discard block
 block discarded – undo
56 56
 	 */
57 57
 	function get_sortable_columns() {
58 58
 		$columns = array(
59
-			'title' => array( 'title', false ),
60
-			'started' => array( 'started', false ),
61
-			'completed' => array( 'completed', false ),
62
-			'status' => array( 'status', false ),
59
+			'title' => array('title', false),
60
+			'started' => array('started', false),
61
+			'completed' => array('completed', false),
62
+			'status' => array('status', false),
63 63
 //			'grade' => array( 'grade', false ),
64
-			'percent' => array( 'percent', false )
64
+			'percent' => array('percent', false)
65 65
 		);
66
-		$columns = apply_filters( 'sensei_analysis_user_profile_columns_sortable', $columns );
66
+		$columns = apply_filters('sensei_analysis_user_profile_columns_sortable', $columns);
67 67
 		return $columns;
68 68
 	}
69 69
 
@@ -77,32 +77,32 @@  discard block
 block discarded – undo
77 77
 
78 78
 		// Handle orderby (needs work)
79 79
 		$orderby = '';
80
-		if ( !empty( $_GET['orderby'] ) ) {
81
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
82
-				$orderby = esc_html( $_GET['orderby'] );
80
+		if ( ! empty($_GET['orderby'])) {
81
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
82
+				$orderby = esc_html($_GET['orderby']);
83 83
 			} // End If Statement
84 84
 		}
85 85
 
86 86
 		// Handle order
87 87
 		$order = 'ASC';
88
-		if ( !empty( $_GET['order'] ) ) {
89
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
88
+		if ( ! empty($_GET['order'])) {
89
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
90 90
 		}
91 91
 
92 92
 		// Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids
93 93
 		$search = false;
94
-		if ( !empty( $_GET['s'] ) ) {
95
-			$search = esc_html( $_GET['s'] );
94
+		if ( ! empty($_GET['s'])) {
95
+			$search = esc_html($_GET['s']);
96 96
 		} // End If Statement
97 97
 		$this->search = $search;
98 98
 
99
-		$per_page = $this->get_items_per_page( 'sensei_comments_per_page' );
100
-		$per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' );
99
+		$per_page = $this->get_items_per_page('sensei_comments_per_page');
100
+		$per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments');
101 101
 
102 102
 		$paged = $this->get_pagenum();
103 103
 		$offset = 0;
104
-		if ( !empty($paged) ) {
105
-			$offset = $per_page * ( $paged - 1 );
104
+		if ( ! empty($paged)) {
105
+			$offset = $per_page * ($paged - 1);
106 106
 		} // End If Statement
107 107
 
108 108
 		$args = array(
@@ -111,19 +111,19 @@  discard block
 block discarded – undo
111 111
 			'orderby' => $orderby,
112 112
 			'order' => $order,
113 113
 		);
114
-		if ( $this->search ) {
114
+		if ($this->search) {
115 115
 			$args['search'] = $this->search;
116 116
 		} // End If Statement
117 117
 
118
-		$this->items = $this->get_course_statuses( $args );
118
+		$this->items = $this->get_course_statuses($args);
119 119
 
120 120
 		$total_items = $this->total_items;
121
-		$total_pages = ceil( $total_items / $per_page );
122
-		$this->set_pagination_args( array(
121
+		$total_pages = ceil($total_items / $per_page);
122
+		$this->set_pagination_args(array(
123 123
 			'total_items' => $total_items,
124 124
 			'total_pages' => $total_pages,
125 125
 			'per_page' => $per_page
126
-		) );
126
+		));
127 127
 	}
128 128
 
129 129
 	/**
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 	 * @since  1.7.0
132 132
 	 * @return data
133 133
 	 */
134
-	public function generate_report( $report ) {
134
+	public function generate_report($report) {
135 135
 
136 136
 		$data = array();
137 137
 
@@ -139,22 +139,22 @@  discard block
 block discarded – undo
139 139
 
140 140
 		// Handle orderby
141 141
 		$orderby = '';
142
-		if ( !empty( $_GET['orderby'] ) ) {
143
-			if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) {
144
-				$orderby = esc_html( $_GET['orderby'] );
142
+		if ( ! empty($_GET['orderby'])) {
143
+			if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) {
144
+				$orderby = esc_html($_GET['orderby']);
145 145
 			} // End If Statement
146 146
 		}
147 147
 
148 148
 		// Handle order
149 149
 		$order = 'ASC';
150
-		if ( !empty( $_GET['order'] ) ) {
151
-			$order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC';
150
+		if ( ! empty($_GET['order'])) {
151
+			$order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC';
152 152
 		}
153 153
 
154 154
 		// Handle search
155 155
 		$search = false;
156
-		if ( !empty( $_GET['s'] ) ) {
157
-			$search = esc_html( $_GET['s'] );
156
+		if ( ! empty($_GET['s'])) {
157
+			$search = esc_html($_GET['s']);
158 158
 		} // End If Statement
159 159
 		$this->search = $search;
160 160
 
@@ -162,23 +162,23 @@  discard block
 block discarded – undo
162 162
 			'orderby' => $orderby,
163 163
 			'order' => $order,
164 164
 		);
165
-		if ( $this->search ) {
165
+		if ($this->search) {
166 166
 			$args['search'] = $this->search;
167 167
 		} // End If Statement
168 168
 
169 169
 		// Start the csv with the column headings
170 170
 		$column_headers = array();
171 171
 		$columns = $this->get_columns();
172
-		foreach( $columns AS $key => $title ) {
172
+		foreach ($columns AS $key => $title) {
173 173
 			$column_headers[] = $title;
174 174
 		}
175 175
 		$data[] = $column_headers;
176 176
 
177
-		$this->items = $this->get_course_statuses( $args );
177
+		$this->items = $this->get_course_statuses($args);
178 178
 
179 179
 		// Process each row
180
-		foreach( $this->items AS $item) {
181
-			$data[] = $this->get_row_data( $item );
180
+		foreach ($this->items AS $item) {
181
+			$data[] = $this->get_row_data($item);
182 182
 		}
183 183
 
184 184
 		return $data;
@@ -189,43 +189,43 @@  discard block
 block discarded – undo
189 189
 	 * @since  1.7.0
190 190
 	 * @param object $item The current item
191 191
 	 */
192
-	protected function get_row_data( $item ) {
192
+	protected function get_row_data($item) {
193 193
 
194
-		$course_title =  get_the_title( $item->comment_post_ID );
195
-		$course_percent = get_comment_meta( $item->comment_ID, 'percent', true );
196
-		$course_start_date = get_comment_meta( $item->comment_ID, 'start', true );
194
+		$course_title = get_the_title($item->comment_post_ID);
195
+		$course_percent = get_comment_meta($item->comment_ID, 'percent', true);
196
+		$course_start_date = get_comment_meta($item->comment_ID, 'start', true);
197 197
 		$course_end_date = '';
198 198
 
199
-		if( 'complete' == $item->comment_approved ) {
199
+		if ('complete' == $item->comment_approved) {
200 200
 
201
-            $status =  __( 'Completed', 'woothemes-sensei' );
201
+            $status = __('Completed', 'woothemes-sensei');
202 202
 			$status_class = 'graded';
203 203
 
204 204
 			$course_end_date = $item->comment_date;
205 205
 
206 206
 		} else {
207 207
 
208
-			$status =  __( 'In Progress', 'woothemes-sensei' );
208
+			$status = __('In Progress', 'woothemes-sensei');
209 209
 			$status_class = 'in-progress';
210 210
 
211 211
 		}
212 212
 
213 213
 		// Output users data
214
-		if ( !$this->csv_output ) {
215
-			$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $this->user_id, 'course_id' => $item->comment_post_ID ), admin_url( 'admin.php' ) );
214
+		if ( ! $this->csv_output) {
215
+			$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $this->user_id, 'course_id' => $item->comment_post_ID), admin_url('admin.php'));
216 216
 
217
-			$course_title = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $course_title . '</a></strong>';
218
-			$status = sprintf( '<span class="%s">%s</span>', $status_class, $status );
219
-			if ( is_numeric($course_percent) ) {
217
+			$course_title = '<strong><a class="row-title" href="'.esc_url($url).'">'.$course_title.'</a></strong>';
218
+			$status = sprintf('<span class="%s">%s</span>', $status_class, $status);
219
+			if (is_numeric($course_percent)) {
220 220
 				$course_percent .= '%';
221 221
 			}
222 222
 		} // End If Statement
223
-		$column_data = apply_filters( 'sensei_analysis_user_profile_column_data', array( 'title' => $course_title,
223
+		$column_data = apply_filters('sensei_analysis_user_profile_column_data', array('title' => $course_title,
224 224
 										'started' => $course_start_date,
225 225
 										'completed' => $course_end_date,
226 226
 										'status' => $status,
227 227
 										'percent' => $course_percent,
228
-									), $item );
228
+									), $item);
229 229
 
230 230
 		return $column_data;
231 231
 	}
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
 	 * @since  1.7.0
236 236
 	 * @return array statuses
237 237
 	 */
238
-	private function get_course_statuses( $args ) {
238
+	private function get_course_statuses($args) {
239 239
 
240 240
 		$activity_args = array( 
241 241
 				'user_id' => $this->user_id,
@@ -247,23 +247,23 @@  discard block
 block discarded – undo
247 247
 				'status' => 'any',
248 248
 			);
249 249
 
250
-		$activity_args = apply_filters( 'sensei_analysis_user_profile_filter_statuses', $activity_args );
250
+		$activity_args = apply_filters('sensei_analysis_user_profile_filter_statuses', $activity_args);
251 251
 
252 252
 		// WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice
253
-		$this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) );
253
+		$this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0)));
254 254
 
255 255
 		// Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views?
256
-		if ( $this->total_items < $activity_args['offset'] ) {
256
+		if ($this->total_items < $activity_args['offset']) {
257 257
 
258
-			$new_paged = floor( $this->total_items / $activity_args['number'] );
258
+			$new_paged = floor($this->total_items / $activity_args['number']);
259 259
 			$activity_args['offset'] = $new_paged * $activity_args['number'];
260 260
 
261 261
 		}
262
-		$statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true );
262
+		$statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true);
263 263
 
264 264
 		// Need to always return an array, even with only 1 item
265
-		if ( !is_array($statuses) ) {
266
-			$statuses = array( $statuses );
265
+		if ( ! is_array($statuses)) {
266
+			$statuses = array($statuses);
267 267
 		}
268 268
 
269 269
 		return $statuses;
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 	 * @return void
277 277
 	 */
278 278
 	public function no_items() {
279
-		echo  __( 'No courses found.', 'woothemes-sensei' );
279
+		echo  __('No courses found.', 'woothemes-sensei');
280 280
 	} // End no_items()
281 281
 
282 282
 	/**
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 * @return void
286 286
 	 */
287 287
 	public function data_table_header() {
288
-		echo '<strong>' . __( 'Courses', 'woothemes-sensei' ) . '</strong>';
288
+		echo '<strong>'.__('Courses', 'woothemes-sensei').'</strong>';
289 289
 	}
290 290
 
291 291
 	/**
@@ -294,10 +294,10 @@  discard block
 block discarded – undo
294 294
 	 * @return void
295 295
 	 */
296 296
 	public function data_table_footer() {
297
-		$user = get_user_by( 'id', $this->user_id );
298
-		$report = sanitize_title( $user->display_name ) . '-course-overview';
299
-		$url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $this->user_id, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) );
300
-		echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>';
297
+		$user = get_user_by('id', $this->user_id);
298
+		$report = sanitize_title($user->display_name).'-course-overview';
299
+		$url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $this->user_id, 'sensei_report_download' => $report), admin_url('admin.php'));
300
+		echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>';
301 301
 	}
302 302
 
303 303
 	/**
@@ -305,8 +305,8 @@  discard block
 block discarded – undo
305 305
 	 * @since  1.7.0
306 306
 	 * @return string
307 307
 	 */
308
-	public function search_button( $text = '' ) {
309
-		return __( 'Search Courses', 'woothemes-sensei' );
308
+	public function search_button($text = '') {
309
+		return __('Search Courses', 'woothemes-sensei');
310 310
 	}
311 311
 
312 312
 } // End Class
Please login to merge, or discard this patch.