@@ -1,5 +1,8 @@ discard block |
||
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 |
||
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 |
||
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'; |
@@ -205,13 +205,13 @@ discard block |
||
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 |
||
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 |
||
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 “%s”' ), $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 |
||
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 “%s”' ), $title ); |
298 | 298 |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 “%s”' ), $title ); |
|
250 | + $title = Sensei_Learner::get_full_name($user_activity->user_id); |
|
251 | + $a_title = sprintf(__('Edit “%s”'), $title); |
|
252 | 252 | |
253 | 253 | /** |
254 | 254 | * sensei_learners_main_column_data filter |
@@ -263,50 +263,50 @@ discard block |
||
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 “%s”' ), $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 “%s”'), $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 “%s”' ), $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 “%s”'), $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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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>← ', $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>← ', $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 |
||
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 |
||
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 |
@@ -1,5 +1,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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' ); |
@@ -627,7 +627,7 @@ |
||
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 |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -1,5 +1,8 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -1424,8 +1424,8 @@ discard block |
||
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 |
||
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 ) { |
@@ -12,107 +12,107 @@ discard block |
||
12 | 12 | */ |
13 | 13 | class Sensei_Updates |
14 | 14 | { |
15 | - public $token = 'woothemes-sensei'; |
|
16 | - public $version; |
|
17 | - public $updates_run; |
|
18 | - public $updates; |
|
19 | - private $parent; |
|
20 | - |
|
21 | - /** |
|
22 | - * Constructor. |
|
23 | - * |
|
24 | - * @access public |
|
25 | - * @since 1.1.0 |
|
26 | - * @param string $parent The main Sensei object by Ref. |
|
27 | - * @return void |
|
28 | - */ |
|
29 | - public function __construct($parent) |
|
30 | - { |
|
15 | + public $token = 'woothemes-sensei'; |
|
16 | + public $version; |
|
17 | + public $updates_run; |
|
18 | + public $updates; |
|
19 | + private $parent; |
|
20 | + |
|
21 | + /** |
|
22 | + * Constructor. |
|
23 | + * |
|
24 | + * @access public |
|
25 | + * @since 1.1.0 |
|
26 | + * @param string $parent The main Sensei object by Ref. |
|
27 | + * @return void |
|
28 | + */ |
|
29 | + public function __construct($parent) |
|
30 | + { |
|
31 | 31 | |
32 | 32 | // Setup object data |
33 | 33 | $this->parent = $parent; |
34 | 34 | $this->updates_run = get_option( 'woothemes-sensei-upgrades', array() ); |
35 | 35 | |
36 | - // The list of upgrades to run |
|
37 | - $this->updates = array('1.1.0' => array('auto' => array('assign_role_caps' => array('title' => __('Assign role capabilities', 'woothemes-sensei'), 'desc' => __('Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei'), 'product' => 'Sensei')), |
|
38 | - 'manual' => array() |
|
39 | - ), |
|
40 | - '1.3.0' => array('auto' => array('set_default_quiz_grade_type' => array('title' => __('Set default quiz grade type', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to the default \'auto\' grade type.', 'woothemes-sensei')), |
|
41 | - 'set_default_question_type' => array('title' => __('Set default question type', 'woothemes-sensei'), 'desc' => __('Sets all questions to the default \'multiple choice\' type.', 'woothemes-sensei')) |
|
42 | - ), |
|
43 | - 'manual' => array('update_question_answer_data' => array('title' => __('Update question answer data', 'woothemes-sensei'), 'desc' => __('Updates questions to use the new question types structure.', 'woothemes-sensei'))) |
|
44 | - ), |
|
45 | - '1.4.0' => array('auto' => array('update_question_grade_points' => array('title' => __('Update question grade points', 'woothemes-sensei'), 'desc' => __('Sets all question grade points to the default value of \'1\'.', 'woothemes-sensei'))), |
|
46 | - 'manual' => array() |
|
47 | - ), |
|
48 | - '1.5.0' => array('auto' => array('convert_essay_paste_questions' => array('title' => __('Convert essay paste questions into multi-line questions', 'woothemes-sensei'), 'desc' => __('Converts all essay paste questions into multi-line questions as the essay paste question type was removed in v1.5.0.', 'woothemes-sensei'))), |
|
49 | - 'manual' => array('set_random_question_order' => array('title' => __('Set all quizzes to have a random question order', 'woothemes-sensei'), 'desc' => __('Sets the order all of questions in all quizzes to a random order, which can be switched off per quiz.', 'woothemes-sensei')), |
|
50 | - 'set_default_show_question_count' => array('title' => __('Set all quizzes to show all questions', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to show all questions - this can be changed per quiz.', 'woothemes-sensei')), |
|
51 | - 'remove_deleted_user_activity' => array('title' => __('Remove Sensei activity for deleted users', 'woothemes-sensei'), 'desc' => __('Removes all course, lesson & quiz activity for users that have already been deleted from the database. This will fix incorrect learner counts in the Analysis section.', 'woothemes-sensei'))) |
|
52 | - ), |
|
53 | - '1.6.0' => array('auto' => array('add_teacher_role' => array('title' => __('Add \'Teacher\' role', 'woothemes-sensei'), 'desc' => __('Adds a \'Teacher\' role to your WordPress site that will allow users to mange the Grading and Analysis pages.', 'woothemes-sensei')), |
|
54 | - 'add_sensei_caps' => array('title' => __('Add administrator capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei\' and \'manage_sensei_grades\' capabilities to the Administrator role.', 'woothemes-sensei')), |
|
55 | - 'restructure_question_meta' => array('title' => __('Restructure question meta data', 'woothemes-sensei'), 'desc' => __('Restructures the question meta data as it relates to quizzes - this accounts for changes in the data structure in v1.6+.', 'woothemes-sensei')), |
|
56 | - 'update_quiz_settings' => array('title' => __('Add new quiz settings', 'woothemes-sensei'), 'desc' => __('Adds new settings to quizzes that were previously registered as global settings.', 'woothemes-sensei')), |
|
57 | - 'reset_lesson_order_meta' => array('title' => __('Set default order of lessons', 'woothemes-sensei'), 'desc' => __('Adds data to lessons to ensure that they show up on the \'Order Lessons\' screen - if this update has been run once before then it will reset all lessons to the default order.', 'woothemes-sensei')),), |
|
58 | - 'manual' => array() |
|
59 | - ), |
|
60 | - '1.7.0' => array('auto' => array('add_editor_caps' => array('title' => __('Add Editor capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei_grades\' capability to the Editor role.', 'woothemes-sensei')),), |
|
61 | - 'forced' => array('update_question_gap_fill_separators' => array('title' => __('Update Gap Fill questions', 'woothemes-sensei'), 'desc' => __('Updates the format of gap fill questions to allow auto grading and greater flexibility in matching.', 'woothemes-sensei')), |
|
62 | - 'update_quiz_lesson_relationship' => array('title' => __('Restructure quiz lesson relationship', 'woothemes-sensei'), 'desc' => __('Adds data to quizzes and lessons to ensure that they maintain their 1 to 1 relationship.', 'woothemes-sensei')), |
|
63 | - 'status_changes_fix_lessons' => array('title' => __('Update lesson statuses', 'woothemes-sensei'), 'desc' => __('Update existing lesson statuses.', 'woothemes-sensei')), |
|
64 | - 'status_changes_convert_lessons' => array('title' => __('Convert lesson statuses', 'woothemes-sensei'), 'desc' => __('Convert to new lesson statuses.', 'woothemes-sensei')), |
|
65 | - 'status_changes_convert_courses' => array('title' => __('Convert course statuses', 'woothemes-sensei'), 'desc' => __('Convert to new course statuses.', 'woothemes-sensei')), |
|
66 | - 'status_changes_convert_questions' => array('title' => __('Convert question statuses', 'woothemes-sensei'), 'desc' => __('Convert to new question statuses.', 'woothemes-sensei')), |
|
67 | - 'update_legacy_sensei_comments_status' => array('title' => __('Convert legacy Sensei activity types', 'woothemes-sensei'), 'desc' => __('Convert all legacy Sensei activity types such as \'sensei_lesson_start\' and \'sensei_user_answer\' to new status format.', 'woothemes-sensei')), |
|
68 | - 'update_comment_course_lesson_comment_counts' => array('title' => __('Update comment counts', 'woothemes-sensei'), 'desc' => __('Update comment counts on Courses and Lessons due to status changes.', 'woothemes-sensei')),), |
|
69 | - ), |
|
70 | - '1.7.2' => array('auto' => array('index_comment_status_field' => array('title' => __('Add database index to comment statuses', 'woothemes-sensei'), 'desc' => __('This indexes the comment statuses in the database, which will speed up all Sensei activity queries.', 'woothemes-sensei')),), |
|
71 | - /*'manual' => array( 'remove_legacy_comments' => array( 'title' => __( 'Remove legacy Sensei activity types', 'woothemes-sensei' ), 'desc' => __( 'This removes all legacy (pre-1.7) Sensei activity types - only run this update once the update to v1.7 is complete and everything is stable.', 'woothemes-sensei' ) ) )*/ |
|
72 | - ), |
|
73 | - '1.8.0' => array('auto' => array('enhance_teacher_role' => array('title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.'),), |
|
74 | - 'manual' => array() |
|
75 | - ), |
|
76 | - ); |
|
36 | + // The list of upgrades to run |
|
37 | + $this->updates = array('1.1.0' => array('auto' => array('assign_role_caps' => array('title' => __('Assign role capabilities', 'woothemes-sensei'), 'desc' => __('Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei'), 'product' => 'Sensei')), |
|
38 | + 'manual' => array() |
|
39 | + ), |
|
40 | + '1.3.0' => array('auto' => array('set_default_quiz_grade_type' => array('title' => __('Set default quiz grade type', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to the default \'auto\' grade type.', 'woothemes-sensei')), |
|
41 | + 'set_default_question_type' => array('title' => __('Set default question type', 'woothemes-sensei'), 'desc' => __('Sets all questions to the default \'multiple choice\' type.', 'woothemes-sensei')) |
|
42 | + ), |
|
43 | + 'manual' => array('update_question_answer_data' => array('title' => __('Update question answer data', 'woothemes-sensei'), 'desc' => __('Updates questions to use the new question types structure.', 'woothemes-sensei'))) |
|
44 | + ), |
|
45 | + '1.4.0' => array('auto' => array('update_question_grade_points' => array('title' => __('Update question grade points', 'woothemes-sensei'), 'desc' => __('Sets all question grade points to the default value of \'1\'.', 'woothemes-sensei'))), |
|
46 | + 'manual' => array() |
|
47 | + ), |
|
48 | + '1.5.0' => array('auto' => array('convert_essay_paste_questions' => array('title' => __('Convert essay paste questions into multi-line questions', 'woothemes-sensei'), 'desc' => __('Converts all essay paste questions into multi-line questions as the essay paste question type was removed in v1.5.0.', 'woothemes-sensei'))), |
|
49 | + 'manual' => array('set_random_question_order' => array('title' => __('Set all quizzes to have a random question order', 'woothemes-sensei'), 'desc' => __('Sets the order all of questions in all quizzes to a random order, which can be switched off per quiz.', 'woothemes-sensei')), |
|
50 | + 'set_default_show_question_count' => array('title' => __('Set all quizzes to show all questions', 'woothemes-sensei'), 'desc' => __('Sets all quizzes to show all questions - this can be changed per quiz.', 'woothemes-sensei')), |
|
51 | + 'remove_deleted_user_activity' => array('title' => __('Remove Sensei activity for deleted users', 'woothemes-sensei'), 'desc' => __('Removes all course, lesson & quiz activity for users that have already been deleted from the database. This will fix incorrect learner counts in the Analysis section.', 'woothemes-sensei'))) |
|
52 | + ), |
|
53 | + '1.6.0' => array('auto' => array('add_teacher_role' => array('title' => __('Add \'Teacher\' role', 'woothemes-sensei'), 'desc' => __('Adds a \'Teacher\' role to your WordPress site that will allow users to mange the Grading and Analysis pages.', 'woothemes-sensei')), |
|
54 | + 'add_sensei_caps' => array('title' => __('Add administrator capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei\' and \'manage_sensei_grades\' capabilities to the Administrator role.', 'woothemes-sensei')), |
|
55 | + 'restructure_question_meta' => array('title' => __('Restructure question meta data', 'woothemes-sensei'), 'desc' => __('Restructures the question meta data as it relates to quizzes - this accounts for changes in the data structure in v1.6+.', 'woothemes-sensei')), |
|
56 | + 'update_quiz_settings' => array('title' => __('Add new quiz settings', 'woothemes-sensei'), 'desc' => __('Adds new settings to quizzes that were previously registered as global settings.', 'woothemes-sensei')), |
|
57 | + 'reset_lesson_order_meta' => array('title' => __('Set default order of lessons', 'woothemes-sensei'), 'desc' => __('Adds data to lessons to ensure that they show up on the \'Order Lessons\' screen - if this update has been run once before then it will reset all lessons to the default order.', 'woothemes-sensei')),), |
|
58 | + 'manual' => array() |
|
59 | + ), |
|
60 | + '1.7.0' => array('auto' => array('add_editor_caps' => array('title' => __('Add Editor capabilities', 'woothemes-sensei'), 'desc' => __('Adds the \'manage_sensei_grades\' capability to the Editor role.', 'woothemes-sensei')),), |
|
61 | + 'forced' => array('update_question_gap_fill_separators' => array('title' => __('Update Gap Fill questions', 'woothemes-sensei'), 'desc' => __('Updates the format of gap fill questions to allow auto grading and greater flexibility in matching.', 'woothemes-sensei')), |
|
62 | + 'update_quiz_lesson_relationship' => array('title' => __('Restructure quiz lesson relationship', 'woothemes-sensei'), 'desc' => __('Adds data to quizzes and lessons to ensure that they maintain their 1 to 1 relationship.', 'woothemes-sensei')), |
|
63 | + 'status_changes_fix_lessons' => array('title' => __('Update lesson statuses', 'woothemes-sensei'), 'desc' => __('Update existing lesson statuses.', 'woothemes-sensei')), |
|
64 | + 'status_changes_convert_lessons' => array('title' => __('Convert lesson statuses', 'woothemes-sensei'), 'desc' => __('Convert to new lesson statuses.', 'woothemes-sensei')), |
|
65 | + 'status_changes_convert_courses' => array('title' => __('Convert course statuses', 'woothemes-sensei'), 'desc' => __('Convert to new course statuses.', 'woothemes-sensei')), |
|
66 | + 'status_changes_convert_questions' => array('title' => __('Convert question statuses', 'woothemes-sensei'), 'desc' => __('Convert to new question statuses.', 'woothemes-sensei')), |
|
67 | + 'update_legacy_sensei_comments_status' => array('title' => __('Convert legacy Sensei activity types', 'woothemes-sensei'), 'desc' => __('Convert all legacy Sensei activity types such as \'sensei_lesson_start\' and \'sensei_user_answer\' to new status format.', 'woothemes-sensei')), |
|
68 | + 'update_comment_course_lesson_comment_counts' => array('title' => __('Update comment counts', 'woothemes-sensei'), 'desc' => __('Update comment counts on Courses and Lessons due to status changes.', 'woothemes-sensei')),), |
|
69 | + ), |
|
70 | + '1.7.2' => array('auto' => array('index_comment_status_field' => array('title' => __('Add database index to comment statuses', 'woothemes-sensei'), 'desc' => __('This indexes the comment statuses in the database, which will speed up all Sensei activity queries.', 'woothemes-sensei')),), |
|
71 | + /*'manual' => array( 'remove_legacy_comments' => array( 'title' => __( 'Remove legacy Sensei activity types', 'woothemes-sensei' ), 'desc' => __( 'This removes all legacy (pre-1.7) Sensei activity types - only run this update once the update to v1.7 is complete and everything is stable.', 'woothemes-sensei' ) ) )*/ |
|
72 | + ), |
|
73 | + '1.8.0' => array('auto' => array('enhance_teacher_role' => array('title' => 'Enhance the \'Teacher\' role', 'desc' => 'Adds the ability for a \'Teacher\' to create courses, lessons , quizes and manage their learners.'),), |
|
74 | + 'manual' => array() |
|
75 | + ), |
|
76 | + ); |
|
77 | 77 | |
78 | 78 | $this->updates = apply_filters( 'sensei_upgrade_functions', $this->updates, $this->updates ); |
79 | 79 | $this->version = get_option( 'woothemes-sensei-version' ); |
80 | 80 | |
81 | - // Manual Update Screen |
|
82 | - add_action('admin_menu', array($this, 'add_update_admin_screen'), 50); |
|
83 | - |
|
84 | - } // End __construct() |
|
85 | - |
|
86 | - /** |
|
87 | - * add_update_admin_screen Adds admin screen to run manual udpates |
|
88 | - * |
|
89 | - * @access public |
|
90 | - * @since 1.3.7 |
|
91 | - * @return void |
|
92 | - */ |
|
93 | - public function add_update_admin_screen() |
|
94 | - { |
|
95 | - if (current_user_can('manage_options')) { |
|
96 | - add_submenu_page('sensei', __('Sensei Updates', 'woothemes-sensei'), __('Data Updates', 'woothemes-sensei'), 'manage_options', 'sensei_updates', array($this, 'sensei_updates_page')); |
|
97 | - } |
|
98 | - } // End add_update_admin_screen() |
|
99 | - |
|
100 | - /** |
|
101 | - * sensei_updates_page HTML output for manual update screen |
|
102 | - * |
|
103 | - * @access public |
|
104 | - * @since 1.3.7 |
|
105 | - * @return void |
|
106 | - */ |
|
107 | - public function sensei_updates_page() { |
|
108 | - |
|
109 | - // Only allow admins to load this page and run the update functions |
|
110 | - if ( ! current_user_can('manage_options')) { |
|
111 | - |
|
112 | - return; |
|
113 | - |
|
114 | - } |
|
115 | - ?> |
|
81 | + // Manual Update Screen |
|
82 | + add_action('admin_menu', array($this, 'add_update_admin_screen'), 50); |
|
83 | + |
|
84 | + } // End __construct() |
|
85 | + |
|
86 | + /** |
|
87 | + * add_update_admin_screen Adds admin screen to run manual udpates |
|
88 | + * |
|
89 | + * @access public |
|
90 | + * @since 1.3.7 |
|
91 | + * @return void |
|
92 | + */ |
|
93 | + public function add_update_admin_screen() |
|
94 | + { |
|
95 | + if (current_user_can('manage_options')) { |
|
96 | + add_submenu_page('sensei', __('Sensei Updates', 'woothemes-sensei'), __('Data Updates', 'woothemes-sensei'), 'manage_options', 'sensei_updates', array($this, 'sensei_updates_page')); |
|
97 | + } |
|
98 | + } // End add_update_admin_screen() |
|
99 | + |
|
100 | + /** |
|
101 | + * sensei_updates_page HTML output for manual update screen |
|
102 | + * |
|
103 | + * @access public |
|
104 | + * @since 1.3.7 |
|
105 | + * @return void |
|
106 | + */ |
|
107 | + public function sensei_updates_page() { |
|
108 | + |
|
109 | + // Only allow admins to load this page and run the update functions |
|
110 | + if ( ! current_user_can('manage_options')) { |
|
111 | + |
|
112 | + return; |
|
113 | + |
|
114 | + } |
|
115 | + ?> |
|
116 | 116 | |
117 | 117 | <div class="wrap"> |
118 | 118 | |
@@ -120,111 +120,111 @@ discard block |
||
120 | 120 | <h2><?php _e('Sensei Updates', 'woothemes-sensei'); ?></h2> |
121 | 121 | |
122 | 122 | <?php |
123 | - $function_name= ''; |
|
124 | - if ( isset($_GET['action']) && $_GET['action'] == 'update' |
|
125 | - && isset($_GET['n']) && intval($_GET['n']) >= 0 |
|
126 | - && ( (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) { |
|
123 | + $function_name= ''; |
|
124 | + if ( isset($_GET['action']) && $_GET['action'] == 'update' |
|
125 | + && isset($_GET['n']) && intval($_GET['n']) >= 0 |
|
126 | + && ( (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) { |
|
127 | 127 | |
128 | - // Setup the data variables |
|
129 | - $n = intval($_GET['n']); |
|
130 | - $functions_list = ''; |
|
131 | - $done_processing = false; |
|
128 | + // Setup the data variables |
|
129 | + $n = intval($_GET['n']); |
|
130 | + $functions_list = ''; |
|
131 | + $done_processing = false; |
|
132 | 132 | |
133 | - // Check for updates to run |
|
134 | - if (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) { |
|
133 | + // Check for updates to run |
|
134 | + if (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) { |
|
135 | 135 | |
136 | - foreach ($_POST['checked'] as $key => $function_name) { |
|
136 | + foreach ($_POST['checked'] as $key => $function_name) { |
|
137 | 137 | |
138 | - if( ! isset( $_POST[ $function_name.'_nonce_field' ] ) |
|
139 | - || ! wp_verify_nonce( $_POST[ $function_name.'_nonce_field' ] , 'run_'.$function_name ) ){ |
|
138 | + if( ! isset( $_POST[ $function_name.'_nonce_field' ] ) |
|
139 | + || ! wp_verify_nonce( $_POST[ $function_name.'_nonce_field' ] , 'run_'.$function_name ) ){ |
|
140 | 140 | |
141 | - wp_die( |
|
142 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
143 | - '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>', |
|
144 | - 403 |
|
145 | - ); |
|
141 | + wp_die( |
|
142 | + '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
143 | + '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>', |
|
144 | + 403 |
|
145 | + ); |
|
146 | 146 | |
147 | - } |
|
147 | + } |
|
148 | 148 | |
149 | - // Dynamic function call |
|
150 | - if (method_exists($this, $function_name)) { |
|
149 | + // Dynamic function call |
|
150 | + if (method_exists($this, $function_name)) { |
|
151 | 151 | |
152 | - $done_processing = call_user_func_array(array($this, $function_name), array(50, $n)); |
|
152 | + $done_processing = call_user_func_array(array($this, $function_name), array(50, $n)); |
|
153 | 153 | |
154 | - } elseif ($this->function_in_whitelist($function_name)) { |
|
154 | + } elseif ($this->function_in_whitelist($function_name)) { |
|
155 | 155 | |
156 | - $done_processing = call_user_func_array($function_name, array(50, $n)); |
|
156 | + $done_processing = call_user_func_array($function_name, array(50, $n)); |
|
157 | 157 | |
158 | - } else { |
|
158 | + } else { |
|
159 | 159 | |
160 | - _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0'); |
|
161 | - return; |
|
160 | + _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0'); |
|
161 | + return; |
|
162 | 162 | |
163 | - }// End If Statement |
|
163 | + }// End If Statement |
|
164 | 164 | |
165 | - // Add to functions list get args |
|
166 | - if ('' == $functions_list) { |
|
167 | - $functions_list .= $function_name; |
|
168 | - } else { |
|
169 | - $functions_list .= '+' . $function_name; |
|
170 | - } // End If Statement |
|
165 | + // Add to functions list get args |
|
166 | + if ('' == $functions_list) { |
|
167 | + $functions_list .= $function_name; |
|
168 | + } else { |
|
169 | + $functions_list .= '+' . $function_name; |
|
170 | + } // End If Statement |
|
171 | 171 | |
172 | - // Mark update has having been run |
|
173 | - $this->set_update_run($function_name); |
|
172 | + // Mark update has having been run |
|
173 | + $this->set_update_run($function_name); |
|
174 | 174 | |
175 | - } // End For Loop |
|
175 | + } // End For Loop |
|
176 | 176 | |
177 | - } // End If Statement |
|
177 | + } // End If Statement |
|
178 | 178 | |
179 | - // Check for updates to run |
|
180 | - if (isset($_GET['functions']) && '' != $_GET['functions']) { |
|
179 | + // Check for updates to run |
|
180 | + if (isset($_GET['functions']) && '' != $_GET['functions']) { |
|
181 | 181 | |
182 | - // Existing functions from GET variables instead of POST |
|
183 | - $functions_array = $_GET['functions']; |
|
182 | + // Existing functions from GET variables instead of POST |
|
183 | + $functions_array = $_GET['functions']; |
|
184 | 184 | |
185 | - foreach ($functions_array as $key => $function_name) { |
|
185 | + foreach ($functions_array as $key => $function_name) { |
|
186 | 186 | |
187 | - if( ! isset( $_GET[ $function_name.'_nonce' ] ) |
|
188 | - || ! wp_verify_nonce( $_GET[ $function_name.'_nonce' ] , 'run_'.$function_name ) ){ |
|
187 | + if( ! isset( $_GET[ $function_name.'_nonce' ] ) |
|
188 | + || ! wp_verify_nonce( $_GET[ $function_name.'_nonce' ] , 'run_'.$function_name ) ){ |
|
189 | 189 | |
190 | - wp_die( |
|
191 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
192 | - '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>', |
|
193 | - 403 |
|
194 | - ); |
|
190 | + wp_die( |
|
191 | + '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
192 | + '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>', |
|
193 | + 403 |
|
194 | + ); |
|
195 | 195 | |
196 | - } |
|
196 | + } |
|
197 | 197 | |
198 | - // Dynamic function call |
|
199 | - if (method_exists($this, $function_name)) { |
|
198 | + // Dynamic function call |
|
199 | + if (method_exists($this, $function_name)) { |
|
200 | 200 | |
201 | - $done_processing = call_user_func_array(array($this, $function_name), array(50, $n)); |
|
201 | + $done_processing = call_user_func_array(array($this, $function_name), array(50, $n)); |
|
202 | 202 | |
203 | - } elseif ($this->function_in_whitelist($function_name)) { |
|
203 | + } elseif ($this->function_in_whitelist($function_name)) { |
|
204 | 204 | |
205 | - $done_processing = call_user_func_array($function_name, array(50, $n)); |
|
205 | + $done_processing = call_user_func_array($function_name, array(50, $n)); |
|
206 | 206 | |
207 | - } else { |
|
207 | + } else { |
|
208 | 208 | |
209 | - _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0'); |
|
210 | - return; |
|
209 | + _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0'); |
|
210 | + return; |
|
211 | 211 | |
212 | - } // End If Statement |
|
212 | + } // End If Statement |
|
213 | 213 | |
214 | - // Add to functions list get args |
|
215 | - if ('' == $functions_list) { |
|
216 | - $functions_list .= $function_name; |
|
217 | - } else { |
|
218 | - $functions_list .= '+' . $function_name; |
|
219 | - } // End If Statement |
|
214 | + // Add to functions list get args |
|
215 | + if ('' == $functions_list) { |
|
216 | + $functions_list .= $function_name; |
|
217 | + } else { |
|
218 | + $functions_list .= '+' . $function_name; |
|
219 | + } // End If Statement |
|
220 | 220 | |
221 | - $this->set_update_run($function_name); |
|
221 | + $this->set_update_run($function_name); |
|
222 | 222 | |
223 | - } // End For Loop |
|
223 | + } // End For Loop |
|
224 | 224 | |
225 | - } // End If Statement |
|
225 | + } // End If Statement |
|
226 | 226 | |
227 | - if (!$done_processing) { ?> |
|
227 | + if (!$done_processing) { ?> |
|
228 | 228 | |
229 | 229 | <h3><?php _e('Processing Updates...', 'woothemes-sensei'); ?></h3> |
230 | 230 | |
@@ -233,14 +233,14 @@ discard block |
||
233 | 233 | <?php _e( "If your browser doesn't start loading the next page automatically, click this button:", 'woothemes-sensei' ); ?> |
234 | 234 | |
235 | 235 | <?php |
236 | - $next_action_url = add_query_arg( array( |
|
237 | - 'page' => 'sensei_updates', |
|
238 | - 'action' => 'update', |
|
239 | - 'n' => $n + 50, |
|
240 | - 'functions' => array( $functions_list ), |
|
241 | - $function_name.'_nonce' => wp_create_nonce( 'run_'. $function_name ), |
|
242 | - ), admin_url( 'admin.php' ) ); |
|
243 | - ?> |
|
236 | + $next_action_url = add_query_arg( array( |
|
237 | + 'page' => 'sensei_updates', |
|
238 | + 'action' => 'update', |
|
239 | + 'n' => $n + 50, |
|
240 | + 'functions' => array( $functions_list ), |
|
241 | + $function_name.'_nonce' => wp_create_nonce( 'run_'. $function_name ), |
|
242 | + ), admin_url( 'admin.php' ) ); |
|
243 | + ?> |
|
244 | 244 | |
245 | 245 | <a class="button" href="<?php echo esc_url( $next_action_url ); ?>"> |
246 | 246 | |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | |
270 | 270 | <?php } // End If Statement |
271 | 271 | |
272 | - } else { ?> |
|
272 | + } else { ?> |
|
273 | 273 | |
274 | 274 | <h3><?php _e('Updates', 'woothemes-sensei'); ?></h3> |
275 | 275 | <p><?php printf(__('These are updates that have been made available as new Sensei versions have been released. Updates of type %1$sAuto%2$s will run as you update Sensei to the relevant version - other updates need to be run manually and you can do that here.', 'woothemes-sensei'), '<code>', '</code>'); ?></p> |
@@ -298,19 +298,19 @@ discard block |
||
298 | 298 | |
299 | 299 | <tbody class="updates"> |
300 | 300 | <?php |
301 | - // Sort updates with the latest at the top |
|
302 | - uksort($this->updates, array($this, 'sort_updates')); |
|
303 | - $this->updates = array_reverse($this->updates, true); |
|
304 | - $class = 'alternate'; |
|
305 | - foreach ($this->updates as $version => $version_updates) { |
|
306 | - foreach ($version_updates as $type => $updates) { |
|
307 | - foreach ($updates as $update => $data) { |
|
308 | - $update_run = $this->has_update_run($update); |
|
309 | - $product = 'Sensei'; |
|
310 | - if (isset($data['product']) && '' != $data['product']) { |
|
311 | - $product = $data['product']; |
|
312 | - } // End If Statement |
|
313 | - ?> |
|
301 | + // Sort updates with the latest at the top |
|
302 | + uksort($this->updates, array($this, 'sort_updates')); |
|
303 | + $this->updates = array_reverse($this->updates, true); |
|
304 | + $class = 'alternate'; |
|
305 | + foreach ($this->updates as $version => $version_updates) { |
|
306 | + foreach ($version_updates as $type => $updates) { |
|
307 | + foreach ($updates as $update => $data) { |
|
308 | + $update_run = $this->has_update_run($update); |
|
309 | + $product = 'Sensei'; |
|
310 | + if (isset($data['product']) && '' != $data['product']) { |
|
311 | + $product = $data['product']; |
|
312 | + } // End If Statement |
|
313 | + ?> |
|
314 | 314 | <form method="post" action="admin.php?page=sensei_updates&action=update&n=0" |
315 | 315 | name="update-sensei" class="upgrade"> |
316 | 316 | <tr class="<?php echo $class; ?>"> |
@@ -323,11 +323,11 @@ discard block |
||
323 | 323 | </p> |
324 | 324 | </td> |
325 | 325 | <?php |
326 | - $type_label = __('Auto', 'woothemes-sensei'); |
|
327 | - if ($type != 'auto') { |
|
328 | - $type_label = __('Manual', 'woothemes-sensei'); |
|
329 | - } |
|
330 | - ?> |
|
326 | + $type_label = __('Auto', 'woothemes-sensei'); |
|
327 | + if ($type != 'auto') { |
|
328 | + $type_label = __('Manual', 'woothemes-sensei'); |
|
329 | + } |
|
330 | + ?> |
|
331 | 331 | <td><p><?php echo $type_label; ?></p></td> |
332 | 332 | <td> |
333 | 333 | <p> |
@@ -339,24 +339,24 @@ discard block |
||
339 | 339 | name="update"> |
340 | 340 | |
341 | 341 | <?php |
342 | - $nonce_action = 'run_'.$update; |
|
343 | - $nonce_field_name = $update.'_nonce_field'; |
|
344 | - wp_nonce_field( $nonce_action, $nonce_field_name, false, true ); |
|
345 | - ?> |
|
342 | + $nonce_action = 'run_'.$update; |
|
343 | + $nonce_field_name = $update.'_nonce_field'; |
|
344 | + wp_nonce_field( $nonce_action, $nonce_field_name, false, true ); |
|
345 | + ?> |
|
346 | 346 | </p> |
347 | 347 | </td> |
348 | 348 | </tr> |
349 | 349 | </form> |
350 | 350 | <?php |
351 | - if ('alternate' == $class) { |
|
352 | - $class = ''; |
|
353 | - } else { |
|
354 | - $class = 'alternate'; |
|
355 | - } |
|
356 | - } |
|
357 | - } |
|
358 | - } |
|
359 | - ?> |
|
351 | + if ('alternate' == $class) { |
|
352 | + $class = ''; |
|
353 | + } else { |
|
354 | + $class = 'alternate'; |
|
355 | + } |
|
356 | + } |
|
357 | + } |
|
358 | + } |
|
359 | + ?> |
|
360 | 360 | </tbody> |
361 | 361 | |
362 | 362 | </table> |
@@ -364,31 +364,31 @@ discard block |
||
364 | 364 | </div> |
365 | 365 | |
366 | 366 | <?php |
367 | - } // End If Statement |
|
368 | - } // End sensei_updates_page() |
|
367 | + } // End If Statement |
|
368 | + } // End sensei_updates_page() |
|
369 | 369 | |
370 | - /** |
|
371 | - * Since 1.9.0 |
|
372 | - * |
|
373 | - * A list of safe to execute functions withing the |
|
374 | - * updater context. |
|
375 | - * |
|
376 | - * @param string $function_name |
|
377 | - */ |
|
378 | - public function function_in_whitelist( $function_name ){ |
|
370 | + /** |
|
371 | + * Since 1.9.0 |
|
372 | + * |
|
373 | + * A list of safe to execute functions withing the |
|
374 | + * updater context. |
|
375 | + * |
|
376 | + * @param string $function_name |
|
377 | + */ |
|
378 | + public function function_in_whitelist( $function_name ){ |
|
379 | 379 | |
380 | - $function_whitelist = array( |
|
381 | - 'status_changes_convert_questions', |
|
382 | - 'status_changes_fix_lessons', |
|
383 | - 'status_changes_convert_courses', |
|
384 | - 'status_changes_convert_lessons', |
|
385 | - 'status_changes_repair_course_statuses', |
|
380 | + $function_whitelist = array( |
|
381 | + 'status_changes_convert_questions', |
|
382 | + 'status_changes_fix_lessons', |
|
383 | + 'status_changes_convert_courses', |
|
384 | + 'status_changes_convert_lessons', |
|
385 | + 'status_changes_repair_course_statuses', |
|
386 | 386 | |
387 | - ); |
|
387 | + ); |
|
388 | 388 | |
389 | - return in_array($function_name, $function_whitelist ); |
|
389 | + return in_array($function_name, $function_whitelist ); |
|
390 | 390 | |
391 | - }// end function_in_whitelist |
|
391 | + }// end function_in_whitelist |
|
392 | 392 | |
393 | 393 | /** |
394 | 394 | * Sort updates list by version number |
@@ -413,47 +413,47 @@ discard block |
||
413 | 413 | |
414 | 414 | // Only allow admins to run update functions |
415 | 415 | if( ! current_user_can( 'manage_options' ) ) { |
416 | - return false; |
|
417 | - } |
|
418 | - |
|
419 | - $this->force_updates(); |
|
420 | - |
|
421 | - // Run through all functions |
|
422 | - foreach ( $this->updates as $version => $value ) { |
|
423 | - foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) { |
|
424 | - if ( $upgrade_type == $type ) { |
|
425 | - $updated = false; |
|
426 | - // Run the update function |
|
427 | - foreach ( $function_to_run as $function_name => $update_data ) { |
|
428 | - if ( isset( $function_name ) && '' != $function_name ) { |
|
429 | - if ( ! in_array( $function_name, $this->updates_run ) ) { |
|
430 | - $updated = false; |
|
431 | - if ( method_exists( $this, $function_name ) ) { |
|
432 | - |
|
433 | - $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update |
|
416 | + return false; |
|
417 | + } |
|
418 | + |
|
419 | + $this->force_updates(); |
|
420 | + |
|
421 | + // Run through all functions |
|
422 | + foreach ( $this->updates as $version => $value ) { |
|
423 | + foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) { |
|
424 | + if ( $upgrade_type == $type ) { |
|
425 | + $updated = false; |
|
426 | + // Run the update function |
|
427 | + foreach ( $function_to_run as $function_name => $update_data ) { |
|
428 | + if ( isset( $function_name ) && '' != $function_name ) { |
|
429 | + if ( ! in_array( $function_name, $this->updates_run ) ) { |
|
430 | + $updated = false; |
|
431 | + if ( method_exists( $this, $function_name ) ) { |
|
432 | + |
|
433 | + $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update |
|
434 | 434 | update_option( Sensei()->token . '-upgrades', $this->updates_run ); |
435 | 435 | return true; |
436 | 436 | |
437 | - } elseif( $this->function_in_whitelist( $function_name ) ) { |
|
437 | + } elseif( $this->function_in_whitelist( $function_name ) ) { |
|
438 | 438 | |
439 | - $updated = call_user_func( $function_name ); |
|
439 | + $updated = call_user_func( $function_name ); |
|
440 | 440 | |
441 | - } // End If Statement |
|
441 | + } // End If Statement |
|
442 | 442 | |
443 | - if ( $updated ) { |
|
444 | - array_push( $this->updates_run, $function_name ); |
|
445 | - } // End If Statement |
|
446 | - } |
|
447 | - } // End If Statement |
|
448 | - } // End For Loop |
|
449 | - } // End If Statement |
|
450 | - } // End For Loop |
|
451 | - } // End For Loop |
|
443 | + if ( $updated ) { |
|
444 | + array_push( $this->updates_run, $function_name ); |
|
445 | + } // End If Statement |
|
446 | + } |
|
447 | + } // End If Statement |
|
448 | + } // End For Loop |
|
449 | + } // End If Statement |
|
450 | + } // End For Loop |
|
451 | + } // End For Loop |
|
452 | 452 | |
453 | - $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update |
|
454 | - update_option( $this->token . '-upgrades', $this->updates_run ); |
|
453 | + $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update |
|
454 | + update_option( $this->token . '-upgrades', $this->updates_run ); |
|
455 | 455 | |
456 | - return true; |
|
456 | + return true; |
|
457 | 457 | |
458 | 458 | } // End update() |
459 | 459 | |
@@ -566,7 +566,7 @@ discard block |
||
566 | 566 | */ |
567 | 567 | private function set_update_run( $update ) { |
568 | 568 | array_push( $this->updates_run, $update ); |
569 | - $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update |
|
569 | + $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update |
|
570 | 570 | update_option( Sensei()->token . '-upgrades', $this->updates_run ); |
571 | 571 | } |
572 | 572 | |
@@ -1030,11 +1030,11 @@ discard block |
||
1030 | 1030 | update_post_meta( $lesson->ID, '_order_' . $course_id, 0 ); |
1031 | 1031 | } |
1032 | 1032 | |
1033 | - $module = Sensei()->modules->get_lesson_module( $lesson->ID ); |
|
1033 | + $module = Sensei()->modules->get_lesson_module( $lesson->ID ); |
|
1034 | 1034 | |
1035 | - if( $module ) { |
|
1036 | - update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 ); |
|
1037 | - } |
|
1035 | + if( $module ) { |
|
1036 | + update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 ); |
|
1037 | + } |
|
1038 | 1038 | |
1039 | 1039 | } |
1040 | 1040 | |
@@ -1844,22 +1844,22 @@ discard block |
||
1844 | 1844 | |
1845 | 1845 | } |
1846 | 1846 | |
1847 | - /** |
|
1848 | - * WooThemes_Sensei_Updates::enhance_teacher_role |
|
1849 | - * |
|
1850 | - * This runs the update to create the teacher role |
|
1851 | - * @access public |
|
1852 | - * @since 1.8.0 |
|
1853 | - * @return bool; |
|
1854 | - */ |
|
1855 | - public function enhance_teacher_role ( ) { |
|
1856 | - |
|
1857 | - require_once('class-sensei-teacher.php'); |
|
1858 | - $teacher = new Sensei_Teacher(); |
|
1859 | - $teacher->create_role(); |
|
1860 | - return true; |
|
1861 | - |
|
1862 | - }// end enhance_teacher_role |
|
1847 | + /** |
|
1848 | + * WooThemes_Sensei_Updates::enhance_teacher_role |
|
1849 | + * |
|
1850 | + * This runs the update to create the teacher role |
|
1851 | + * @access public |
|
1852 | + * @since 1.8.0 |
|
1853 | + * @return bool; |
|
1854 | + */ |
|
1855 | + public function enhance_teacher_role ( ) { |
|
1856 | + |
|
1857 | + require_once('class-sensei-teacher.php'); |
|
1858 | + $teacher = new Sensei_Teacher(); |
|
1859 | + $teacher->create_role(); |
|
1860 | + return true; |
|
1861 | + |
|
1862 | + }// end enhance_teacher_role |
|
1863 | 1863 | |
1864 | 1864 | } // End Class |
1865 | 1865 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Sensei Updates Class |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | |
32 | 32 | // Setup object data |
33 | 33 | $this->parent = $parent; |
34 | - $this->updates_run = get_option( 'woothemes-sensei-upgrades', array() ); |
|
34 | + $this->updates_run = get_option('woothemes-sensei-upgrades', array()); |
|
35 | 35 | |
36 | 36 | // The list of upgrades to run |
37 | 37 | $this->updates = array('1.1.0' => array('auto' => array('assign_role_caps' => array('title' => __('Assign role capabilities', 'woothemes-sensei'), 'desc' => __('Assigns Sensei capabilites to the relevant user roles.', 'woothemes-sensei'), 'product' => 'Sensei')), |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | ), |
76 | 76 | ); |
77 | 77 | |
78 | - $this->updates = apply_filters( 'sensei_upgrade_functions', $this->updates, $this->updates ); |
|
79 | - $this->version = get_option( 'woothemes-sensei-version' ); |
|
78 | + $this->updates = apply_filters('sensei_upgrade_functions', $this->updates, $this->updates); |
|
79 | + $this->version = get_option('woothemes-sensei-version'); |
|
80 | 80 | |
81 | 81 | // Manual Update Screen |
82 | 82 | add_action('admin_menu', array($this, 'add_update_admin_screen'), 50); |
@@ -120,10 +120,10 @@ discard block |
||
120 | 120 | <h2><?php _e('Sensei Updates', 'woothemes-sensei'); ?></h2> |
121 | 121 | |
122 | 122 | <?php |
123 | - $function_name= ''; |
|
124 | - if ( isset($_GET['action']) && $_GET['action'] == 'update' |
|
123 | + $function_name = ''; |
|
124 | + if (isset($_GET['action']) && $_GET['action'] == 'update' |
|
125 | 125 | && isset($_GET['n']) && intval($_GET['n']) >= 0 |
126 | - && ( (isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) { |
|
126 | + && ((isset($_POST['checked'][0]) && '' != $_POST['checked'][0]) || (isset($_GET['functions']) && '' != $_GET['functions']))) { |
|
127 | 127 | |
128 | 128 | // Setup the data variables |
129 | 129 | $n = intval($_GET['n']); |
@@ -135,12 +135,12 @@ discard block |
||
135 | 135 | |
136 | 136 | foreach ($_POST['checked'] as $key => $function_name) { |
137 | 137 | |
138 | - if( ! isset( $_POST[ $function_name.'_nonce_field' ] ) |
|
139 | - || ! wp_verify_nonce( $_POST[ $function_name.'_nonce_field' ] , 'run_'.$function_name ) ){ |
|
138 | + if ( ! isset($_POST[$function_name.'_nonce_field']) |
|
139 | + || ! wp_verify_nonce($_POST[$function_name.'_nonce_field'], 'run_'.$function_name)) { |
|
140 | 140 | |
141 | 141 | wp_die( |
142 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
143 | - '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>', |
|
142 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
143 | + '<p>'.__('The nonce supplied in order to run this update function is invalid', 'woothemes-sensei').'</p>', |
|
144 | 144 | 403 |
145 | 145 | ); |
146 | 146 | |
@@ -157,7 +157,7 @@ discard block |
||
157 | 157 | |
158 | 158 | } else { |
159 | 159 | |
160 | - _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0'); |
|
160 | + _doing_it_wrong(esc_html($function_name), 'Is not a valid Sensei updater function', 'Sensei 1.9.0'); |
|
161 | 161 | return; |
162 | 162 | |
163 | 163 | }// End If Statement |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | if ('' == $functions_list) { |
167 | 167 | $functions_list .= $function_name; |
168 | 168 | } else { |
169 | - $functions_list .= '+' . $function_name; |
|
169 | + $functions_list .= '+'.$function_name; |
|
170 | 170 | } // End If Statement |
171 | 171 | |
172 | 172 | // Mark update has having been run |
@@ -184,12 +184,12 @@ discard block |
||
184 | 184 | |
185 | 185 | foreach ($functions_array as $key => $function_name) { |
186 | 186 | |
187 | - if( ! isset( $_GET[ $function_name.'_nonce' ] ) |
|
188 | - || ! wp_verify_nonce( $_GET[ $function_name.'_nonce' ] , 'run_'.$function_name ) ){ |
|
187 | + if ( ! isset($_GET[$function_name.'_nonce']) |
|
188 | + || ! wp_verify_nonce($_GET[$function_name.'_nonce'], 'run_'.$function_name)) { |
|
189 | 189 | |
190 | 190 | wp_die( |
191 | - '<h1>' . __( 'Cheatin’ uh?' ) . '</h1>' . |
|
192 | - '<p>' . __( 'The nonce supplied in order to run this update function is invalid','woothemes-sensei') . '</p>', |
|
191 | + '<h1>'.__('Cheatin’ uh?').'</h1>'. |
|
192 | + '<p>'.__('The nonce supplied in order to run this update function is invalid', 'woothemes-sensei').'</p>', |
|
193 | 193 | 403 |
194 | 194 | ); |
195 | 195 | |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | |
207 | 207 | } else { |
208 | 208 | |
209 | - _doing_it_wrong( esc_html( $function_name) , 'Is not a valid Sensei updater function', 'Sensei 1.9.0'); |
|
209 | + _doing_it_wrong(esc_html($function_name), 'Is not a valid Sensei updater function', 'Sensei 1.9.0'); |
|
210 | 210 | return; |
211 | 211 | |
212 | 212 | } // End If Statement |
@@ -215,7 +215,7 @@ discard block |
||
215 | 215 | if ('' == $functions_list) { |
216 | 216 | $functions_list .= $function_name; |
217 | 217 | } else { |
218 | - $functions_list .= '+' . $function_name; |
|
218 | + $functions_list .= '+'.$function_name; |
|
219 | 219 | } // End If Statement |
220 | 220 | |
221 | 221 | $this->set_update_run($function_name); |
@@ -224,27 +224,27 @@ discard block |
||
224 | 224 | |
225 | 225 | } // End If Statement |
226 | 226 | |
227 | - if (!$done_processing) { ?> |
|
227 | + if ( ! $done_processing) { ?> |
|
228 | 228 | |
229 | 229 | <h3><?php _e('Processing Updates...', 'woothemes-sensei'); ?></h3> |
230 | 230 | |
231 | 231 | <p> |
232 | 232 | |
233 | - <?php _e( "If your browser doesn't start loading the next page automatically, click this button:", 'woothemes-sensei' ); ?> |
|
233 | + <?php _e("If your browser doesn't start loading the next page automatically, click this button:", 'woothemes-sensei'); ?> |
|
234 | 234 | |
235 | 235 | <?php |
236 | - $next_action_url = add_query_arg( array( |
|
236 | + $next_action_url = add_query_arg(array( |
|
237 | 237 | 'page' => 'sensei_updates', |
238 | 238 | 'action' => 'update', |
239 | 239 | 'n' => $n + 50, |
240 | - 'functions' => array( $functions_list ), |
|
241 | - $function_name.'_nonce' => wp_create_nonce( 'run_'. $function_name ), |
|
242 | - ), admin_url( 'admin.php' ) ); |
|
240 | + 'functions' => array($functions_list), |
|
241 | + $function_name.'_nonce' => wp_create_nonce('run_'.$function_name), |
|
242 | + ), admin_url('admin.php')); |
|
243 | 243 | ?> |
244 | 244 | |
245 | - <a class="button" href="<?php echo esc_url( $next_action_url ); ?>"> |
|
245 | + <a class="button" href="<?php echo esc_url($next_action_url); ?>"> |
|
246 | 246 | |
247 | - <?php _e( 'Next', 'woothemes-sensei' ); ?> |
|
247 | + <?php _e('Next', 'woothemes-sensei'); ?> |
|
248 | 248 | |
249 | 249 | </a> |
250 | 250 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | <script type='text/javascript'> |
253 | 253 | <!-- |
254 | 254 | function js_sensei_nextpage() { |
255 | - location.href = "<?php echo esc_url_raw( $next_action_url );?>"; |
|
255 | + location.href = "<?php echo esc_url_raw($next_action_url); ?>"; |
|
256 | 256 | } |
257 | 257 | setTimeout( "js_sensei_nextpage()", 250 ); |
258 | 258 | //--> |
@@ -331,17 +331,17 @@ discard block |
||
331 | 331 | <td><p><?php echo $type_label; ?></p></td> |
332 | 332 | <td> |
333 | 333 | <p> |
334 | - <input onclick="javascript:return confirm('<?php echo addslashes( sprintf( __( 'Are you sure you want to run the \'%s\' update?', 'woothemes-sensei' ), $data['title'] ) ); ?>');" |
|
334 | + <input onclick="javascript:return confirm('<?php echo addslashes(sprintf(__('Are you sure you want to run the \'%s\' update?', 'woothemes-sensei'), $data['title'])); ?>');" |
|
335 | 335 | id="update-sensei" |
336 | - class="button<?php if( ! $update_run ) { echo ' button-primary'; } ?>" |
|
336 | + class="button<?php if ( ! $update_run) { echo ' button-primary'; } ?>" |
|
337 | 337 | type="submit" |
338 | - value="<?php if( $update_run ) { _e( 'Re-run Update', 'woothemes-sensei' ); } else { _e( 'Run Update', 'woothemes-sensei' ); } ?>" |
|
338 | + value="<?php if ($update_run) { _e('Re-run Update', 'woothemes-sensei'); } else { _e('Run Update', 'woothemes-sensei'); } ?>" |
|
339 | 339 | name="update"> |
340 | 340 | |
341 | 341 | <?php |
342 | 342 | $nonce_action = 'run_'.$update; |
343 | 343 | $nonce_field_name = $update.'_nonce_field'; |
344 | - wp_nonce_field( $nonce_action, $nonce_field_name, false, true ); |
|
344 | + wp_nonce_field($nonce_action, $nonce_field_name, false, true); |
|
345 | 345 | ?> |
346 | 346 | </p> |
347 | 347 | </td> |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * |
376 | 376 | * @param string $function_name |
377 | 377 | */ |
378 | - public function function_in_whitelist( $function_name ){ |
|
378 | + public function function_in_whitelist($function_name) { |
|
379 | 379 | |
380 | 380 | $function_whitelist = array( |
381 | 381 | 'status_changes_convert_questions', |
@@ -386,7 +386,7 @@ discard block |
||
386 | 386 | |
387 | 387 | ); |
388 | 388 | |
389 | - return in_array($function_name, $function_whitelist ); |
|
389 | + return in_array($function_name, $function_whitelist); |
|
390 | 390 | |
391 | 391 | }// end function_in_whitelist |
392 | 392 | |
@@ -397,8 +397,8 @@ discard block |
||
397 | 397 | * @param string $b Second key |
398 | 398 | * @return integer |
399 | 399 | */ |
400 | - private function sort_updates( $a, $b ) { |
|
401 | - return strcmp( $a, $b ); |
|
400 | + private function sort_updates($a, $b) { |
|
401 | + return strcmp($a, $b); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | /** |
@@ -409,39 +409,39 @@ discard block |
||
409 | 409 | * @access public |
410 | 410 | * @return boolean |
411 | 411 | */ |
412 | - public function update ( $type = 'auto' ) { |
|
412 | + public function update($type = 'auto') { |
|
413 | 413 | |
414 | 414 | // Only allow admins to run update functions |
415 | - if( ! current_user_can( 'manage_options' ) ) { |
|
415 | + if ( ! current_user_can('manage_options')) { |
|
416 | 416 | return false; |
417 | 417 | } |
418 | 418 | |
419 | 419 | $this->force_updates(); |
420 | 420 | |
421 | 421 | // Run through all functions |
422 | - foreach ( $this->updates as $version => $value ) { |
|
423 | - foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) { |
|
424 | - if ( $upgrade_type == $type ) { |
|
422 | + foreach ($this->updates as $version => $value) { |
|
423 | + foreach ($this->updates[$version] as $upgrade_type => $function_to_run) { |
|
424 | + if ($upgrade_type == $type) { |
|
425 | 425 | $updated = false; |
426 | 426 | // Run the update function |
427 | - foreach ( $function_to_run as $function_name => $update_data ) { |
|
428 | - if ( isset( $function_name ) && '' != $function_name ) { |
|
429 | - if ( ! in_array( $function_name, $this->updates_run ) ) { |
|
427 | + foreach ($function_to_run as $function_name => $update_data) { |
|
428 | + if (isset($function_name) && '' != $function_name) { |
|
429 | + if ( ! in_array($function_name, $this->updates_run)) { |
|
430 | 430 | $updated = false; |
431 | - if ( method_exists( $this, $function_name ) ) { |
|
431 | + if (method_exists($this, $function_name)) { |
|
432 | 432 | |
433 | - $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update |
|
434 | - update_option( Sensei()->token . '-upgrades', $this->updates_run ); |
|
433 | + $this->updates_run = array_unique($this->updates_run); // we only need one reference per update |
|
434 | + update_option(Sensei()->token.'-upgrades', $this->updates_run); |
|
435 | 435 | return true; |
436 | 436 | |
437 | - } elseif( $this->function_in_whitelist( $function_name ) ) { |
|
437 | + } elseif ($this->function_in_whitelist($function_name)) { |
|
438 | 438 | |
439 | - $updated = call_user_func( $function_name ); |
|
439 | + $updated = call_user_func($function_name); |
|
440 | 440 | |
441 | 441 | } // End If Statement |
442 | 442 | |
443 | - if ( $updated ) { |
|
444 | - array_push( $this->updates_run, $function_name ); |
|
443 | + if ($updated) { |
|
444 | + array_push($this->updates_run, $function_name); |
|
445 | 445 | } // End If Statement |
446 | 446 | } |
447 | 447 | } // End If Statement |
@@ -450,8 +450,8 @@ discard block |
||
450 | 450 | } // End For Loop |
451 | 451 | } // End For Loop |
452 | 452 | |
453 | - $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update |
|
454 | - update_option( $this->token . '-upgrades', $this->updates_run ); |
|
453 | + $this->updates_run = array_unique($this->updates_run); // we only need one reference per update |
|
454 | + update_option($this->token.'-upgrades', $this->updates_run); |
|
455 | 455 | |
456 | 456 | return true; |
457 | 457 | |
@@ -459,7 +459,7 @@ discard block |
||
459 | 459 | |
460 | 460 | private function force_updates() { |
461 | 461 | |
462 | - if( ! isset( $_GET['page'] ) || 'sensei_updates' != $_GET['page'] ) { |
|
462 | + if ( ! isset($_GET['page']) || 'sensei_updates' != $_GET['page']) { |
|
463 | 463 | |
464 | 464 | // $skip_forced_updates = false; |
465 | 465 | // if( ! get_option( 'woothemes-sensei-force-updates', false ) ) { |
@@ -468,8 +468,8 @@ discard block |
||
468 | 468 | |
469 | 469 | // Force critical updates if only if lessons already exist |
470 | 470 | $skip_forced_updates = false; |
471 | - $lesson_posts = wp_count_posts( 'lesson' ); |
|
472 | - if( ! isset( $lesson_posts->publish ) || ! $lesson_posts->publish ) { |
|
471 | + $lesson_posts = wp_count_posts('lesson'); |
|
472 | + if ( ! isset($lesson_posts->publish) || ! $lesson_posts->publish) { |
|
473 | 473 | $skip_forced_updates = true; |
474 | 474 | } |
475 | 475 | |
@@ -477,69 +477,69 @@ discard block |
||
477 | 477 | |
478 | 478 | $updates_to_run = array(); |
479 | 479 | |
480 | - foreach ( $this->updates as $version => $value ) { |
|
481 | - foreach ( $this->updates[$version] as $upgrade_type => $function_to_run ) { |
|
482 | - if ( $upgrade_type == 'forced' ) { |
|
483 | - foreach ( $function_to_run as $function_name => $update_data ) { |
|
480 | + foreach ($this->updates as $version => $value) { |
|
481 | + foreach ($this->updates[$version] as $upgrade_type => $function_to_run) { |
|
482 | + if ($upgrade_type == 'forced') { |
|
483 | + foreach ($function_to_run as $function_name => $update_data) { |
|
484 | 484 | |
485 | - if( $skip_forced_updates ) { |
|
486 | - $this->set_update_run( $function_name ); |
|
485 | + if ($skip_forced_updates) { |
|
486 | + $this->set_update_run($function_name); |
|
487 | 487 | continue; |
488 | 488 | } |
489 | 489 | |
490 | - $update_run = $this->has_update_run( $function_name ); |
|
490 | + $update_run = $this->has_update_run($function_name); |
|
491 | 491 | |
492 | - if( ! $update_run ) { |
|
492 | + if ( ! $update_run) { |
|
493 | 493 | $use_the_force = true; |
494 | - $updates_to_run[ $function_name ] = $update_data; |
|
494 | + $updates_to_run[$function_name] = $update_data; |
|
495 | 495 | } |
496 | 496 | } |
497 | 497 | } |
498 | 498 | } |
499 | 499 | } |
500 | 500 | |
501 | - if( $skip_forced_updates ) { |
|
501 | + if ($skip_forced_updates) { |
|
502 | 502 | return; |
503 | 503 | } |
504 | 504 | |
505 | - if( $use_the_force && 0 < count( $updates_to_run ) ) { |
|
505 | + if ($use_the_force && 0 < count($updates_to_run)) { |
|
506 | 506 | |
507 | - $update_title = __( 'Important Sensei updates required', 'woothemes-sensei' ); |
|
507 | + $update_title = __('Important Sensei updates required', 'woothemes-sensei'); |
|
508 | 508 | |
509 | - $update_message = '<h1>' . __( 'Important Sensei upgrades required!', 'woothemes-sensei' ) . '</h1>' . "\n"; |
|
509 | + $update_message = '<h1>'.__('Important Sensei upgrades required!', 'woothemes-sensei').'</h1>'."\n"; |
|
510 | 510 | |
511 | 511 | // $update_message .= '<h4>' . sprintf( __( 'These updates are only required if you are updating from a previous version of Sensei. If you are installing Sensei for the first time, %1$syou can dismiss this page by clicking here%2$s.', 'woothemes-sensei' ), '<a href="' . add_query_arg( array( 'sensei_skip_forced_updates' => 'true' ) ) . '">', '</a>' ) . '</h4>' ."\n"; |
512 | 512 | |
513 | - $update_message .= '<p>' . __( 'The latest version of Sensei requires some important database upgrades. In order to run these upgrades you will need to follow the step by step guide below. Your site will not function correctly unless you run these critical updates.', 'woothemes-sensei' ) . '</p>' . "\n"; |
|
513 | + $update_message .= '<p>'.__('The latest version of Sensei requires some important database upgrades. In order to run these upgrades you will need to follow the step by step guide below. Your site will not function correctly unless you run these critical updates.', 'woothemes-sensei').'</p>'."\n"; |
|
514 | 514 | |
515 | - $update_message .= '<p><b>' . __( 'To run the upgrades click on each of the links below in the order that they appear.', 'woothemes-sensei' ) . '</b></p>' . "\n"; |
|
515 | + $update_message .= '<p><b>'.__('To run the upgrades click on each of the links below in the order that they appear.', 'woothemes-sensei').'</b></p>'."\n"; |
|
516 | 516 | |
517 | - $update_message .= '<p>' . __( 'Clicking each link will open up a new window/tab - do not close that window/tab until you see the message \'Update completed successfully\'. Once you see that message you can close the window/tab and start the next upgrade by clicking on the next link in the list.', 'woothemes-sensei' ) . '</p>' . "\n"; |
|
517 | + $update_message .= '<p>'.__('Clicking each link will open up a new window/tab - do not close that window/tab until you see the message \'Update completed successfully\'. Once you see that message you can close the window/tab and start the next upgrade by clicking on the next link in the list.', 'woothemes-sensei').'</p>'."\n"; |
|
518 | 518 | |
519 | - $update_message .= '<p><b>' . __( 'Once all the upgrades have been completed you will be able to use your WordPress site again.', 'woothemes-sensei' ) . '</b></p>' . "\n"; |
|
519 | + $update_message .= '<p><b>'.__('Once all the upgrades have been completed you will be able to use your WordPress site again.', 'woothemes-sensei').'</b></p>'."\n"; |
|
520 | 520 | |
521 | - $update_message .= '<ol>' . "\n"; |
|
521 | + $update_message .= '<ol>'."\n"; |
|
522 | 522 | |
523 | - foreach( $updates_to_run as $function => $data ) { |
|
523 | + foreach ($updates_to_run as $function => $data) { |
|
524 | 524 | |
525 | - if( ! isset( $data['title'] ) ) { |
|
525 | + if ( ! isset($data['title'])) { |
|
526 | 526 | break; |
527 | 527 | } |
528 | 528 | |
529 | - $update_message .= '<li style="margin:5px 0;"><a href="' . admin_url( 'admin.php?page=sensei_updates&action=update&n=0&functions[]=' . $function ) . '" target="_blank">' . $data['title'] . '</a></li>'; |
|
529 | + $update_message .= '<li style="margin:5px 0;"><a href="'.admin_url('admin.php?page=sensei_updates&action=update&n=0&functions[]='.$function).'" target="_blank">'.$data['title'].'</a></li>'; |
|
530 | 530 | } |
531 | 531 | |
532 | - $update_message .= '</ol>' . "\n"; |
|
532 | + $update_message .= '</ol>'."\n"; |
|
533 | 533 | |
534 | - switch( $version ) { |
|
534 | + switch ($version) { |
|
535 | 535 | |
536 | 536 | case '1.7.0': |
537 | - $update_message .= '<p><em>' . sprintf( __( 'Want to know what these upgrades are all about? %1$sFind out more here%2$s.', 'woothemes-sensei' ), '<a href="http://develop.woothemes.com/sensei/2014/12/03/important-information-about-sensei-1-7" target="_blank">', '</a>' ) . '</em></p>' . "\n"; |
|
537 | + $update_message .= '<p><em>'.sprintf(__('Want to know what these upgrades are all about? %1$sFind out more here%2$s.', 'woothemes-sensei'), '<a href="http://develop.woothemes.com/sensei/2014/12/03/important-information-about-sensei-1-7" target="_blank">', '</a>').'</em></p>'."\n"; |
|
538 | 538 | break; |
539 | 539 | |
540 | 540 | } |
541 | 541 | |
542 | - wp_die( $update_message, $update_title ); |
|
542 | + wp_die($update_message, $update_title); |
|
543 | 543 | } |
544 | 544 | } |
545 | 545 | } |
@@ -551,8 +551,8 @@ discard block |
||
551 | 551 | * @since 1.4.0 |
552 | 552 | * @return boolean |
553 | 553 | */ |
554 | - private function has_update_run( $update ) { |
|
555 | - if ( in_array( $update, $this->updates_run ) ) { |
|
554 | + private function has_update_run($update) { |
|
555 | + if (in_array($update, $this->updates_run)) { |
|
556 | 556 | return true; |
557 | 557 | } |
558 | 558 | return false; |
@@ -564,10 +564,10 @@ discard block |
||
564 | 564 | * @param string $update Update to process |
565 | 565 | * @since 1.4.0 |
566 | 566 | */ |
567 | - private function set_update_run( $update ) { |
|
568 | - array_push( $this->updates_run, $update ); |
|
569 | - $this->updates_run = array_unique( $this->updates_run ); // we only need one reference per update |
|
570 | - update_option( Sensei()->token . '-upgrades', $this->updates_run ); |
|
567 | + private function set_update_run($update) { |
|
568 | + array_push($this->updates_run, $update); |
|
569 | + $this->updates_run = array_unique($this->updates_run); // we only need one reference per update |
|
570 | + update_option(Sensei()->token.'-upgrades', $this->updates_run); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | /** |
@@ -578,15 +578,15 @@ discard block |
||
578 | 578 | * @return void |
579 | 579 | */ |
580 | 580 | public function assign_role_caps() { |
581 | - foreach ( $this->parent->post_types->role_caps as $role_cap_set ) { |
|
582 | - foreach ( $role_cap_set as $role_key => $capabilities_array ) { |
|
581 | + foreach ($this->parent->post_types->role_caps as $role_cap_set) { |
|
582 | + foreach ($role_cap_set as $role_key => $capabilities_array) { |
|
583 | 583 | /* Get the role. */ |
584 | - $role = get_role( $role_key ); |
|
585 | - foreach ( $capabilities_array as $cap_name ) { |
|
584 | + $role = get_role($role_key); |
|
585 | + foreach ($capabilities_array as $cap_name) { |
|
586 | 586 | /* If the role exists, add required capabilities for the plugin. */ |
587 | - if ( !empty( $role ) ) { |
|
588 | - if ( !$role->has_cap( $cap_name ) ) { |
|
589 | - $role->add_cap( $cap_name ); |
|
587 | + if ( ! empty($role)) { |
|
588 | + if ( ! $role->has_cap($cap_name)) { |
|
589 | + $role->add_cap($cap_name); |
|
590 | 590 | } // End If Statement |
591 | 591 | } // End If Statement |
592 | 592 | } // End For Loop |
@@ -602,16 +602,16 @@ discard block |
||
602 | 602 | * @return void |
603 | 603 | */ |
604 | 604 | public function set_default_quiz_grade_type() { |
605 | - $args = array( 'post_type' => 'quiz', |
|
605 | + $args = array('post_type' => 'quiz', |
|
606 | 606 | 'posts_per_page' => -1, |
607 | 607 | 'post_status' => 'publish', |
608 | 608 | 'suppress_filters' => 0 |
609 | 609 | ); |
610 | - $quizzes = get_posts( $args ); |
|
610 | + $quizzes = get_posts($args); |
|
611 | 611 | |
612 | - foreach( $quizzes as $quiz ) { |
|
613 | - update_post_meta( $quiz->ID, '_quiz_grade_type', 'auto' ); |
|
614 | - update_post_meta( $quiz->ID, '_quiz_grade_type_disabled', '' ); |
|
612 | + foreach ($quizzes as $quiz) { |
|
613 | + update_post_meta($quiz->ID, '_quiz_grade_type', 'auto'); |
|
614 | + update_post_meta($quiz->ID, '_quiz_grade_type_disabled', ''); |
|
615 | 615 | } |
616 | 616 | } // End set_default_quiz_grade_type |
617 | 617 | |
@@ -623,23 +623,23 @@ discard block |
||
623 | 623 | * @return void |
624 | 624 | */ |
625 | 625 | public function set_default_question_type() { |
626 | - $args = array( 'post_type' => 'question', |
|
626 | + $args = array('post_type' => 'question', |
|
627 | 627 | 'posts_per_page' => -1, |
628 | 628 | 'post_status' => 'publish', |
629 | 629 | 'suppress_filters' => 0 |
630 | 630 | ); |
631 | - $questions = get_posts( $args ); |
|
631 | + $questions = get_posts($args); |
|
632 | 632 | |
633 | 633 | $already_run = true; |
634 | - foreach( $questions as $question ) { |
|
635 | - if( $already_run ) { |
|
636 | - $terms = wp_get_post_terms( $question->ID, 'question-type' ); |
|
637 | - if( is_array( $terms ) && count( $terms ) > 0 ) { |
|
634 | + foreach ($questions as $question) { |
|
635 | + if ($already_run) { |
|
636 | + $terms = wp_get_post_terms($question->ID, 'question-type'); |
|
637 | + if (is_array($terms) && count($terms) > 0) { |
|
638 | 638 | break; |
639 | 639 | } |
640 | 640 | } |
641 | 641 | $already_run = false; |
642 | - wp_set_post_terms( $question->ID, array( 'multiple-choice' ), 'question-type' ); |
|
642 | + wp_set_post_terms($question->ID, array('multiple-choice'), 'question-type'); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | } // End set_default_question_type |
@@ -651,90 +651,90 @@ discard block |
||
651 | 651 | * @access public |
652 | 652 | * @return boolean |
653 | 653 | */ |
654 | - public function update_question_answer_data( $n = 50, $offset = 0 ) { |
|
654 | + public function update_question_answer_data($n = 50, $offset = 0) { |
|
655 | 655 | |
656 | 656 | // Get Total Number of Updates to run |
657 | - $quiz_count_object = wp_count_posts( 'quiz' ); |
|
657 | + $quiz_count_object = wp_count_posts('quiz'); |
|
658 | 658 | $quiz_count_published = $quiz_count_object->publish; |
659 | 659 | |
660 | 660 | // Calculate if this is the last page |
661 | - if ( 0 == $offset ) { |
|
661 | + if (0 == $offset) { |
|
662 | 662 | $current_page = 1; |
663 | 663 | } else { |
664 | - $current_page = intval( $offset / $n ); |
|
664 | + $current_page = intval($offset / $n); |
|
665 | 665 | } // End If Statement |
666 | - $total_pages = intval( $quiz_count_published / $n ); |
|
666 | + $total_pages = intval($quiz_count_published / $n); |
|
667 | 667 | |
668 | 668 | |
669 | - $args = array( 'post_type' => 'quiz', |
|
669 | + $args = array('post_type' => 'quiz', |
|
670 | 670 | 'posts_per_page' => $n, |
671 | 671 | 'offset' => $offset, |
672 | 672 | 'post_status' => 'publish', |
673 | 673 | 'suppress_filters' => 0 |
674 | 674 | ); |
675 | - $quizzes = get_posts( $args ); |
|
675 | + $quizzes = get_posts($args); |
|
676 | 676 | |
677 | 677 | $old_answers = array(); |
678 | 678 | $right_answers = array(); |
679 | 679 | $old_user_answers = array(); |
680 | 680 | |
681 | - if( is_array( $quizzes ) ) { |
|
682 | - foreach( $quizzes as $quiz ) { |
|
681 | + if (is_array($quizzes)) { |
|
682 | + foreach ($quizzes as $quiz) { |
|
683 | 683 | $quiz_id = $quiz->ID; |
684 | 684 | |
685 | 685 | // Get current user answers |
686 | - $comments = Sensei_Utils::sensei_check_for_activity( array( 'post_id' => $quiz_id, 'type' => 'sensei_quiz_answers' ), true ); |
|
686 | + $comments = Sensei_Utils::sensei_check_for_activity(array('post_id' => $quiz_id, 'type' => 'sensei_quiz_answers'), true); |
|
687 | 687 | // Need to always return an array, even with only 1 item |
688 | - if ( !is_array($comments) ) { |
|
689 | - $comments = array( $comments ); |
|
688 | + if ( ! is_array($comments)) { |
|
689 | + $comments = array($comments); |
|
690 | 690 | } |
691 | - foreach ( $comments as $comment ) { |
|
691 | + foreach ($comments as $comment) { |
|
692 | 692 | $user_id = $comment->user_id; |
693 | - $content = maybe_unserialize( base64_decode( $comment->comment_content ) ); |
|
694 | - $old_user_answers[ $quiz_id ][ $user_id ] = $content; |
|
693 | + $content = maybe_unserialize(base64_decode($comment->comment_content)); |
|
694 | + $old_user_answers[$quiz_id][$user_id] = $content; |
|
695 | 695 | } |
696 | 696 | |
697 | 697 | // Get correct answers |
698 | - $questions = Sensei_Utils::sensei_get_quiz_questions( $quiz_id ); |
|
699 | - if( is_array( $questions ) ) { |
|
700 | - foreach( $questions as $question ) { |
|
701 | - $right_answer = get_post_meta( $question->ID, '_question_right_answer', true ); |
|
702 | - $right_answers[ $quiz_id ][ $question->ID ] = $right_answer; |
|
698 | + $questions = Sensei_Utils::sensei_get_quiz_questions($quiz_id); |
|
699 | + if (is_array($questions)) { |
|
700 | + foreach ($questions as $question) { |
|
701 | + $right_answer = get_post_meta($question->ID, '_question_right_answer', true); |
|
702 | + $right_answers[$quiz_id][$question->ID] = $right_answer; |
|
703 | 703 | } |
704 | 704 | } |
705 | 705 | } |
706 | 706 | } |
707 | 707 | |
708 | - if( is_array( $right_answers ) ) { |
|
709 | - foreach( $right_answers as $quiz_id => $question ) { |
|
708 | + if (is_array($right_answers)) { |
|
709 | + foreach ($right_answers as $quiz_id => $question) { |
|
710 | 710 | $count = 0; |
711 | - if( is_array( $question ) ) { |
|
712 | - foreach( $question as $question_id => $answer ) { |
|
711 | + if (is_array($question)) { |
|
712 | + foreach ($question as $question_id => $answer) { |
|
713 | 713 | ++$count; |
714 | - if( isset( $old_user_answers[ $quiz_id ] ) ) { |
|
715 | - $answers_linkup[ $quiz_id ][ $count ] = $question_id; |
|
714 | + if (isset($old_user_answers[$quiz_id])) { |
|
715 | + $answers_linkup[$quiz_id][$count] = $question_id; |
|
716 | 716 | } |
717 | 717 | } |
718 | 718 | } |
719 | 719 | } |
720 | 720 | } |
721 | 721 | |
722 | - if( is_array( $old_user_answers ) ) { |
|
723 | - foreach( $old_user_answers as $quiz_id => $user_answers ) { |
|
724 | - foreach( $user_answers as $user_id => $answers ) { |
|
725 | - foreach( $answers as $answer_id => $user_answer ) { |
|
726 | - $question_id = $answers_linkup[ $quiz_id ][ $answer_id ]; |
|
727 | - $new_user_answers[ $question_id ] = $user_answer; |
|
728 | - Sensei_Utils::sensei_grade_question_auto( $question_id, '', $user_answer, $user_id ); |
|
722 | + if (is_array($old_user_answers)) { |
|
723 | + foreach ($old_user_answers as $quiz_id => $user_answers) { |
|
724 | + foreach ($user_answers as $user_id => $answers) { |
|
725 | + foreach ($answers as $answer_id => $user_answer) { |
|
726 | + $question_id = $answers_linkup[$quiz_id][$answer_id]; |
|
727 | + $new_user_answers[$question_id] = $user_answer; |
|
728 | + Sensei_Utils::sensei_grade_question_auto($question_id, '', $user_answer, $user_id); |
|
729 | 729 | } |
730 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
731 | - Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id ); |
|
732 | - Sensei_Utils::sensei_save_quiz_answers( $new_user_answers, $user_id ); |
|
730 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
731 | + Sensei_Utils::sensei_start_lesson($lesson_id, $user_id); |
|
732 | + Sensei_Utils::sensei_save_quiz_answers($new_user_answers, $user_id); |
|
733 | 733 | } |
734 | 734 | } |
735 | 735 | } |
736 | 736 | |
737 | - if ( $current_page == $total_pages ) { |
|
737 | + if ($current_page == $total_pages) { |
|
738 | 738 | return true; |
739 | 739 | } else { |
740 | 740 | return false; |
@@ -749,15 +749,15 @@ discard block |
||
749 | 749 | * @return boolean |
750 | 750 | */ |
751 | 751 | public function update_question_grade_points() { |
752 | - $args = array( 'post_type' => 'question', |
|
752 | + $args = array('post_type' => 'question', |
|
753 | 753 | 'posts_per_page' => -1, |
754 | 754 | 'post_status' => 'publish', |
755 | 755 | 'suppress_filters' => 0 |
756 | 756 | ); |
757 | - $questions = get_posts( $args ); |
|
757 | + $questions = get_posts($args); |
|
758 | 758 | |
759 | - foreach( $questions as $question ) { |
|
760 | - update_post_meta( $question->ID, '_question_grade', '1' ); |
|
759 | + foreach ($questions as $question) { |
|
760 | + update_post_meta($question->ID, '_question_grade', '1'); |
|
761 | 761 | } |
762 | 762 | return true; |
763 | 763 | } // End update_question_grade_points |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | * @return boolean |
770 | 770 | */ |
771 | 771 | public function convert_essay_paste_questions() { |
772 | - $args = array( 'post_type' => 'question', |
|
772 | + $args = array('post_type' => 'question', |
|
773 | 773 | 'posts_per_page' => -1, |
774 | 774 | 'post_status' => 'publish', |
775 | 775 | 'tax_query' => array( |
@@ -781,14 +781,14 @@ discard block |
||
781 | 781 | ), |
782 | 782 | 'suppress_filters' => 0 |
783 | 783 | ); |
784 | - $questions = get_posts( $args ); |
|
784 | + $questions = get_posts($args); |
|
785 | 785 | |
786 | - foreach( $questions as $question ) { |
|
787 | - wp_set_object_terms( $question->ID, 'multi-line', 'question-type', false ); |
|
786 | + foreach ($questions as $question) { |
|
787 | + wp_set_object_terms($question->ID, 'multi-line', 'question-type', false); |
|
788 | 788 | |
789 | - $quiz_id = get_post_meta( $question->ID, '_quiz_id', true ); |
|
790 | - if( 0 < intval( $quiz_id ) ) { |
|
791 | - add_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $quiz_id . '0000', true ); |
|
789 | + $quiz_id = get_post_meta($question->ID, '_quiz_id', true); |
|
790 | + if (0 < intval($quiz_id)) { |
|
791 | + add_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $quiz_id.'0000', true); |
|
792 | 792 | } |
793 | 793 | } |
794 | 794 | return true; |
@@ -800,33 +800,33 @@ discard block |
||
800 | 800 | * @since 1.5.0 |
801 | 801 | * @return boolean |
802 | 802 | */ |
803 | - public function set_random_question_order( $n = 50, $offset = 0 ) { |
|
803 | + public function set_random_question_order($n = 50, $offset = 0) { |
|
804 | 804 | |
805 | 805 | // Get Total Number of Updates to run |
806 | - $quiz_count_object = wp_count_posts( 'quiz' ); |
|
806 | + $quiz_count_object = wp_count_posts('quiz'); |
|
807 | 807 | $quiz_count_published = $quiz_count_object->publish; |
808 | 808 | |
809 | 809 | // Calculate if this is the last page |
810 | - if ( 0 == $offset ) { |
|
810 | + if (0 == $offset) { |
|
811 | 811 | $current_page = 1; |
812 | 812 | } else { |
813 | - $current_page = intval( $offset / $n ); |
|
813 | + $current_page = intval($offset / $n); |
|
814 | 814 | } // End If Statement |
815 | - $total_pages = intval( $quiz_count_published / $n ); |
|
815 | + $total_pages = intval($quiz_count_published / $n); |
|
816 | 816 | |
817 | - $args = array( 'post_type' => 'quiz', |
|
817 | + $args = array('post_type' => 'quiz', |
|
818 | 818 | 'post_status' => 'any', |
819 | 819 | 'posts_per_page' => $n, |
820 | 820 | 'offset' => $offset, |
821 | 821 | 'suppress_filters' => 0 |
822 | 822 | ); |
823 | - $quizzes = get_posts( $args ); |
|
823 | + $quizzes = get_posts($args); |
|
824 | 824 | |
825 | - foreach( $quizzes as $quiz ) { |
|
826 | - update_post_meta( $quiz->ID, '_random_question_order', 'yes' ); |
|
825 | + foreach ($quizzes as $quiz) { |
|
826 | + update_post_meta($quiz->ID, '_random_question_order', 'yes'); |
|
827 | 827 | } |
828 | 828 | |
829 | - if ( $current_page == $total_pages ) { |
|
829 | + if ($current_page == $total_pages) { |
|
830 | 830 | return true; |
831 | 831 | } else { |
832 | 832 | return false; |
@@ -840,37 +840,37 @@ discard block |
||
840 | 840 | * @since 1.5.0 |
841 | 841 | * @return boolean |
842 | 842 | */ |
843 | - public function set_default_show_question_count( $n = 50, $offset = 0 ) { |
|
843 | + public function set_default_show_question_count($n = 50, $offset = 0) { |
|
844 | 844 | |
845 | - $args = array( 'post_type' => 'quiz', |
|
845 | + $args = array('post_type' => 'quiz', |
|
846 | 846 | 'post_status' => 'any', |
847 | 847 | 'posts_per_page' => $n, |
848 | 848 | 'offset' => $offset, |
849 | 849 | 'meta_key' => '_show_questions', |
850 | 850 | 'suppress_filters' => 0 |
851 | 851 | ); |
852 | - $quizzes = get_posts( $args ); |
|
852 | + $quizzes = get_posts($args); |
|
853 | 853 | |
854 | - $total_quizzes = count( $quizzes ); |
|
854 | + $total_quizzes = count($quizzes); |
|
855 | 855 | |
856 | - if( 0 == intval( $total_quizzes ) ) { |
|
856 | + if (0 == intval($total_quizzes)) { |
|
857 | 857 | return true; |
858 | 858 | } |
859 | 859 | |
860 | - foreach( $quizzes as $quiz ) { |
|
861 | - delete_post_meta( $quiz->ID, '_show_questions' ); |
|
860 | + foreach ($quizzes as $quiz) { |
|
861 | + delete_post_meta($quiz->ID, '_show_questions'); |
|
862 | 862 | } |
863 | 863 | |
864 | - $total_pages = intval( $total_quizzes / $n ); |
|
864 | + $total_pages = intval($total_quizzes / $n); |
|
865 | 865 | |
866 | 866 | // Calculate if this is the last page |
867 | - if ( 0 == $offset ) { |
|
867 | + if (0 == $offset) { |
|
868 | 868 | $current_page = 1; |
869 | 869 | } else { |
870 | - $current_page = intval( $offset / $n ); |
|
870 | + $current_page = intval($offset / $n); |
|
871 | 871 | } // End If Statement |
872 | 872 | |
873 | - if ( $current_page == $total_pages ) { |
|
873 | + if ($current_page == $total_pages) { |
|
874 | 874 | return true; |
875 | 875 | } else { |
876 | 876 | return false; |
@@ -878,14 +878,14 @@ discard block |
||
878 | 878 | |
879 | 879 | } |
880 | 880 | |
881 | - public function remove_deleted_user_activity( $n = 50, $offset = 0 ) { |
|
881 | + public function remove_deleted_user_activity($n = 50, $offset = 0) { |
|
882 | 882 | |
883 | - $all_activity = get_comments( array( 'status' => 'approve' ) ); |
|
883 | + $all_activity = get_comments(array('status' => 'approve')); |
|
884 | 884 | $activity_count = array(); |
885 | - foreach( $all_activity as $activity ) { |
|
886 | - if( '' == $activity->comment_type ) continue; |
|
887 | - if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue; |
|
888 | - if( 0 == $activity->user_id ) continue; |
|
885 | + foreach ($all_activity as $activity) { |
|
886 | + if ('' == $activity->comment_type) continue; |
|
887 | + if (strpos('sensei_', $activity->comment_type) != 0) continue; |
|
888 | + if (0 == $activity->user_id) continue; |
|
889 | 889 | $activity_count[] = $activity->comment_ID; |
890 | 890 | } |
891 | 891 | |
@@ -895,33 +895,33 @@ discard block |
||
895 | 895 | 'status' => 'approve' |
896 | 896 | ); |
897 | 897 | |
898 | - $activities = get_comments( $args ); |
|
898 | + $activities = get_comments($args); |
|
899 | 899 | |
900 | - foreach( $activities as $activity ) { |
|
901 | - if( '' == $activity->comment_type ) continue; |
|
902 | - if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue; |
|
903 | - if( 0 == $activity->user_id ) continue; |
|
900 | + foreach ($activities as $activity) { |
|
901 | + if ('' == $activity->comment_type) continue; |
|
902 | + if (strpos('sensei_', $activity->comment_type) != 0) continue; |
|
903 | + if (0 == $activity->user_id) continue; |
|
904 | 904 | |
905 | - $user_exists = get_userdata( $activity->user_id ); |
|
905 | + $user_exists = get_userdata($activity->user_id); |
|
906 | 906 | |
907 | - if( ! $user_exists ) { |
|
908 | - wp_delete_comment( intval( $activity->comment_ID ), true ); |
|
907 | + if ( ! $user_exists) { |
|
908 | + wp_delete_comment(intval($activity->comment_ID), true); |
|
909 | 909 | wp_cache_flush(); |
910 | 910 | } |
911 | 911 | } |
912 | 912 | |
913 | - $total_activities = count( $activity_count ); |
|
913 | + $total_activities = count($activity_count); |
|
914 | 914 | |
915 | - $total_pages = intval( $total_activities / $n ); |
|
915 | + $total_pages = intval($total_activities / $n); |
|
916 | 916 | |
917 | 917 | // Calculate if this is the last page |
918 | - if ( 0 == $offset ) { |
|
918 | + if (0 == $offset) { |
|
919 | 919 | $current_page = 1; |
920 | 920 | } else { |
921 | - $current_page = intval( $offset / $n ); |
|
921 | + $current_page = intval($offset / $n); |
|
922 | 922 | } // End If Statement |
923 | 923 | |
924 | - if ( $current_page >= $total_pages ) { |
|
924 | + if ($current_page >= $total_pages) { |
|
925 | 925 | return true; |
926 | 926 | } else { |
927 | 927 | return false; |
@@ -930,16 +930,16 @@ discard block |
||
930 | 930 | } |
931 | 931 | |
932 | 932 | public function add_teacher_role() { |
933 | - add_role( 'teacher', __( 'Teacher', 'woothemes-sensei' ), array( 'read' => true, 'manage_sensei_grades' => true ) ); |
|
933 | + add_role('teacher', __('Teacher', 'woothemes-sensei'), array('read' => true, 'manage_sensei_grades' => true)); |
|
934 | 934 | return true; |
935 | 935 | } |
936 | 936 | |
937 | 937 | public function add_sensei_caps() { |
938 | - $role = get_role( 'administrator' ); |
|
938 | + $role = get_role('administrator'); |
|
939 | 939 | |
940 | - if( ! is_null( $role ) ) { |
|
941 | - $role->add_cap( 'manage_sensei' ); |
|
942 | - $role->add_cap( 'manage_sensei_grades' ); |
|
940 | + if ( ! is_null($role)) { |
|
941 | + $role->add_cap('manage_sensei'); |
|
942 | + $role->add_cap('manage_sensei_grades'); |
|
943 | 943 | } |
944 | 944 | |
945 | 945 | return true; |
@@ -953,16 +953,16 @@ discard block |
||
953 | 953 | 'suppress_filters' => 0 |
954 | 954 | ); |
955 | 955 | |
956 | - $questions = get_posts( $args ); |
|
956 | + $questions = get_posts($args); |
|
957 | 957 | |
958 | - foreach( $questions as $question ) { |
|
958 | + foreach ($questions as $question) { |
|
959 | 959 | |
960 | - if( ! isset( $question->ID ) ) continue; |
|
960 | + if ( ! isset($question->ID)) continue; |
|
961 | 961 | |
962 | - $quiz_id = get_post_meta( $question->ID, '_quiz_id', true ); |
|
962 | + $quiz_id = get_post_meta($question->ID, '_quiz_id', true); |
|
963 | 963 | |
964 | - $question_order = get_post_meta( $question->ID, '_quiz_question_order', true ); |
|
965 | - update_post_meta( $question->ID, '_quiz_question_order' . $quiz_id, $question_order ); |
|
964 | + $question_order = get_post_meta($question->ID, '_quiz_question_order', true); |
|
965 | + update_post_meta($question->ID, '_quiz_question_order'.$quiz_id, $question_order); |
|
966 | 966 | |
967 | 967 | } |
968 | 968 | |
@@ -971,15 +971,15 @@ discard block |
||
971 | 971 | |
972 | 972 | public function update_quiz_settings() { |
973 | 973 | |
974 | - $settings = get_option( 'woothemes-sensei-settings', array() ); |
|
974 | + $settings = get_option('woothemes-sensei-settings', array()); |
|
975 | 975 | |
976 | 976 | $lesson_completion = false; |
977 | - if( isset( $settings['lesson_completion'] ) ) { |
|
977 | + if (isset($settings['lesson_completion'])) { |
|
978 | 978 | $lesson_completion = $settings['lesson_completion']; |
979 | 979 | } |
980 | 980 | |
981 | 981 | $reset_quiz_allowed = false; |
982 | - if( isset( $settings['quiz_reset_allowed'] ) ) { |
|
982 | + if (isset($settings['quiz_reset_allowed'])) { |
|
983 | 983 | $reset_quiz_allowed = $settings['quiz_reset_allowed']; |
984 | 984 | } |
985 | 985 | |
@@ -990,20 +990,20 @@ discard block |
||
990 | 990 | 'suppress_filters' => 0 |
991 | 991 | ); |
992 | 992 | |
993 | - $quizzes = get_posts( $args ); |
|
993 | + $quizzes = get_posts($args); |
|
994 | 994 | |
995 | - foreach( $quizzes as $quiz ) { |
|
995 | + foreach ($quizzes as $quiz) { |
|
996 | 996 | |
997 | - if( ! isset( $quiz->ID ) ) continue; |
|
997 | + if ( ! isset($quiz->ID)) continue; |
|
998 | 998 | |
999 | - if( isset( $lesson_completion ) && 'passed' == $lesson_completion ) { |
|
1000 | - update_post_meta( $quiz->ID, '_pass_required', 'on' ); |
|
999 | + if (isset($lesson_completion) && 'passed' == $lesson_completion) { |
|
1000 | + update_post_meta($quiz->ID, '_pass_required', 'on'); |
|
1001 | 1001 | } else { |
1002 | - update_post_meta( $quiz->ID, '_quiz_passmark', 0 ); |
|
1002 | + update_post_meta($quiz->ID, '_quiz_passmark', 0); |
|
1003 | 1003 | } |
1004 | 1004 | |
1005 | - if( isset( $reset_quiz_allowed ) && $reset_quiz_allowed ) { |
|
1006 | - update_post_meta( $quiz->ID, '_enable_quiz_reset', 'on' ); |
|
1005 | + if (isset($reset_quiz_allowed) && $reset_quiz_allowed) { |
|
1006 | + update_post_meta($quiz->ID, '_enable_quiz_reset', 'on'); |
|
1007 | 1007 | } |
1008 | 1008 | } |
1009 | 1009 | |
@@ -1018,22 +1018,22 @@ discard block |
||
1018 | 1018 | 'suppress_filters' => 0 |
1019 | 1019 | ); |
1020 | 1020 | |
1021 | - $lessons = get_posts( $args ); |
|
1021 | + $lessons = get_posts($args); |
|
1022 | 1022 | |
1023 | - foreach( $lessons as $lesson ) { |
|
1023 | + foreach ($lessons as $lesson) { |
|
1024 | 1024 | |
1025 | - if( ! isset( $lesson->ID ) ) continue; |
|
1025 | + if ( ! isset($lesson->ID)) continue; |
|
1026 | 1026 | |
1027 | - $course_id = get_post_meta( $lesson->ID, '_lesson_course', true); |
|
1027 | + $course_id = get_post_meta($lesson->ID, '_lesson_course', true); |
|
1028 | 1028 | |
1029 | - if( $course_id ) { |
|
1030 | - update_post_meta( $lesson->ID, '_order_' . $course_id, 0 ); |
|
1029 | + if ($course_id) { |
|
1030 | + update_post_meta($lesson->ID, '_order_'.$course_id, 0); |
|
1031 | 1031 | } |
1032 | 1032 | |
1033 | - $module = Sensei()->modules->get_lesson_module( $lesson->ID ); |
|
1033 | + $module = Sensei()->modules->get_lesson_module($lesson->ID); |
|
1034 | 1034 | |
1035 | - if( $module ) { |
|
1036 | - update_post_meta( $lesson->ID, '_order_module_' . $module->term_id, 0 ); |
|
1035 | + if ($module) { |
|
1036 | + update_post_meta($lesson->ID, '_order_module_'.$module->term_id, 0); |
|
1037 | 1037 | } |
1038 | 1038 | |
1039 | 1039 | } |
@@ -1042,10 +1042,10 @@ discard block |
||
1042 | 1042 | } |
1043 | 1043 | |
1044 | 1044 | public function add_editor_caps() { |
1045 | - $role = get_role( 'editor' ); |
|
1045 | + $role = get_role('editor'); |
|
1046 | 1046 | |
1047 | - if( ! is_null( $role ) ) { |
|
1048 | - $role->add_cap( 'manage_sensei_grades' ); |
|
1047 | + if ( ! is_null($role)) { |
|
1048 | + $role->add_cap('manage_sensei_grades'); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | return true; |
@@ -1064,26 +1064,26 @@ discard block |
||
1064 | 1064 | WHERE m.meta_key = '_question_right_answer' AND m.meta_value LIKE '%|%' AND m.meta_value NOT LIKE '%||%' |
1065 | 1065 | AND m.post_id = tr.object_id AND tr.term_taxonomy_id = tt.term_taxonomy_id AND tt.term_id = t.term_id |
1066 | 1066 | AND tt.taxonomy = 'question-type' AND t.slug = 'gap-fill'"; |
1067 | - $wpdb->query( $sql ); |
|
1067 | + $wpdb->query($sql); |
|
1068 | 1068 | |
1069 | 1069 | return true; |
1070 | 1070 | } |
1071 | 1071 | |
1072 | - public function update_quiz_lesson_relationship( $n = 50, $offset = 0 ) { |
|
1073 | - $count_object = wp_count_posts( 'quiz' ); |
|
1072 | + public function update_quiz_lesson_relationship($n = 50, $offset = 0) { |
|
1073 | + $count_object = wp_count_posts('quiz'); |
|
1074 | 1074 | |
1075 | 1075 | $count_published = 0; |
1076 | - foreach ( $count_object AS $status => $count ) { |
|
1076 | + foreach ($count_object AS $status => $count) { |
|
1077 | 1077 | $count_published += $count; |
1078 | 1078 | } |
1079 | 1079 | |
1080 | 1080 | // Calculate if this is the last page |
1081 | - if ( 0 == $offset ) { |
|
1081 | + if (0 == $offset) { |
|
1082 | 1082 | $current_page = 1; |
1083 | 1083 | } else { |
1084 | - $current_page = intval( $offset / $n ); |
|
1084 | + $current_page = intval($offset / $n); |
|
1085 | 1085 | } |
1086 | - $total_pages = ceil( $count_published / $n ); |
|
1086 | + $total_pages = ceil($count_published / $n); |
|
1087 | 1087 | |
1088 | 1088 | $args = array( |
1089 | 1089 | 'post_type' => 'quiz', |
@@ -1092,52 +1092,52 @@ discard block |
||
1092 | 1092 | 'post_status' => 'any' |
1093 | 1093 | ); |
1094 | 1094 | |
1095 | - $quizzes = get_posts( $args ); |
|
1095 | + $quizzes = get_posts($args); |
|
1096 | 1096 | |
1097 | - foreach( $quizzes as $quiz ) { |
|
1097 | + foreach ($quizzes as $quiz) { |
|
1098 | 1098 | |
1099 | - if( ! isset( $quiz->ID ) || 0 != $quiz->post_parent ) continue; |
|
1099 | + if ( ! isset($quiz->ID) || 0 != $quiz->post_parent) continue; |
|
1100 | 1100 | |
1101 | - $lesson_id = get_post_meta( $quiz->ID, '_quiz_lesson', true ); |
|
1101 | + $lesson_id = get_post_meta($quiz->ID, '_quiz_lesson', true); |
|
1102 | 1102 | |
1103 | - if( empty( $lesson_id ) ) continue; |
|
1103 | + if (empty($lesson_id)) continue; |
|
1104 | 1104 | |
1105 | 1105 | $data = array( |
1106 | 1106 | 'ID' => $quiz->ID, |
1107 | 1107 | 'post_parent' => $lesson_id, |
1108 | 1108 | ); |
1109 | - wp_update_post( $data ); |
|
1109 | + wp_update_post($data); |
|
1110 | 1110 | |
1111 | - update_post_meta( $lesson_id, '_lesson_quiz', $quiz->ID ); |
|
1111 | + update_post_meta($lesson_id, '_lesson_quiz', $quiz->ID); |
|
1112 | 1112 | } |
1113 | 1113 | |
1114 | - if ( $current_page == $total_pages || 0 == $total_pages ) { |
|
1114 | + if ($current_page == $total_pages || 0 == $total_pages) { |
|
1115 | 1115 | return true; |
1116 | 1116 | } else { |
1117 | 1117 | return false; |
1118 | 1118 | } |
1119 | 1119 | } |
1120 | 1120 | |
1121 | - function status_changes_fix_lessons( $n = 50, $offset = 0 ) { |
|
1121 | + function status_changes_fix_lessons($n = 50, $offset = 0) { |
|
1122 | 1122 | global $wpdb; |
1123 | 1123 | |
1124 | - $count_object = wp_count_posts( 'lesson' ); |
|
1124 | + $count_object = wp_count_posts('lesson'); |
|
1125 | 1125 | $count_published = 0; |
1126 | - foreach ( $count_object AS $status => $count ) { |
|
1126 | + foreach ($count_object AS $status => $count) { |
|
1127 | 1127 | $count_published += $count; |
1128 | 1128 | } |
1129 | 1129 | |
1130 | - if ( 0 == $count_published ) { |
|
1130 | + if (0 == $count_published) { |
|
1131 | 1131 | return true; |
1132 | 1132 | } |
1133 | 1133 | |
1134 | 1134 | // Calculate if this is the last page |
1135 | - if ( 0 == $offset ) { |
|
1135 | + if (0 == $offset) { |
|
1136 | 1136 | $current_page = 1; |
1137 | 1137 | } else { |
1138 | - $current_page = intval( $offset / $n ); |
|
1138 | + $current_page = intval($offset / $n); |
|
1139 | 1139 | } |
1140 | - $total_pages = ceil( $count_published / $n ); |
|
1140 | + $total_pages = ceil($count_published / $n); |
|
1141 | 1141 | |
1142 | 1142 | // Get all Lessons with (and without) Quizzes... |
1143 | 1143 | $args = array( |
@@ -1147,26 +1147,26 @@ discard block |
||
1147 | 1147 | 'offset' => $offset, |
1148 | 1148 | 'fields' => 'ids' |
1149 | 1149 | ); |
1150 | - $lesson_ids = get_posts( $args ); |
|
1150 | + $lesson_ids = get_posts($args); |
|
1151 | 1151 | |
1152 | 1152 | // ...get all Quiz IDs for the above Lessons |
1153 | - $id_list = join( ',', $lesson_ids ); |
|
1154 | - $meta_list = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A ); |
|
1153 | + $id_list = join(',', $lesson_ids); |
|
1154 | + $meta_list = $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A); |
|
1155 | 1155 | $lesson_quiz_ids = array(); |
1156 | - if ( !empty($meta_list) ) { |
|
1157 | - foreach ( $meta_list as $metarow ) { |
|
1156 | + if ( ! empty($meta_list)) { |
|
1157 | + foreach ($meta_list as $metarow) { |
|
1158 | 1158 | $lesson_id = $metarow['meta_value']; |
1159 | 1159 | $quiz_id = $metarow['post_id']; |
1160 | - $lesson_quiz_ids[ $lesson_id ] = $quiz_id; |
|
1160 | + $lesson_quiz_ids[$lesson_id] = $quiz_id; |
|
1161 | 1161 | } |
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | // ...check all Quiz IDs for questions |
1165 | - $id_list = join( ',', array_values($lesson_quiz_ids) ); |
|
1166 | - $meta_list = $wpdb->get_results( "SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A ); |
|
1165 | + $id_list = join(',', array_values($lesson_quiz_ids)); |
|
1166 | + $meta_list = $wpdb->get_results("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_id' AND meta_value IN ($id_list)", ARRAY_A); |
|
1167 | 1167 | $lesson_quiz_ids_with_questions = array(); |
1168 | - if ( !empty($meta_list) ) { |
|
1169 | - foreach ( $meta_list as $metarow ) { |
|
1168 | + if ( ! empty($meta_list)) { |
|
1169 | + foreach ($meta_list as $metarow) { |
|
1170 | 1170 | $quiz_id = $metarow['meta_value']; |
1171 | 1171 | $lesson_quiz_ids_with_questions[] = $quiz_id; |
1172 | 1172 | } |
@@ -1174,49 +1174,49 @@ discard block |
||
1174 | 1174 | |
1175 | 1175 | // For each quiz check there are questions, if not remove the corresponding meta keys from Quizzes and Lessons |
1176 | 1176 | // if there are questions on the quiz add the corresponding meta keys to Quizzes and Lessons |
1177 | - $d_count = $a_count =0; |
|
1178 | - foreach ( $lesson_quiz_ids AS $lesson_id => $quiz_id ) { |
|
1179 | - if ( !in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) { |
|
1177 | + $d_count = $a_count = 0; |
|
1178 | + foreach ($lesson_quiz_ids AS $lesson_id => $quiz_id) { |
|
1179 | + if ( ! in_array($quiz_id, $lesson_quiz_ids_with_questions)) { |
|
1180 | 1180 | |
1181 | 1181 | // Quiz has no questions, drop the corresponding data |
1182 | - delete_post_meta( $quiz_id, '_pass_required' ); |
|
1183 | - delete_post_meta( $quiz_id, '_quiz_passmark' ); |
|
1184 | - delete_post_meta( $lesson_id, '_quiz_has_questions' ); |
|
1182 | + delete_post_meta($quiz_id, '_pass_required'); |
|
1183 | + delete_post_meta($quiz_id, '_quiz_passmark'); |
|
1184 | + delete_post_meta($lesson_id, '_quiz_has_questions'); |
|
1185 | 1185 | $d_count++; |
1186 | 1186 | } |
1187 | - else if ( in_array( $quiz_id, $lesson_quiz_ids_with_questions ) ) { |
|
1187 | + else if (in_array($quiz_id, $lesson_quiz_ids_with_questions)) { |
|
1188 | 1188 | |
1189 | 1189 | // Quiz has no questions, drop the corresponding data |
1190 | - update_post_meta( $lesson_id, '_quiz_has_questions', true ); |
|
1190 | + update_post_meta($lesson_id, '_quiz_has_questions', true); |
|
1191 | 1191 | $a_count++; |
1192 | 1192 | } |
1193 | 1193 | } |
1194 | 1194 | |
1195 | - if ( $current_page == $total_pages ) { |
|
1195 | + if ($current_page == $total_pages) { |
|
1196 | 1196 | return true; |
1197 | 1197 | } else { |
1198 | 1198 | return false; |
1199 | 1199 | } |
1200 | 1200 | } |
1201 | 1201 | |
1202 | - function status_changes_convert_lessons( $n = 50, $offset = 0 ) { |
|
1202 | + function status_changes_convert_lessons($n = 50, $offset = 0) { |
|
1203 | 1203 | global $wpdb; |
1204 | 1204 | |
1205 | - wp_defer_comment_counting( true ); |
|
1205 | + wp_defer_comment_counting(true); |
|
1206 | 1206 | |
1207 | - $user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " ); |
|
1207 | + $user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users "); |
|
1208 | 1208 | |
1209 | - if ( 0 == $user_count_result ) { |
|
1209 | + if (0 == $user_count_result) { |
|
1210 | 1210 | return true; |
1211 | 1211 | } |
1212 | 1212 | |
1213 | - if ( 0 == $offset ) { |
|
1213 | + if (0 == $offset) { |
|
1214 | 1214 | $current_page = 1; |
1215 | 1215 | } else { |
1216 | - $current_page = intval( $offset / $n ); |
|
1216 | + $current_page = intval($offset / $n); |
|
1217 | 1217 | } |
1218 | 1218 | |
1219 | - $total_pages = ceil( $user_count_result / $n ); |
|
1219 | + $total_pages = ceil($user_count_result / $n); |
|
1220 | 1220 | |
1221 | 1221 | // Get all Lessons with Quizzes... |
1222 | 1222 | $args = array( |
@@ -1231,34 +1231,34 @@ discard block |
||
1231 | 1231 | ), |
1232 | 1232 | 'fields' => 'ids' |
1233 | 1233 | ); |
1234 | - $lesson_ids_with_quizzes = get_posts( $args ); |
|
1234 | + $lesson_ids_with_quizzes = get_posts($args); |
|
1235 | 1235 | // ...get all Quiz IDs for the above Lessons |
1236 | - $id_list = join( ',', $lesson_ids_with_quizzes ); |
|
1237 | - $meta_list = $wpdb->get_results( "SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A ); |
|
1236 | + $id_list = join(',', $lesson_ids_with_quizzes); |
|
1237 | + $meta_list = $wpdb->get_results("SELECT post_id, meta_value FROM $wpdb->postmeta WHERE meta_key = '_quiz_lesson' AND meta_value IN ($id_list)", ARRAY_A); |
|
1238 | 1238 | $lesson_quiz_ids = array(); |
1239 | - if ( !empty($meta_list) ) { |
|
1240 | - foreach ( $meta_list as $metarow ) { |
|
1239 | + if ( ! empty($meta_list)) { |
|
1240 | + foreach ($meta_list as $metarow) { |
|
1241 | 1241 | $lesson_id = $metarow['meta_value']; |
1242 | 1242 | $quiz_id = $metarow['post_id']; |
1243 | - $lesson_quiz_ids[ $lesson_id ] = $quiz_id; |
|
1243 | + $lesson_quiz_ids[$lesson_id] = $quiz_id; |
|
1244 | 1244 | } |
1245 | 1245 | } |
1246 | 1246 | |
1247 | 1247 | // ...get all Pass Required & Passmarks for the above Lesson/Quizzes |
1248 | - $id_list = join( ',', array_values($lesson_quiz_ids) ); |
|
1249 | - $meta_list = $wpdb->get_results( "SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE ( meta_key = '_pass_required' OR meta_key = '_quiz_passmark' ) AND post_id IN ($id_list)", ARRAY_A ); |
|
1248 | + $id_list = join(',', array_values($lesson_quiz_ids)); |
|
1249 | + $meta_list = $wpdb->get_results("SELECT post_id, meta_key, meta_value FROM $wpdb->postmeta WHERE ( meta_key = '_pass_required' OR meta_key = '_quiz_passmark' ) AND post_id IN ($id_list)", ARRAY_A); |
|
1250 | 1250 | $quizzes_pass_required = $quizzes_passmarks = array(); |
1251 | - if ( !empty($meta_list) ) { |
|
1252 | - foreach ( $meta_list as $metarow ) { |
|
1253 | - if ( !empty($metarow['meta_value']) ) { |
|
1251 | + if ( ! empty($meta_list)) { |
|
1252 | + foreach ($meta_list as $metarow) { |
|
1253 | + if ( ! empty($metarow['meta_value'])) { |
|
1254 | 1254 | $quiz_id = $metarow['post_id']; |
1255 | 1255 | $key = $metarow['meta_key']; |
1256 | 1256 | $value = $metarow['meta_value']; |
1257 | - if ( '_pass_required' == $key ) { |
|
1258 | - $quizzes_pass_required[ $quiz_id ] = $value; |
|
1257 | + if ('_pass_required' == $key) { |
|
1258 | + $quizzes_pass_required[$quiz_id] = $value; |
|
1259 | 1259 | } |
1260 | - if ( '_quiz_passmark' == $key ) { |
|
1261 | - $quizzes_passmarks[ $quiz_id ] = $value; |
|
1260 | + if ('_quiz_passmark' == $key) { |
|
1261 | + $quizzes_passmarks[$quiz_id] = $value; |
|
1262 | 1262 | } |
1263 | 1263 | } |
1264 | 1264 | } |
@@ -1272,41 +1272,41 @@ discard block |
||
1272 | 1272 | $check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_lesson_status' "; |
1273 | 1273 | |
1274 | 1274 | // $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time? |
1275 | - $user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) ); |
|
1275 | + $user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset)); |
|
1276 | 1276 | |
1277 | - foreach ( $user_ids AS $user_id ) { |
|
1277 | + foreach ($user_ids AS $user_id) { |
|
1278 | 1278 | |
1279 | 1279 | $lesson_ends = $lesson_grades = $lesson_answers = array(); |
1280 | 1280 | |
1281 | 1281 | // Pre-process the lesson ends |
1282 | - $_lesson_ends = $wpdb->get_results( $wpdb->prepare($end_sql, $user_id), ARRAY_A ); |
|
1283 | - foreach ( $_lesson_ends as $lesson_end ) { |
|
1282 | + $_lesson_ends = $wpdb->get_results($wpdb->prepare($end_sql, $user_id), ARRAY_A); |
|
1283 | + foreach ($_lesson_ends as $lesson_end) { |
|
1284 | 1284 | // This will overwrite existing entries with the newer ones |
1285 | - $lesson_ends[ $lesson_end['comment_post_ID'] ] = $lesson_end['comment_date']; |
|
1285 | + $lesson_ends[$lesson_end['comment_post_ID']] = $lesson_end['comment_date']; |
|
1286 | 1286 | } |
1287 | - unset( $_lesson_ends ); |
|
1287 | + unset($_lesson_ends); |
|
1288 | 1288 | |
1289 | 1289 | // Pre-process the lesson grades |
1290 | - $_lesson_grades = $wpdb->get_results( $wpdb->prepare($grade_sql, $user_id), ARRAY_A ); |
|
1291 | - foreach ( $_lesson_grades as $lesson_grade ) { |
|
1290 | + $_lesson_grades = $wpdb->get_results($wpdb->prepare($grade_sql, $user_id), ARRAY_A); |
|
1291 | + foreach ($_lesson_grades as $lesson_grade) { |
|
1292 | 1292 | // This will overwrite existing entries with the newer ones (assuming the grade is higher) |
1293 | - if ( empty($lesson_grades[ $lesson_grade['comment_post_ID'] ]) || $lesson_grades[ $lesson_grade['comment_post_ID'] ] < $lesson_grade['comment_content'] ) { |
|
1294 | - $lesson_grades[ $lesson_grade['comment_post_ID'] ] = $lesson_grade['comment_content']; |
|
1293 | + if (empty($lesson_grades[$lesson_grade['comment_post_ID']]) || $lesson_grades[$lesson_grade['comment_post_ID']] < $lesson_grade['comment_content']) { |
|
1294 | + $lesson_grades[$lesson_grade['comment_post_ID']] = $lesson_grade['comment_content']; |
|
1295 | 1295 | } |
1296 | 1296 | } |
1297 | - unset( $_lesson_grades ); |
|
1297 | + unset($_lesson_grades); |
|
1298 | 1298 | |
1299 | 1299 | // Pre-process the lesson answers |
1300 | - $_lesson_answers = $wpdb->get_results( $wpdb->prepare($answers_sql, $user_id), ARRAY_A ); |
|
1301 | - foreach ( $_lesson_answers as $lesson_answer ) { |
|
1300 | + $_lesson_answers = $wpdb->get_results($wpdb->prepare($answers_sql, $user_id), ARRAY_A); |
|
1301 | + foreach ($_lesson_answers as $lesson_answer) { |
|
1302 | 1302 | // This will overwrite existing entries with the newer ones |
1303 | - $lesson_answers[ $lesson_answer['comment_post_ID'] ] = $lesson_answer['comment_content']; |
|
1303 | + $lesson_answers[$lesson_answer['comment_post_ID']] = $lesson_answer['comment_content']; |
|
1304 | 1304 | } |
1305 | - unset( $_lesson_answers ); |
|
1305 | + unset($_lesson_answers); |
|
1306 | 1306 | |
1307 | 1307 | // Grab all the lesson starts for the user |
1308 | - $lesson_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A ); |
|
1309 | - foreach ( $lesson_starts as $lesson_log ) { |
|
1308 | + $lesson_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A); |
|
1309 | + foreach ($lesson_starts as $lesson_log) { |
|
1310 | 1310 | |
1311 | 1311 | $lesson_id = $lesson_log['comment_post_ID']; |
1312 | 1312 | |
@@ -1319,23 +1319,23 @@ discard block |
||
1319 | 1319 | 'start' => $status_date, |
1320 | 1320 | ); |
1321 | 1321 | // Check if there is a lesson end |
1322 | - if ( !empty($lesson_ends[$lesson_id]) ) { |
|
1322 | + if ( ! empty($lesson_ends[$lesson_id])) { |
|
1323 | 1323 | $status_date = $lesson_ends[$lesson_id]; |
1324 | 1324 | // Check lesson has quiz |
1325 | - if ( !empty( $lesson_quiz_ids[$lesson_id] ) ) { |
|
1325 | + if ( ! empty($lesson_quiz_ids[$lesson_id])) { |
|
1326 | 1326 | // Check for the quiz answers |
1327 | - if ( !empty($lesson_answers[$quiz_id]) ) { |
|
1327 | + if ( ! empty($lesson_answers[$quiz_id])) { |
|
1328 | 1328 | $meta_data['questions_asked'] = $lesson_answers[$quiz_id]; |
1329 | 1329 | } |
1330 | 1330 | // Check if there is a quiz grade |
1331 | 1331 | $quiz_id = $lesson_quiz_ids[$lesson_id]; |
1332 | - if ( !empty($lesson_grades[$quiz_id]) ) { |
|
1332 | + if ( ! empty($lesson_grades[$quiz_id])) { |
|
1333 | 1333 | $meta_data['grade'] = $quiz_grade = $lesson_grades[$quiz_id]; |
1334 | 1334 | // Check if the user has to get the passmark and has or not |
1335 | - if ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] <= $quiz_grade ) { |
|
1335 | + if ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] <= $quiz_grade) { |
|
1336 | 1336 | $status = 'passed'; |
1337 | 1337 | } |
1338 | - elseif ( !empty( $quizzes_pass_required[$quiz_id] ) && $quizzes_passmarks[$quiz_id] > $quiz_grade ) { |
|
1338 | + elseif ( ! empty($quizzes_pass_required[$quiz_id]) && $quizzes_passmarks[$quiz_id] > $quiz_grade) { |
|
1339 | 1339 | $status = 'failed'; |
1340 | 1340 | } |
1341 | 1341 | else { |
@@ -1363,26 +1363,26 @@ discard block |
||
1363 | 1363 | 'comment_author' => '', |
1364 | 1364 | ); |
1365 | 1365 | // Check it doesn't already exist |
1366 | - $sql = $wpdb->prepare( $check_existing_sql, $lesson_id, $user_id ); |
|
1367 | - $comment_ID = $wpdb->get_var( $sql ); |
|
1368 | - if ( !$comment_ID ) { |
|
1366 | + $sql = $wpdb->prepare($check_existing_sql, $lesson_id, $user_id); |
|
1367 | + $comment_ID = $wpdb->get_var($sql); |
|
1368 | + if ( ! $comment_ID) { |
|
1369 | 1369 | // Bypassing WP wp_insert_comment( $data ), so no actions/filters are run |
1370 | 1370 | $wpdb->insert($wpdb->comments, $data); |
1371 | 1371 | $comment_ID = (int) $wpdb->insert_id; |
1372 | 1372 | |
1373 | - if ( $comment_ID && !empty($meta_data) ) { |
|
1374 | - foreach ( $meta_data as $key => $value ) { |
|
1373 | + if ($comment_ID && ! empty($meta_data)) { |
|
1374 | + foreach ($meta_data as $key => $value) { |
|
1375 | 1375 | // Bypassing WP add_comment_meta(() so no actions/filters are run |
1376 | - if ( $wpdb->get_var( $wpdb->prepare( |
|
1376 | + if ($wpdb->get_var($wpdb->prepare( |
|
1377 | 1377 | "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ", |
1378 | - $comment_ID, $key ) ) ) { |
|
1378 | + $comment_ID, $key ))) { |
|
1379 | 1379 | continue; // Found the meta data already |
1380 | 1380 | } |
1381 | - $result = $wpdb->insert( $wpdb->commentmeta, array( |
|
1381 | + $result = $wpdb->insert($wpdb->commentmeta, array( |
|
1382 | 1382 | 'comment_id' => $comment_ID, |
1383 | 1383 | 'meta_key' => $key, |
1384 | 1384 | 'meta_value' => $value |
1385 | - ) ); |
|
1385 | + )); |
|
1386 | 1386 | } |
1387 | 1387 | } |
1388 | 1388 | } |
@@ -1390,40 +1390,40 @@ discard block |
||
1390 | 1390 | } |
1391 | 1391 | $wpdb->flush(); |
1392 | 1392 | |
1393 | - if ( $current_page == $total_pages ) { |
|
1393 | + if ($current_page == $total_pages) { |
|
1394 | 1394 | return true; |
1395 | 1395 | } else { |
1396 | 1396 | return false; |
1397 | 1397 | } |
1398 | 1398 | } |
1399 | 1399 | |
1400 | - function status_changes_convert_courses( $n = 50, $offset = 0 ) { |
|
1400 | + function status_changes_convert_courses($n = 50, $offset = 0) { |
|
1401 | 1401 | global $wpdb; |
1402 | 1402 | |
1403 | - wp_defer_comment_counting( true ); |
|
1403 | + wp_defer_comment_counting(true); |
|
1404 | 1404 | |
1405 | - $user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " ); |
|
1405 | + $user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users "); |
|
1406 | 1406 | |
1407 | - if ( 0 == $user_count_result ) { |
|
1407 | + if (0 == $user_count_result) { |
|
1408 | 1408 | return true; |
1409 | 1409 | } |
1410 | 1410 | |
1411 | - if ( 0 == $offset ) { |
|
1411 | + if (0 == $offset) { |
|
1412 | 1412 | $current_page = 1; |
1413 | 1413 | } else { |
1414 | - $current_page = intval( $offset / $n ); |
|
1414 | + $current_page = intval($offset / $n); |
|
1415 | 1415 | } |
1416 | 1416 | |
1417 | - $total_pages = ceil( $user_count_result / $n ); |
|
1417 | + $total_pages = ceil($user_count_result / $n); |
|
1418 | 1418 | |
1419 | 1419 | // Get all Lesson => Course relationships |
1420 | - $meta_list = $wpdb->get_results( "SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course'", ARRAY_A ); |
|
1420 | + $meta_list = $wpdb->get_results("SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course'", ARRAY_A); |
|
1421 | 1421 | $course_lesson_ids = array(); |
1422 | - if ( !empty($meta_list) ) { |
|
1423 | - foreach ( $meta_list as $metarow ) { |
|
1422 | + if ( ! empty($meta_list)) { |
|
1423 | + foreach ($meta_list as $metarow) { |
|
1424 | 1424 | $lesson_id = $metarow['post_id']; |
1425 | 1425 | $course_id = $metarow['meta_value']; |
1426 | - $course_lesson_ids[ $course_id ][] = $lesson_id; |
|
1426 | + $course_lesson_ids[$course_id][] = $lesson_id; |
|
1427 | 1427 | } |
1428 | 1428 | } |
1429 | 1429 | |
@@ -1433,13 +1433,13 @@ discard block |
||
1433 | 1433 | $check_existing_sql = "SELECT comment_ID FROM $wpdb->comments WHERE comment_post_ID = %d AND user_id = %d AND comment_type = 'sensei_course_status' "; |
1434 | 1434 | |
1435 | 1435 | // $per_page users at a time, could be batch run via an admin ajax command, 1 user at a time? |
1436 | - $user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) ); |
|
1436 | + $user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset)); |
|
1437 | 1437 | |
1438 | - foreach ( $user_ids AS $user_id ) { |
|
1438 | + foreach ($user_ids AS $user_id) { |
|
1439 | 1439 | |
1440 | 1440 | // Grab all the course starts for the user |
1441 | - $course_starts = $wpdb->get_results( $wpdb->prepare($start_sql, $user_id), ARRAY_A ); |
|
1442 | - foreach ( $course_starts as $course_log ) { |
|
1441 | + $course_starts = $wpdb->get_results($wpdb->prepare($start_sql, $user_id), ARRAY_A); |
|
1442 | + foreach ($course_starts as $course_log) { |
|
1443 | 1443 | |
1444 | 1444 | $course_id = $course_log['comment_post_ID']; |
1445 | 1445 | |
@@ -1454,23 +1454,23 @@ discard block |
||
1454 | 1454 | 'percent' => 0, |
1455 | 1455 | ); |
1456 | 1456 | // Check if the course has lessons |
1457 | - if ( !empty( $course_lesson_ids[$course_id] ) ) { |
|
1457 | + if ( ! empty($course_lesson_ids[$course_id])) { |
|
1458 | 1458 | |
1459 | 1459 | $lessons_completed = 0; |
1460 | - $total_lessons = count( $course_lesson_ids[ $course_id ] ); |
|
1460 | + $total_lessons = count($course_lesson_ids[$course_id]); |
|
1461 | 1461 | |
1462 | 1462 | // Don't use prepare as we need to provide the id join |
1463 | - $sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[ $course_id ]) ); |
|
1463 | + $sql = sprintf($lessons_sql, $user_id, join(', ', $course_lesson_ids[$course_id])); |
|
1464 | 1464 | // Get all lesson statuses for this Courses' lessons |
1465 | - $lesson_statuses = $wpdb->get_results( $sql, ARRAY_A ); |
|
1465 | + $lesson_statuses = $wpdb->get_results($sql, ARRAY_A); |
|
1466 | 1466 | // Not enough lesson statuses, thus cannot be complete |
1467 | - if ( $total_lessons > count($lesson_statuses) ) { |
|
1467 | + if ($total_lessons > count($lesson_statuses)) { |
|
1468 | 1468 | $status = 'in-progress'; |
1469 | 1469 | } |
1470 | 1470 | // Count each lesson to work out the overall percentage |
1471 | - foreach ( $lesson_statuses as $lesson_status ) { |
|
1471 | + foreach ($lesson_statuses as $lesson_status) { |
|
1472 | 1472 | $status_date = $lesson_status['comment_date']; |
1473 | - switch ( $lesson_status['status'] ) { |
|
1473 | + switch ($lesson_status['status']) { |
|
1474 | 1474 | case 'complete': // Lesson has no quiz/questions |
1475 | 1475 | case 'graded': // Lesson has quiz, but it's not important what the grade was |
1476 | 1476 | case 'passed': |
@@ -1485,7 +1485,7 @@ discard block |
||
1485 | 1485 | } |
1486 | 1486 | } |
1487 | 1487 | $meta_data['complete'] = $lessons_completed; |
1488 | - $meta_data['percent'] = abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) ); |
|
1488 | + $meta_data['percent'] = abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0)); |
|
1489 | 1489 | } |
1490 | 1490 | else { |
1491 | 1491 | // Course has no lessons, therefore cannot be 'complete' |
@@ -1502,26 +1502,26 @@ discard block |
||
1502 | 1502 | 'comment_author' => '', |
1503 | 1503 | ); |
1504 | 1504 | // Check it doesn't already exist |
1505 | - $sql = $wpdb->prepare( $check_existing_sql, $course_id, $user_id ); |
|
1506 | - $comment_ID = $wpdb->get_var( $sql ); |
|
1507 | - if ( !$comment_ID ) { |
|
1505 | + $sql = $wpdb->prepare($check_existing_sql, $course_id, $user_id); |
|
1506 | + $comment_ID = $wpdb->get_var($sql); |
|
1507 | + if ( ! $comment_ID) { |
|
1508 | 1508 | // Bypassing WP wp_insert_comment( $data ), so no actions/filters are run |
1509 | 1509 | $wpdb->insert($wpdb->comments, $data); |
1510 | 1510 | $comment_ID = (int) $wpdb->insert_id; |
1511 | 1511 | |
1512 | - if ( $comment_ID && !empty($meta_data) ) { |
|
1513 | - foreach ( $meta_data as $key => $value ) { |
|
1512 | + if ($comment_ID && ! empty($meta_data)) { |
|
1513 | + foreach ($meta_data as $key => $value) { |
|
1514 | 1514 | // Bypassing WP wp_insert_comment( $data ), so no actions/filters are run |
1515 | - if ( $wpdb->get_var( $wpdb->prepare( |
|
1515 | + if ($wpdb->get_var($wpdb->prepare( |
|
1516 | 1516 | "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ", |
1517 | - $comment_ID, $key ) ) ) { |
|
1517 | + $comment_ID, $key ))) { |
|
1518 | 1518 | continue; // Found the meta data already |
1519 | 1519 | } |
1520 | - $result = $wpdb->insert( $wpdb->commentmeta, array( |
|
1520 | + $result = $wpdb->insert($wpdb->commentmeta, array( |
|
1521 | 1521 | 'comment_id' => $comment_ID, |
1522 | 1522 | 'meta_key' => $key, |
1523 | 1523 | 'meta_value' => $value |
1524 | - ) ); |
|
1524 | + )); |
|
1525 | 1525 | } |
1526 | 1526 | } |
1527 | 1527 | } |
@@ -1529,7 +1529,7 @@ discard block |
||
1529 | 1529 | } |
1530 | 1530 | $wpdb->flush(); |
1531 | 1531 | |
1532 | - if ( $current_page == $total_pages ) { |
|
1532 | + if ($current_page == $total_pages) { |
|
1533 | 1533 | return true; |
1534 | 1534 | } else { |
1535 | 1535 | return false; |
@@ -1545,70 +1545,70 @@ discard block |
||
1545 | 1545 | * @param type $offset |
1546 | 1546 | * @return boolean |
1547 | 1547 | */ |
1548 | - function status_changes_repair_course_statuses( $n = 50, $offset = 0 ) { |
|
1548 | + function status_changes_repair_course_statuses($n = 50, $offset = 0) { |
|
1549 | 1549 | global $wpdb; |
1550 | 1550 | |
1551 | - $count_object = wp_count_posts( 'lesson' ); |
|
1551 | + $count_object = wp_count_posts('lesson'); |
|
1552 | 1552 | $count_published = $count_object->publish; |
1553 | 1553 | |
1554 | - if ( 0 == $count_published ) { |
|
1554 | + if (0 == $count_published) { |
|
1555 | 1555 | return true; |
1556 | 1556 | } |
1557 | 1557 | |
1558 | 1558 | // Calculate if this is the last page |
1559 | - if ( 0 == $offset ) { |
|
1559 | + if (0 == $offset) { |
|
1560 | 1560 | $current_page = 1; |
1561 | 1561 | } else { |
1562 | - $current_page = intval( $offset / $n ); |
|
1562 | + $current_page = intval($offset / $n); |
|
1563 | 1563 | } |
1564 | - $total_pages = ceil( $count_published / $n ); |
|
1564 | + $total_pages = ceil($count_published / $n); |
|
1565 | 1565 | |
1566 | 1566 | $course_lesson_ids = $lesson_user_statuses = array(); |
1567 | 1567 | |
1568 | 1568 | // Get all Lesson => Course relationships |
1569 | - $meta_list = $wpdb->get_results( "SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course' LIMIT $n OFFSET $offset ", ARRAY_A ); |
|
1570 | - if ( !empty($meta_list) ) { |
|
1571 | - foreach ( $meta_list as $metarow ) { |
|
1569 | + $meta_list = $wpdb->get_results("SELECT $wpdb->postmeta.post_id, $wpdb->postmeta.meta_value FROM $wpdb->postmeta INNER JOIN $wpdb->posts ON ($wpdb->posts.ID = $wpdb->postmeta.post_id) WHERE $wpdb->posts.post_type = 'lesson' AND $wpdb->postmeta.meta_key = '_lesson_course' LIMIT $n OFFSET $offset ", ARRAY_A); |
|
1570 | + if ( ! empty($meta_list)) { |
|
1571 | + foreach ($meta_list as $metarow) { |
|
1572 | 1572 | $lesson_id = $metarow['post_id']; |
1573 | 1573 | $course_id = $metarow['meta_value']; |
1574 | - $course_lesson_ids[ $course_id ][] = $lesson_id; |
|
1574 | + $course_lesson_ids[$course_id][] = $lesson_id; |
|
1575 | 1575 | } |
1576 | 1576 | } |
1577 | 1577 | |
1578 | 1578 | // Get all Lesson => Course relationships |
1579 | - $status_list = $wpdb->get_results( "SELECT user_id, comment_post_ID, comment_approved FROM $wpdb->comments WHERE comment_type = 'sensei_lesson_status' GROUP BY user_id, comment_post_ID ", ARRAY_A ); |
|
1580 | - if ( !empty($status_list) ) { |
|
1581 | - foreach ( $status_list as $status ) { |
|
1582 | - $lesson_user_statuses[ $status['comment_post_ID'] ][ $status['user_id'] ] = $status['comment_approved']; |
|
1579 | + $status_list = $wpdb->get_results("SELECT user_id, comment_post_ID, comment_approved FROM $wpdb->comments WHERE comment_type = 'sensei_lesson_status' GROUP BY user_id, comment_post_ID ", ARRAY_A); |
|
1580 | + if ( ! empty($status_list)) { |
|
1581 | + foreach ($status_list as $status) { |
|
1582 | + $lesson_user_statuses[$status['comment_post_ID']][$status['user_id']] = $status['comment_approved']; |
|
1583 | 1583 | } |
1584 | 1584 | } |
1585 | 1585 | |
1586 | - $course_completion = Sensei()->settings->settings[ 'course_completion' ]; |
|
1586 | + $course_completion = Sensei()->settings->settings['course_completion']; |
|
1587 | 1587 | |
1588 | 1588 | $per_page = 40; |
1589 | 1589 | $comment_id_offset = $count = 0; |
1590 | 1590 | |
1591 | 1591 | $course_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_course_status' AND comment_ID > %d LIMIT $per_page"; |
1592 | 1592 | // $per_page users at a time |
1593 | - while ( $course_statuses = $wpdb->get_results( $wpdb->prepare($course_sql, $comment_id_offset) ) ) { |
|
1593 | + while ($course_statuses = $wpdb->get_results($wpdb->prepare($course_sql, $comment_id_offset))) { |
|
1594 | 1594 | |
1595 | - foreach ( $course_statuses AS $course_status ) { |
|
1595 | + foreach ($course_statuses AS $course_status) { |
|
1596 | 1596 | $user_id = $course_status->user_id; |
1597 | 1597 | $course_id = $course_status->comment_post_ID; |
1598 | - $total_lessons = count( $course_lesson_ids[ $course_id ] ); |
|
1599 | - if ( $total_lessons <= 0 ) { |
|
1598 | + $total_lessons = count($course_lesson_ids[$course_id]); |
|
1599 | + if ($total_lessons <= 0) { |
|
1600 | 1600 | $total_lessons = 1; // Fix division of zero error, some courses have no lessons |
1601 | 1601 | } |
1602 | 1602 | $lessons_completed = 0; |
1603 | 1603 | $status = 'in-progress'; |
1604 | 1604 | |
1605 | 1605 | // Some Courses have no lessons... (can they ever be complete?) |
1606 | - if ( !empty($course_lesson_ids[ $course_id ]) ) { |
|
1607 | - foreach( $course_lesson_ids[ $course_id ] AS $lesson_id ) { |
|
1608 | - $lesson_status = $lesson_user_statuses[ $lesson_id ][ $user_id ]; |
|
1606 | + if ( ! empty($course_lesson_ids[$course_id])) { |
|
1607 | + foreach ($course_lesson_ids[$course_id] AS $lesson_id) { |
|
1608 | + $lesson_status = $lesson_user_statuses[$lesson_id][$user_id]; |
|
1609 | 1609 | // If lessons are complete without needing quizzes to be passed |
1610 | - if ( 'passed' != $course_completion ) { |
|
1611 | - switch ( $lesson_status ) { |
|
1610 | + if ('passed' != $course_completion) { |
|
1611 | + switch ($lesson_status) { |
|
1612 | 1612 | // A user cannot 'complete' a course if a lesson... |
1613 | 1613 | case 'in-progress': // ...is still in progress |
1614 | 1614 | case 'ungraded': // ...hasn't yet been graded |
@@ -1620,7 +1620,7 @@ discard block |
||
1620 | 1620 | } |
1621 | 1621 | } |
1622 | 1622 | else { |
1623 | - switch ( $lesson_status ) { |
|
1623 | + switch ($lesson_status) { |
|
1624 | 1624 | case 'complete': // Lesson has no quiz/questions |
1625 | 1625 | case 'graded': // Lesson has quiz, but it's not important what the grade was |
1626 | 1626 | case 'passed': // Lesson has quiz and the user passed |
@@ -1635,79 +1635,79 @@ discard block |
||
1635 | 1635 | } |
1636 | 1636 | } // Each lesson |
1637 | 1637 | } // Check for lessons |
1638 | - if ( $lessons_completed == $total_lessons ) { |
|
1638 | + if ($lessons_completed == $total_lessons) { |
|
1639 | 1639 | $status = 'complete'; |
1640 | 1640 | } |
1641 | 1641 | // update the overall percentage of the course lessons complete (or graded) compared to 'in-progress' regardless of the above |
1642 | 1642 | $metadata = array( |
1643 | 1643 | 'complete' => $lessons_completed, |
1644 | - 'percent' => abs( round( ( doubleval( $lessons_completed ) * 100 ) / ( $total_lessons ), 0 ) ), |
|
1644 | + 'percent' => abs(round((doubleval($lessons_completed) * 100) / ($total_lessons), 0)), |
|
1645 | 1645 | ); |
1646 | - Sensei_Utils::update_course_status( $user_id, $course_id, $status, $metadata ); |
|
1646 | + Sensei_Utils::update_course_status($user_id, $course_id, $status, $metadata); |
|
1647 | 1647 | $count++; |
1648 | 1648 | |
1649 | 1649 | } // per course status |
1650 | 1650 | $comment_id_offset = $course_status->comment_ID; |
1651 | 1651 | } // all course statuses |
1652 | 1652 | |
1653 | - if ( $current_page == $total_pages ) { |
|
1653 | + if ($current_page == $total_pages) { |
|
1654 | 1654 | return true; |
1655 | 1655 | } else { |
1656 | 1656 | return false; |
1657 | 1657 | } |
1658 | 1658 | } |
1659 | 1659 | |
1660 | - function status_changes_convert_questions( $n = 50, $offset = 0 ) { |
|
1660 | + function status_changes_convert_questions($n = 50, $offset = 0) { |
|
1661 | 1661 | global $wpdb; |
1662 | 1662 | |
1663 | - wp_defer_comment_counting( true ); |
|
1663 | + wp_defer_comment_counting(true); |
|
1664 | 1664 | |
1665 | - $user_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->users " ); |
|
1665 | + $user_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->users "); |
|
1666 | 1666 | |
1667 | - if ( 0 == $user_count_result ) { |
|
1667 | + if (0 == $user_count_result) { |
|
1668 | 1668 | return true; |
1669 | 1669 | } |
1670 | 1670 | |
1671 | 1671 | // Calculate if this is the last page |
1672 | - if ( 0 == $offset ) { |
|
1672 | + if (0 == $offset) { |
|
1673 | 1673 | $current_page = 1; |
1674 | 1674 | } else { |
1675 | - $current_page = intval( $offset / $n ); |
|
1675 | + $current_page = intval($offset / $n); |
|
1676 | 1676 | } |
1677 | 1677 | |
1678 | - $total_pages = ceil( $user_count_result / $n ); |
|
1678 | + $total_pages = ceil($user_count_result / $n); |
|
1679 | 1679 | |
1680 | 1680 | $users_sql = "SELECT ID FROM $wpdb->users ORDER BY ID ASC LIMIT %d OFFSET %d"; |
1681 | 1681 | $answers_sql = "SELECT * FROM $wpdb->comments WHERE comment_type = 'sensei_user_answer' AND user_id = %d GROUP BY comment_post_ID "; |
1682 | 1682 | $grades_sql = "SELECT comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_type = 'sensei_user_grade' AND user_id = %d GROUP BY comment_post_ID "; |
1683 | 1683 | $notes_sql = "SELECT comment_post_ID, comment_content FROM $wpdb->comments WHERE comment_type = 'sensei_answer_notes' AND user_id = %d GROUP BY comment_post_ID "; |
1684 | 1684 | |
1685 | - $user_ids = $wpdb->get_col( $wpdb->prepare($users_sql, $n, $offset) ); |
|
1685 | + $user_ids = $wpdb->get_col($wpdb->prepare($users_sql, $n, $offset)); |
|
1686 | 1686 | |
1687 | - foreach ( $user_ids AS $user_id ) { |
|
1687 | + foreach ($user_ids AS $user_id) { |
|
1688 | 1688 | |
1689 | 1689 | $answer_grades = $answer_notes = array(); |
1690 | 1690 | |
1691 | 1691 | // Pre-process the answer grades |
1692 | - $_answer_grades = $wpdb->get_results( $wpdb->prepare($grades_sql, $user_id), ARRAY_A ); |
|
1693 | - foreach ( $_answer_grades as $answer_grade ) { |
|
1692 | + $_answer_grades = $wpdb->get_results($wpdb->prepare($grades_sql, $user_id), ARRAY_A); |
|
1693 | + foreach ($_answer_grades as $answer_grade) { |
|
1694 | 1694 | // This will overwrite existing entries with the newer ones |
1695 | - $answer_grades[ $answer_grade['comment_post_ID'] ] = $answer_grade['comment_content']; |
|
1695 | + $answer_grades[$answer_grade['comment_post_ID']] = $answer_grade['comment_content']; |
|
1696 | 1696 | } |
1697 | - unset( $_answer_grades ); |
|
1697 | + unset($_answer_grades); |
|
1698 | 1698 | |
1699 | 1699 | // Pre-process the answer notes |
1700 | - $_answer_notes = $wpdb->get_results( $wpdb->prepare($notes_sql, $user_id), ARRAY_A ); |
|
1701 | - foreach ( $_answer_notes as $answer_note ) { |
|
1700 | + $_answer_notes = $wpdb->get_results($wpdb->prepare($notes_sql, $user_id), ARRAY_A); |
|
1701 | + foreach ($_answer_notes as $answer_note) { |
|
1702 | 1702 | // This will overwrite existing entries with the newer ones |
1703 | - $answer_notes[ $answer_note['comment_post_ID'] ] = $answer_note['comment_content']; |
|
1703 | + $answer_notes[$answer_note['comment_post_ID']] = $answer_note['comment_content']; |
|
1704 | 1704 | } |
1705 | - unset( $_answer_notes ); |
|
1705 | + unset($_answer_notes); |
|
1706 | 1706 | |
1707 | 1707 | // Grab all the questions for the user |
1708 | 1708 | $sql = $wpdb->prepare($answers_sql, $user_id); |
1709 | - $answers = $wpdb->get_results( $sql, ARRAY_A ); |
|
1710 | - foreach ( $answers as $answer ) { |
|
1709 | + $answers = $wpdb->get_results($sql, ARRAY_A); |
|
1710 | + foreach ($answers as $answer) { |
|
1711 | 1711 | |
1712 | 1712 | // Excape data |
1713 | 1713 | $answer = wp_slash($answer); |
@@ -1717,12 +1717,12 @@ discard block |
||
1717 | 1717 | $meta_data = array(); |
1718 | 1718 | |
1719 | 1719 | // Check if the question has been graded, add as meta |
1720 | - if ( !empty($answer_grades[ $answer['comment_post_ID'] ]) ) { |
|
1721 | - $meta_data['user_grade'] = $answer_grades[ $answer['comment_post_ID'] ]; |
|
1720 | + if ( ! empty($answer_grades[$answer['comment_post_ID']])) { |
|
1721 | + $meta_data['user_grade'] = $answer_grades[$answer['comment_post_ID']]; |
|
1722 | 1722 | } |
1723 | 1723 | // Check if there is an answer note, add as meta |
1724 | - if ( !empty($answer_notes[ $answer['comment_post_ID'] ]) ) { |
|
1725 | - $meta_data['answer_note'] = $answer_notes[ $answer['comment_post_ID'] ]; |
|
1724 | + if ( ! empty($answer_notes[$answer['comment_post_ID']])) { |
|
1725 | + $meta_data['answer_note'] = $answer_notes[$answer['comment_post_ID']]; |
|
1726 | 1726 | } |
1727 | 1727 | |
1728 | 1728 | // Wipe the unnessary data from the main comment |
@@ -1735,21 +1735,21 @@ discard block |
||
1735 | 1735 | ); |
1736 | 1736 | $data = array_merge($answer, $data); |
1737 | 1737 | |
1738 | - $rval = $wpdb->update( $wpdb->comments, $data, compact( 'comment_ID' ) ); |
|
1739 | - if ( $rval ) { |
|
1740 | - if ( !empty($meta_data) ) { |
|
1741 | - foreach ( $meta_data as $key => $value ) { |
|
1738 | + $rval = $wpdb->update($wpdb->comments, $data, compact('comment_ID')); |
|
1739 | + if ($rval) { |
|
1740 | + if ( ! empty($meta_data)) { |
|
1741 | + foreach ($meta_data as $key => $value) { |
|
1742 | 1742 | // Bypassing WP wp_insert_comment( $data ), so no actions/filters are run |
1743 | - if ( $wpdb->get_var( $wpdb->prepare( |
|
1743 | + if ($wpdb->get_var($wpdb->prepare( |
|
1744 | 1744 | "SELECT COUNT(*) FROM $wpdb->commentmeta WHERE comment_id = %d AND meta_key = %s ", |
1745 | - $comment_ID, $key ) ) ) { |
|
1745 | + $comment_ID, $key ))) { |
|
1746 | 1746 | continue; // Found the meta data already |
1747 | 1747 | } |
1748 | - $result = $wpdb->insert( $wpdb->commentmeta, array( |
|
1748 | + $result = $wpdb->insert($wpdb->commentmeta, array( |
|
1749 | 1749 | 'comment_id' => $comment_ID, |
1750 | 1750 | 'meta_key' => $key, |
1751 | 1751 | 'meta_value' => $value |
1752 | - ) ); |
|
1752 | + )); |
|
1753 | 1753 | } |
1754 | 1754 | } |
1755 | 1755 | } |
@@ -1757,7 +1757,7 @@ discard block |
||
1757 | 1757 | } |
1758 | 1758 | $wpdb->flush(); |
1759 | 1759 | |
1760 | - if ( $current_page == $total_pages ) { |
|
1760 | + if ($current_page == $total_pages) { |
|
1761 | 1761 | return true; |
1762 | 1762 | } else { |
1763 | 1763 | return false; |
@@ -1774,10 +1774,10 @@ discard block |
||
1774 | 1774 | global $wpdb; |
1775 | 1775 | |
1776 | 1776 | // Update 'sensei_user_answer' entries to use comment_approved = 'log' so they don't appear in counts |
1777 | - $wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' " ); |
|
1777 | + $wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'log' WHERE comment_type = 'sensei_user_answer' "); |
|
1778 | 1778 | |
1779 | 1779 | // Mark all old Sensei comment types with comment_approved = 'legacy' so they no longer appear in counts, but can be restored if required |
1780 | - $wpdb->query( "UPDATE $wpdb->comments SET comment_approved = 'legacy' WHERE comment_type IN ('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_answer_notes', 'sensei_quiz_grade') " ); |
|
1780 | + $wpdb->query("UPDATE $wpdb->comments SET comment_approved = 'legacy' WHERE comment_type IN ('sensei_course_start', 'sensei_course_end', 'sensei_lesson_start', 'sensei_lesson_end', 'sensei_quiz_asked', 'sensei_user_grade', 'sensei_answer_notes', 'sensei_quiz_grade') "); |
|
1781 | 1781 | |
1782 | 1782 | return true; |
1783 | 1783 | } |
@@ -1790,50 +1790,50 @@ discard block |
||
1790 | 1790 | * @param type $offset |
1791 | 1791 | * @return boolean |
1792 | 1792 | */ |
1793 | - public function update_comment_course_lesson_comment_counts( $n = 50, $offset = 0 ) { |
|
1793 | + public function update_comment_course_lesson_comment_counts($n = 50, $offset = 0) { |
|
1794 | 1794 | global $wpdb; |
1795 | 1795 | |
1796 | - $item_count_result = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') " ); |
|
1796 | + $item_count_result = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') "); |
|
1797 | 1797 | |
1798 | - if ( 0 == $item_count_result ) { |
|
1798 | + if (0 == $item_count_result) { |
|
1799 | 1799 | return true; |
1800 | 1800 | } |
1801 | 1801 | |
1802 | 1802 | // Calculate if this is the last page |
1803 | - if ( 0 == $offset ) { |
|
1803 | + if (0 == $offset) { |
|
1804 | 1804 | $current_page = 1; |
1805 | 1805 | } else { |
1806 | - $current_page = intval( $offset / $n ); |
|
1806 | + $current_page = intval($offset / $n); |
|
1807 | 1807 | } |
1808 | 1808 | |
1809 | - $total_pages = ceil( $item_count_result / $n ); |
|
1809 | + $total_pages = ceil($item_count_result / $n); |
|
1810 | 1810 | |
1811 | 1811 | // Recalculate all counts |
1812 | - $items = $wpdb->get_results( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset ) ); |
|
1813 | - foreach ( (array) $items as $post ) { |
|
1812 | + $items = $wpdb->get_results($wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_type IN ('course', 'lesson') LIMIT %d OFFSET %d", $n, $offset)); |
|
1813 | + foreach ((array) $items as $post) { |
|
1814 | 1814 | // Code copied from wp_update_comment_count_now() |
1815 | - $new = (int) $wpdb->get_var( $wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID) ); |
|
1816 | - $wpdb->update( $wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID) ); |
|
1815 | + $new = (int) $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_post_ID = %d AND comment_approved = '1'", $post->ID)); |
|
1816 | + $wpdb->update($wpdb->posts, array('comment_count' => $new), array('ID' => $post->ID)); |
|
1817 | 1817 | |
1818 | - clean_post_cache( $post->ID ); |
|
1818 | + clean_post_cache($post->ID); |
|
1819 | 1819 | } |
1820 | 1820 | |
1821 | - if ( $current_page == $total_pages ) { |
|
1821 | + if ($current_page == $total_pages) { |
|
1822 | 1822 | return true; |
1823 | 1823 | } else { |
1824 | 1824 | return false; |
1825 | 1825 | } |
1826 | 1826 | } |
1827 | 1827 | |
1828 | - public function remove_legacy_comments () { |
|
1828 | + public function remove_legacy_comments() { |
|
1829 | 1829 | global $wpdb; |
1830 | 1830 | |
1831 | - $result = $wpdb->delete( $wpdb->comments, array( 'comment_approved' => 'legacy' ) ); |
|
1831 | + $result = $wpdb->delete($wpdb->comments, array('comment_approved' => 'legacy')); |
|
1832 | 1832 | |
1833 | 1833 | return true; |
1834 | 1834 | } |
1835 | 1835 | |
1836 | - public function index_comment_status_field () { |
|
1836 | + public function index_comment_status_field() { |
|
1837 | 1837 | global $wpdb; |
1838 | 1838 | |
1839 | 1839 | $wpdb->query("ALTER TABLE `$wpdb->comments` ADD INDEX `comment_type` ( `comment_type` )"); |
@@ -1852,7 +1852,7 @@ discard block |
||
1852 | 1852 | * @since 1.8.0 |
1853 | 1853 | * @return bool; |
1854 | 1854 | */ |
1855 | - public function enhance_teacher_role ( ) { |
|
1855 | + public function enhance_teacher_role( ) { |
|
1856 | 1856 | |
1857 | 1857 | require_once('class-sensei-teacher.php'); |
1858 | 1858 | $teacher = new Sensei_Teacher(); |
@@ -201,7 +201,7 @@ |
||
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; |
@@ -1,5 +1,8 @@ |
||
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 |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | /** |
4 | 6 | * The Template for displaying the my course page data. |
5 | 7 | * |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | /** |
4 | 4 | * Content wrappers |
5 | 5 | * |
@@ -1,15 +1,15 @@ |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
3 | 3 | /** |
4 | - * Content wrappers |
|
5 | - * |
|
6 | - * All support theme wrappers can be found in includes/theme-integrations |
|
7 | - * |
|
8 | - * @author Automattic |
|
9 | - * @package Sensei |
|
10 | - * @category Templates |
|
11 | - * @version 1.9.0 |
|
12 | - */ |
|
4 | + * Content wrappers |
|
5 | + * |
|
6 | + * All support theme wrappers can be found in includes/theme-integrations |
|
7 | + * |
|
8 | + * @author Automattic |
|
9 | + * @package Sensei |
|
10 | + * @category Templates |
|
11 | + * @version 1.9.0 |
|
12 | + */ |
|
13 | 13 | ?> |
14 | 14 | |
15 | 15 | </main> |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | /** |
4 | 6 | * The Template for displaying the my course page data. |
5 | 7 | * |
@@ -14,19 +14,19 @@ |
||
14 | 14 | |
15 | 15 | <?php |
16 | 16 | |
17 | - /** |
|
18 | - * Get the question data with the current quiz id |
|
19 | - * All data is loaded in this array to keep the template clean. |
|
20 | - */ |
|
21 | - $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() ); |
|
17 | + /** |
|
18 | + * Get the question data with the current quiz id |
|
19 | + * All data is loaded in this array to keep the template clean. |
|
20 | + */ |
|
21 | + $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() ); |
|
22 | 22 | |
23 | 23 | ?> |
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | - Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ] , |
|
28 | - 'textquestion' . $question_data[ 'ID' ] , |
|
29 | - 'sensei_question[' . $question_data[ 'ID' ] . ']' ); |
|
27 | + Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ] , |
|
28 | + 'textquestion' . $question_data[ 'ID' ] , |
|
29 | + 'sensei_question[' . $question_data[ 'ID' ] . ']' ); |
|
30 | 30 | |
31 | 31 | ?> |
32 | 32 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | /** |
4 | 4 | * The Template for displaying Multi Line Questions. |
5 | 5 | * |
@@ -18,15 +18,15 @@ discard block |
||
18 | 18 | * Get the question data with the current quiz id |
19 | 19 | * All data is loaded in this array to keep the template clean. |
20 | 20 | */ |
21 | - $question_data = WooThemes_Sensei_Question::get_template_data( sensei_get_the_question_id(), get_the_ID() ); |
|
21 | + $question_data = WooThemes_Sensei_Question::get_template_data(sensei_get_the_question_id(), get_the_ID()); |
|
22 | 22 | |
23 | 23 | ?> |
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | - Sensei_Utils::sensei_text_editor( $question_data[ 'user_answer_entry' ] , |
|
28 | - 'textquestion' . $question_data[ 'ID' ] , |
|
29 | - 'sensei_question[' . $question_data[ 'ID' ] . ']' ); |
|
27 | + Sensei_Utils::sensei_text_editor($question_data['user_answer_entry'], |
|
28 | + 'textquestion'.$question_data['ID'], |
|
29 | + 'sensei_question['.$question_data['ID'].']'); |
|
30 | 30 | |
31 | 31 | ?> |
32 | 32 |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | /** |
4 | 6 | * The Template for displaying the my course page data. |
5 | 7 | * |
@@ -1,51 +1,51 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
3 | 3 | /** |
4 | - * Content-course.php template file |
|
5 | - * |
|
6 | - * responsible for content on archive like pages. Only shows the course excerpt. |
|
7 | - * |
|
8 | - * For single course content please see single-course.php |
|
9 | - * |
|
10 | - * @author Automattic |
|
11 | - * @package Sensei |
|
12 | - * @category Templates |
|
13 | - * @version 1.9.0 |
|
14 | - */ |
|
4 | + * Content-course.php template file |
|
5 | + * |
|
6 | + * responsible for content on archive like pages. Only shows the course excerpt. |
|
7 | + * |
|
8 | + * For single course content please see single-course.php |
|
9 | + * |
|
10 | + * @author Automattic |
|
11 | + * @package Sensei |
|
12 | + * @category Templates |
|
13 | + * @version 1.9.0 |
|
14 | + */ |
|
15 | 15 | ?> |
16 | 16 | |
17 | 17 | <li <?php post_class( WooThemes_Sensei_Course::get_course_loop_content_class() ); ?> > |
18 | 18 | |
19 | 19 | <?php |
20 | - /** |
|
21 | - * This action runs before the sensei course content. It runs inside the sensei |
|
22 | - * content-course.php template. |
|
23 | - * |
|
24 | - * @since 1.9 |
|
25 | - * |
|
26 | - * @param integer $course_id |
|
27 | - */ |
|
28 | - do_action( 'sensei_course_content_before', get_the_ID() ); |
|
29 | - ?> |
|
20 | + /** |
|
21 | + * This action runs before the sensei course content. It runs inside the sensei |
|
22 | + * content-course.php template. |
|
23 | + * |
|
24 | + * @since 1.9 |
|
25 | + * |
|
26 | + * @param integer $course_id |
|
27 | + */ |
|
28 | + do_action( 'sensei_course_content_before', get_the_ID() ); |
|
29 | + ?> |
|
30 | 30 | |
31 | 31 | <section class="course-content"> |
32 | 32 | |
33 | 33 | <section class="entry"> |
34 | 34 | |
35 | 35 | <?php |
36 | - /** |
|
37 | - * Fires just before the course content in the content-course.php file. |
|
38 | - * |
|
39 | - * @since 1.9 |
|
40 | - * |
|
41 | - * @param integer $course_id |
|
42 | - * |
|
43 | - * @hooked Sensei_Templates::the_title - 5 |
|
44 | - * @hooked Sensei()->course->course_image - 10 |
|
45 | - * @hooked Sensei()->course->the_course_meta - 20 |
|
46 | - */ |
|
47 | - do_action('sensei_course_content_inside_before', get_the_ID() ); |
|
48 | - ?> |
|
36 | + /** |
|
37 | + * Fires just before the course content in the content-course.php file. |
|
38 | + * |
|
39 | + * @since 1.9 |
|
40 | + * |
|
41 | + * @param integer $course_id |
|
42 | + * |
|
43 | + * @hooked Sensei_Templates::the_title - 5 |
|
44 | + * @hooked Sensei()->course->course_image - 10 |
|
45 | + * @hooked Sensei()->course->the_course_meta - 20 |
|
46 | + */ |
|
47 | + do_action('sensei_course_content_inside_before', get_the_ID() ); |
|
48 | + ?> |
|
49 | 49 | |
50 | 50 | <p class="course-excerpt"> |
51 | 51 | |
@@ -54,34 +54,34 @@ discard block |
||
54 | 54 | </p> |
55 | 55 | |
56 | 56 | <?php |
57 | - /** |
|
58 | - * Fires just after the course content in the content-course.php file. |
|
59 | - * |
|
60 | - * @since 1.9 |
|
61 | - * |
|
62 | - * @param integer $course_id |
|
63 | - * |
|
64 | - * @hooked Sensei()->course->the_course_free_lesson_preview - 20 |
|
65 | - */ |
|
66 | - do_action('sensei_course_content_inside_after', get_the_ID() ); |
|
67 | - ?> |
|
57 | + /** |
|
58 | + * Fires just after the course content in the content-course.php file. |
|
59 | + * |
|
60 | + * @since 1.9 |
|
61 | + * |
|
62 | + * @param integer $course_id |
|
63 | + * |
|
64 | + * @hooked Sensei()->course->the_course_free_lesson_preview - 20 |
|
65 | + */ |
|
66 | + do_action('sensei_course_content_inside_after', get_the_ID() ); |
|
67 | + ?> |
|
68 | 68 | |
69 | 69 | </section> <!-- section .entry --> |
70 | 70 | |
71 | 71 | </section> <!-- section .course-content --> |
72 | 72 | |
73 | 73 | <?php |
74 | - /** |
|
75 | - * Fires after the course block in the content-course.php file. |
|
76 | - * |
|
77 | - * @since 1.9 |
|
78 | - * |
|
79 | - * @param integer $course_id |
|
80 | - * |
|
81 | - * @hooked Sensei()->course->the_course_free_lesson_preview - 20 |
|
82 | - */ |
|
83 | - do_action('sensei_course_content_after', get_the_ID() ); |
|
84 | - ?> |
|
74 | + /** |
|
75 | + * Fires after the course block in the content-course.php file. |
|
76 | + * |
|
77 | + * @since 1.9 |
|
78 | + * |
|
79 | + * @param integer $course_id |
|
80 | + * |
|
81 | + * @hooked Sensei()->course->the_course_free_lesson_preview - 20 |
|
82 | + */ |
|
83 | + do_action('sensei_course_content_after', get_the_ID() ); |
|
84 | + ?> |
|
85 | 85 | |
86 | 86 | |
87 | 87 | </li> <!-- article .(<?php esc_attr_e( join( ' ', get_post_class( array( 'course', 'post' ) ) ) ); ?> --> |
88 | 88 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | /** |
4 | 4 | * Content-course.php template file |
5 | 5 | * |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | */ |
15 | 15 | ?> |
16 | 16 | |
17 | -<li <?php post_class( WooThemes_Sensei_Course::get_course_loop_content_class() ); ?> > |
|
17 | +<li <?php post_class(WooThemes_Sensei_Course::get_course_loop_content_class()); ?> > |
|
18 | 18 | |
19 | 19 | <?php |
20 | 20 | /** |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @param integer $course_id |
27 | 27 | */ |
28 | - do_action( 'sensei_course_content_before', get_the_ID() ); |
|
28 | + do_action('sensei_course_content_before', get_the_ID()); |
|
29 | 29 | ?> |
30 | 30 | |
31 | 31 | <section class="course-content"> |
@@ -44,7 +44,7 @@ discard block |
||
44 | 44 | * @hooked Sensei()->course->course_image - 10 |
45 | 45 | * @hooked Sensei()->course->the_course_meta - 20 |
46 | 46 | */ |
47 | - do_action('sensei_course_content_inside_before', get_the_ID() ); |
|
47 | + do_action('sensei_course_content_inside_before', get_the_ID()); |
|
48 | 48 | ?> |
49 | 49 | |
50 | 50 | <p class="course-excerpt"> |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | * |
64 | 64 | * @hooked Sensei()->course->the_course_free_lesson_preview - 20 |
65 | 65 | */ |
66 | - do_action('sensei_course_content_inside_after', get_the_ID() ); |
|
66 | + do_action('sensei_course_content_inside_after', get_the_ID()); |
|
67 | 67 | ?> |
68 | 68 | |
69 | 69 | </section> <!-- section .entry --> |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @hooked Sensei()->course->the_course_free_lesson_preview - 20 |
82 | 82 | */ |
83 | - do_action('sensei_course_content_after', get_the_ID() ); |
|
83 | + do_action('sensei_course_content_after', get_the_ID()); |
|
84 | 84 | ?> |
85 | 85 | |
86 | 86 | |
87 | -</li> <!-- article .(<?php esc_attr_e( join( ' ', get_post_class( array( 'course', 'post' ) ) ) ); ?> --> |
|
88 | 87 | \ No newline at end of file |
88 | +</li> <!-- article .(<?php esc_attr_e(join(' ', get_post_class(array('course', 'post')))); ?> --> |
|
89 | 89 | \ No newline at end of file |
@@ -1,5 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
3 | 5 | /** |
4 | 6 | * The Template for displaying the my course page data. |
5 | 7 | * |
@@ -1,15 +1,15 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) exit; |
3 | 3 | /** |
4 | - * The Template for displaying all course lessons on the course results page. |
|
5 | - * |
|
6 | - * Override this template by copying it to yourtheme/sensei/course-results/course-lessons.php |
|
7 | - * |
|
8 | - * @author Automattic |
|
9 | - * @package Sensei |
|
10 | - * @category Templates |
|
11 | - * @version 1.9.0 |
|
12 | - */ |
|
4 | + * The Template for displaying all course lessons on the course results page. |
|
5 | + * |
|
6 | + * Override this template by copying it to yourtheme/sensei/course-results/course-lessons.php |
|
7 | + * |
|
8 | + * @author Automattic |
|
9 | + * @package Sensei |
|
10 | + * @category Templates |
|
11 | + * @version 1.9.0 |
|
12 | + */ |
|
13 | 13 | |
14 | 14 | global $course; |
15 | 15 | ?> |
@@ -17,13 +17,13 @@ discard block |
||
17 | 17 | <?php if ( is_user_logged_in() ): ?> |
18 | 18 | |
19 | 19 | <?php |
20 | - /** |
|
21 | - * Fires inside course-results/lessons.php after the |
|
22 | - * is uer logged check, just above the lessons header. |
|
23 | - * @since 1.4.0 |
|
24 | - */ |
|
25 | - do_action( 'sensei_course_results_before_lessons', $course->ID ); |
|
26 | - ?> |
|
20 | + /** |
|
21 | + * Fires inside course-results/lessons.php after the |
|
22 | + * is uer logged check, just above the lessons header. |
|
23 | + * @since 1.4.0 |
|
24 | + */ |
|
25 | + do_action( 'sensei_course_results_before_lessons', $course->ID ); |
|
26 | + ?> |
|
27 | 27 | |
28 | 28 | <header> |
29 | 29 | |
@@ -36,38 +36,38 @@ discard block |
||
36 | 36 | <?php |
37 | 37 | |
38 | 38 | $displayed_lessons = array(); |
39 | - $modules = Sensei()->modules->get_course_modules( intval( $course->ID ) ); |
|
39 | + $modules = Sensei()->modules->get_course_modules( intval( $course->ID ) ); |
|
40 | 40 | |
41 | - // List modules with lessons |
|
42 | - $course_has_lessons_in_modules = false; |
|
43 | - foreach( $modules as $module ) { |
|
41 | + // List modules with lessons |
|
42 | + $course_has_lessons_in_modules = false; |
|
43 | + foreach( $modules as $module ) { |
|
44 | 44 | |
45 | - $lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id ); |
|
46 | - $lessons = $lessons_query->get_posts(); |
|
45 | + $lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id ); |
|
46 | + $lessons = $lessons_query->get_posts(); |
|
47 | 47 | |
48 | - if( count( $lessons ) > 0 ) { |
|
48 | + if( count( $lessons ) > 0 ) { |
|
49 | 49 | |
50 | - $course_has_lessons_in_modules = true; |
|
50 | + $course_has_lessons_in_modules = true; |
|
51 | 51 | |
52 | - ?> |
|
52 | + ?> |
|
53 | 53 | |
54 | 54 | <h3> <?php echo $module->name; ?></h3> |
55 | 55 | |
56 | 56 | <?php |
57 | - $count = 0; |
|
58 | - foreach( $lessons as $lesson ) { |
|
59 | - |
|
60 | - $lesson_grade = 'n/a'; |
|
61 | - $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
62 | - if ( $has_questions ) { |
|
63 | - $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() ); |
|
64 | - // Get user quiz grade |
|
65 | - $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
66 | - if ( $lesson_grade ) { |
|
67 | - $lesson_grade .= '%'; |
|
68 | - } |
|
69 | - } |
|
70 | - ?> |
|
57 | + $count = 0; |
|
58 | + foreach( $lessons as $lesson ) { |
|
59 | + |
|
60 | + $lesson_grade = 'n/a'; |
|
61 | + $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
62 | + if ( $has_questions ) { |
|
63 | + $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() ); |
|
64 | + // Get user quiz grade |
|
65 | + $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
66 | + if ( $lesson_grade ) { |
|
67 | + $lesson_grade .= '%'; |
|
68 | + } |
|
69 | + } |
|
70 | + ?> |
|
71 | 71 | <h2> |
72 | 72 | |
73 | 73 | <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ); ?>" |
@@ -85,46 +85,46 @@ discard block |
||
85 | 85 | |
86 | 86 | <?php |
87 | 87 | |
88 | - }// end for each |
|
88 | + }// end for each |
|
89 | 89 | |
90 | - }// end if count lesson |
|
90 | + }// end if count lesson |
|
91 | 91 | |
92 | - } // end for each module |
|
93 | - ?> |
|
92 | + } // end for each module |
|
93 | + ?> |
|
94 | 94 | |
95 | 95 | <?php |
96 | 96 | |
97 | - $lessons = Sensei()->modules->get_none_module_lessons( $course->ID ); |
|
98 | - if( 0 < count( $lessons ) ): ?> |
|
97 | + $lessons = Sensei()->modules->get_none_module_lessons( $course->ID ); |
|
98 | + if( 0 < count( $lessons ) ): ?> |
|
99 | 99 | |
100 | 100 | <h3> |
101 | 101 | |
102 | 102 | <?php |
103 | - // lesson title will already appear above |
|
104 | - if ( $course_has_lessons_in_modules ) { |
|
105 | - _e( 'Other Lessons', 'woothemes-sensei' ); |
|
106 | - } |
|
107 | - ?> |
|
103 | + // lesson title will already appear above |
|
104 | + if ( $course_has_lessons_in_modules ) { |
|
105 | + _e( 'Other Lessons', 'woothemes-sensei' ); |
|
106 | + } |
|
107 | + ?> |
|
108 | 108 | |
109 | 109 | </h3> |
110 | 110 | |
111 | 111 | <?php foreach ( $lessons as $lesson ): ?> |
112 | 112 | |
113 | 113 | <?php |
114 | - $lesson_grade = 'n/a'; |
|
115 | - $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
116 | - if ( $has_questions ) { |
|
117 | - $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id()); |
|
118 | - // Get user quiz grade |
|
119 | - $lesson_grade = ''; |
|
120 | - if( ! empty( $lesson_status ) ) { |
|
121 | - $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
122 | - if ( $lesson_grade ) { |
|
123 | - $lesson_grade .= '%'; |
|
124 | - } |
|
125 | - } |
|
126 | - } |
|
127 | - ?> |
|
114 | + $lesson_grade = 'n/a'; |
|
115 | + $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
116 | + if ( $has_questions ) { |
|
117 | + $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id()); |
|
118 | + // Get user quiz grade |
|
119 | + $lesson_grade = ''; |
|
120 | + if( ! empty( $lesson_status ) ) { |
|
121 | + $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
122 | + if ( $lesson_grade ) { |
|
123 | + $lesson_grade .= '%'; |
|
124 | + } |
|
125 | + } |
|
126 | + } |
|
127 | + ?> |
|
128 | 128 | |
129 | 129 | <h2> |
130 | 130 | |
@@ -150,10 +150,10 @@ discard block |
||
150 | 150 | |
151 | 151 | <?php |
152 | 152 | |
153 | - $course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() ); |
|
154 | - echo $course_user_grade . '%'; |
|
153 | + $course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() ); |
|
154 | + echo $course_user_grade . '%'; |
|
155 | 155 | |
156 | - ?> |
|
156 | + ?> |
|
157 | 157 | |
158 | 158 | </span> |
159 | 159 | |
@@ -162,13 +162,13 @@ discard block |
||
162 | 162 | </article> |
163 | 163 | |
164 | 164 | <?php |
165 | - /** |
|
166 | - * Fires inside course-results/lessons.php after the |
|
167 | - * is uer logged check, at the bottom of all lessons. |
|
168 | - * |
|
169 | - * @since 1.4.0 |
|
170 | - */ |
|
165 | + /** |
|
166 | + * Fires inside course-results/lessons.php after the |
|
167 | + * is uer logged check, at the bottom of all lessons. |
|
168 | + * |
|
169 | + * @since 1.4.0 |
|
170 | + */ |
|
171 | 171 | do_action( 'sensei_course_results_after_lessons', $course->ID ); |
172 | - ?> |
|
172 | + ?> |
|
173 | 173 | |
174 | 174 | <?php endif; //user logged in ?> |
175 | 175 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; |
|
2 | +if ( ! defined('ABSPATH')) exit; |
|
3 | 3 | /** |
4 | 4 | * The Template for displaying all course lessons on the course results page. |
5 | 5 | * |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | global $course; |
15 | 15 | ?> |
16 | 16 | |
17 | -<?php if ( is_user_logged_in() ): ?> |
|
17 | +<?php if (is_user_logged_in()): ?> |
|
18 | 18 | |
19 | 19 | <?php |
20 | 20 | /** |
@@ -22,30 +22,30 @@ discard block |
||
22 | 22 | * is uer logged check, just above the lessons header. |
23 | 23 | * @since 1.4.0 |
24 | 24 | */ |
25 | - do_action( 'sensei_course_results_before_lessons', $course->ID ); |
|
25 | + do_action('sensei_course_results_before_lessons', $course->ID); |
|
26 | 26 | ?> |
27 | 27 | |
28 | 28 | <header> |
29 | 29 | |
30 | - <h2> <?php _e( 'Lessons', 'woothemes-sensei' ); ?> </h2> |
|
30 | + <h2> <?php _e('Lessons', 'woothemes-sensei'); ?> </h2> |
|
31 | 31 | |
32 | 32 | </header> |
33 | 33 | |
34 | - <article class="<?php esc_attr_e( join( ' ', get_post_class( array( 'course', 'post' ), $course->ID ) ) ); ?> "> |
|
34 | + <article class="<?php esc_attr_e(join(' ', get_post_class(array('course', 'post'), $course->ID))); ?> "> |
|
35 | 35 | |
36 | 36 | <?php |
37 | 37 | |
38 | 38 | $displayed_lessons = array(); |
39 | - $modules = Sensei()->modules->get_course_modules( intval( $course->ID ) ); |
|
39 | + $modules = Sensei()->modules->get_course_modules(intval($course->ID)); |
|
40 | 40 | |
41 | 41 | // List modules with lessons |
42 | 42 | $course_has_lessons_in_modules = false; |
43 | - foreach( $modules as $module ) { |
|
43 | + foreach ($modules as $module) { |
|
44 | 44 | |
45 | - $lessons_query = Sensei()->modules->get_lessons_query( $course->ID, $module->term_id ); |
|
45 | + $lessons_query = Sensei()->modules->get_lessons_query($course->ID, $module->term_id); |
|
46 | 46 | $lessons = $lessons_query->get_posts(); |
47 | 47 | |
48 | - if( count( $lessons ) > 0 ) { |
|
48 | + if (count($lessons) > 0) { |
|
49 | 49 | |
50 | 50 | $course_has_lessons_in_modules = true; |
51 | 51 | |
@@ -55,25 +55,25 @@ discard block |
||
55 | 55 | |
56 | 56 | <?php |
57 | 57 | $count = 0; |
58 | - foreach( $lessons as $lesson ) { |
|
58 | + foreach ($lessons as $lesson) { |
|
59 | 59 | |
60 | 60 | $lesson_grade = 'n/a'; |
61 | - $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
62 | - if ( $has_questions ) { |
|
63 | - $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id() ); |
|
61 | + $has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true); |
|
62 | + if ($has_questions) { |
|
63 | + $lesson_status = Sensei_Utils::user_lesson_status($lesson->ID, get_current_user_id()); |
|
64 | 64 | // Get user quiz grade |
65 | - $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
66 | - if ( $lesson_grade ) { |
|
65 | + $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); |
|
66 | + if ($lesson_grade) { |
|
67 | 67 | $lesson_grade .= '%'; |
68 | 68 | } |
69 | 69 | } |
70 | 70 | ?> |
71 | 71 | <h2> |
72 | 72 | |
73 | - <a href="<?php esc_url_raw( get_permalink( $lesson->ID ) ); ?>" |
|
74 | - title="<?php esc_attr_e( sprintf( __( 'Start %s', 'woothemes-sensei' ), $lesson->post_title ) ); ?>"> |
|
73 | + <a href="<?php esc_url_raw(get_permalink($lesson->ID)); ?>" |
|
74 | + title="<?php esc_attr_e(sprintf(__('Start %s', 'woothemes-sensei'), $lesson->post_title)); ?>"> |
|
75 | 75 | |
76 | - <?php esc_html_e( $lesson->post_title ); ?> |
|
76 | + <?php esc_html_e($lesson->post_title); ?> |
|
77 | 77 | |
78 | 78 | </a> |
79 | 79 | |
@@ -94,32 +94,32 @@ discard block |
||
94 | 94 | |
95 | 95 | <?php |
96 | 96 | |
97 | - $lessons = Sensei()->modules->get_none_module_lessons( $course->ID ); |
|
98 | - if( 0 < count( $lessons ) ): ?> |
|
97 | + $lessons = Sensei()->modules->get_none_module_lessons($course->ID); |
|
98 | + if (0 < count($lessons)): ?> |
|
99 | 99 | |
100 | 100 | <h3> |
101 | 101 | |
102 | 102 | <?php |
103 | 103 | // lesson title will already appear above |
104 | - if ( $course_has_lessons_in_modules ) { |
|
105 | - _e( 'Other Lessons', 'woothemes-sensei' ); |
|
104 | + if ($course_has_lessons_in_modules) { |
|
105 | + _e('Other Lessons', 'woothemes-sensei'); |
|
106 | 106 | } |
107 | 107 | ?> |
108 | 108 | |
109 | 109 | </h3> |
110 | 110 | |
111 | - <?php foreach ( $lessons as $lesson ): ?> |
|
111 | + <?php foreach ($lessons as $lesson): ?> |
|
112 | 112 | |
113 | 113 | <?php |
114 | 114 | $lesson_grade = 'n/a'; |
115 | - $has_questions = get_post_meta( $lesson->ID, '_quiz_has_questions', true ); |
|
116 | - if ( $has_questions ) { |
|
117 | - $lesson_status = Sensei_Utils::user_lesson_status( $lesson->ID, get_current_user_id()); |
|
115 | + $has_questions = get_post_meta($lesson->ID, '_quiz_has_questions', true); |
|
116 | + if ($has_questions) { |
|
117 | + $lesson_status = Sensei_Utils::user_lesson_status($lesson->ID, get_current_user_id()); |
|
118 | 118 | // Get user quiz grade |
119 | 119 | $lesson_grade = ''; |
120 | - if( ! empty( $lesson_status ) ) { |
|
121 | - $lesson_grade = get_comment_meta( $lesson_status->comment_ID, 'grade', true ); |
|
122 | - if ( $lesson_grade ) { |
|
120 | + if ( ! empty($lesson_status)) { |
|
121 | + $lesson_grade = get_comment_meta($lesson_status->comment_ID, 'grade', true); |
|
122 | + if ($lesson_grade) { |
|
123 | 123 | $lesson_grade .= '%'; |
124 | 124 | } |
125 | 125 | } |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | |
129 | 129 | <h2> |
130 | 130 | |
131 | - <a href="<?php echo esc_url_raw( get_permalink( $lesson->ID ) ) ?>" title="<?php esc_attr_e( sprintf( __( 'Start %s', 'woothemes-sensei' ), $lesson->post_title ) ) ?>" > |
|
131 | + <a href="<?php echo esc_url_raw(get_permalink($lesson->ID)) ?>" title="<?php esc_attr_e(sprintf(__('Start %s', 'woothemes-sensei'), $lesson->post_title)) ?>" > |
|
132 | 132 | |
133 | - <?php esc_html_e( sprintf( __( '%s', 'woothemes-sensei' ), $lesson->post_title ) ); ?> |
|
133 | + <?php esc_html_e(sprintf(__('%s', 'woothemes-sensei'), $lesson->post_title)); ?> |
|
134 | 134 | |
135 | 135 | </a> |
136 | 136 | |
@@ -145,13 +145,13 @@ discard block |
||
145 | 145 | |
146 | 146 | <h2 class="total-grade"> |
147 | 147 | |
148 | - <?php _e( 'Total Grade', 'woothemes-sensei' ); ?> |
|
148 | + <?php _e('Total Grade', 'woothemes-sensei'); ?> |
|
149 | 149 | <span class="lesson-grade"> |
150 | 150 | |
151 | 151 | <?php |
152 | 152 | |
153 | - $course_user_grade = Sensei_Utils::sensei_course_user_grade( $course->ID, get_current_user_id() ); |
|
154 | - echo $course_user_grade . '%'; |
|
153 | + $course_user_grade = Sensei_Utils::sensei_course_user_grade($course->ID, get_current_user_id()); |
|
154 | + echo $course_user_grade.'%'; |
|
155 | 155 | |
156 | 156 | ?> |
157 | 157 | |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | * |
169 | 169 | * @since 1.4.0 |
170 | 170 | */ |
171 | - do_action( 'sensei_course_results_after_lessons', $course->ID ); |
|
171 | + do_action('sensei_course_results_after_lessons', $course->ID); |
|
172 | 172 | ?> |
173 | 173 | |
174 | 174 | <?php endif; //user logged in ?> |
175 | 175 | \ No newline at end of file |
@@ -1,5 +1,8 @@ |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly. |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
5 | +// Exit if accessed directly. |
|
3 | 6 | |
4 | 7 | /** |
5 | 8 | * Sensei Course Component Widget |
@@ -53,10 +53,10 @@ discard block |
||
53 | 53 | */ |
54 | 54 | public function widget( $args, $instance ) { |
55 | 55 | |
56 | - $before_widget = $args[ 'before_widget' ]; |
|
57 | - $before_title = $args[ 'before_title' ]; |
|
58 | - $after_title = $args[ 'after_title' ]; |
|
59 | - $after_widget = $args[ 'after_widget' ]; |
|
56 | + $before_widget = $args[ 'before_widget' ]; |
|
57 | + $before_title = $args[ 'before_title' ]; |
|
58 | + $after_title = $args[ 'after_title' ]; |
|
59 | + $after_widget = $args[ 'after_widget' ]; |
|
60 | 60 | |
61 | 61 | if ( in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) ) && ( 'activecourses' == $instance['component'] || 'completedcourses' == $instance['component'] ) && !is_user_logged_in() ) { |
62 | 62 | // No Output |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param array $instance The settings for this instance. |
118 | 118 | * @return void |
119 | 119 | */ |
120 | - public function form( $instance ) { |
|
120 | + public function form( $instance ) { |
|
121 | 121 | |
122 | 122 | /* Set up some default widget settings. */ |
123 | 123 | /* Make sure all keys are added here, even with empty string values. */ |
@@ -172,8 +172,8 @@ discard block |
||
172 | 172 | $post_args = array( 'post_type' => 'lesson', |
173 | 173 | 'posts_per_page' => intval( $instance[ 'limit' ] ), |
174 | 174 | 'orderby' => 'menu_order date', |
175 | - 'order' => 'DESC', |
|
176 | - 'post_status' => 'publish', |
|
175 | + 'order' => 'DESC', |
|
176 | + 'post_status' => 'publish', |
|
177 | 177 | 'suppress_filters' => 0 |
178 | 178 | ); |
179 | 179 | $posts_array = get_posts( $post_args ); |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | if ( count( $posts_array ) > 0 ) { ?> |
182 | 182 | <ul> |
183 | 183 | <?php foreach ($posts_array as $post_item){ |
184 | - $post_id = absint( $post_item->ID ); |
|
185 | - $post_title = $post_item->post_title; |
|
186 | - $user_info = get_userdata( absint( $post_item->post_author ) ); |
|
187 | - $author_link = get_author_posts_url( absint( $post_item->post_author ) ); |
|
188 | - $author_display_name = $user_info->display_name; |
|
189 | - $author_id = $post_item->post_author; |
|
190 | - $lesson_course_id = get_post_meta( $post_id, '_lesson_course', true ); |
|
191 | - ?> |
|
184 | + $post_id = absint( $post_item->ID ); |
|
185 | + $post_title = $post_item->post_title; |
|
186 | + $user_info = get_userdata( absint( $post_item->post_author ) ); |
|
187 | + $author_link = get_author_posts_url( absint( $post_item->post_author ) ); |
|
188 | + $author_display_name = $user_info->display_name; |
|
189 | + $author_id = $post_item->post_author; |
|
190 | + $lesson_course_id = get_post_meta( $post_id, '_lesson_course', true ); |
|
191 | + ?> |
|
192 | 192 | <li class="fix"> |
193 | 193 | <?php do_action( 'sensei_lesson_image', $post_id, '100', '100', false, true ); ?> |
194 | 194 | <a href="<?php echo esc_url( get_permalink( $post_id ) ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a> |
@@ -1,5 +1,5 @@ discard block |
||
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 Lesson Component Widget |
@@ -26,22 +26,22 @@ discard block |
||
26 | 26 | public function __construct() { |
27 | 27 | /* Widget variable settings. */ |
28 | 28 | $this->woo_widget_cssclass = 'widget_sensei_lesson_component'; |
29 | - $this->woo_widget_description = __( 'This widget will output a list of the latest Lessons.', 'woothemes-sensei' ); |
|
29 | + $this->woo_widget_description = __('This widget will output a list of the latest Lessons.', 'woothemes-sensei'); |
|
30 | 30 | $this->woo_widget_idbase = 'sensei_lesson_component'; |
31 | - $this->woo_widget_title = __( 'Sensei - Lesson Component', 'woothemes-sensei' ); |
|
31 | + $this->woo_widget_title = __('Sensei - Lesson Component', 'woothemes-sensei'); |
|
32 | 32 | |
33 | 33 | $this->woo_widget_componentslist = array( |
34 | - 'newlessons' => __( 'New Lessons', 'woothemes-sensei' ), |
|
34 | + 'newlessons' => __('New Lessons', 'woothemes-sensei'), |
|
35 | 35 | ); |
36 | 36 | |
37 | 37 | /* Widget settings. */ |
38 | - $widget_ops = array( 'classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description ); |
|
38 | + $widget_ops = array('classname' => $this->woo_widget_cssclass, 'description' => $this->woo_widget_description); |
|
39 | 39 | |
40 | 40 | /* Widget control settings. */ |
41 | - $control_ops = array( 'width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase ); |
|
41 | + $control_ops = array('width' => 250, 'height' => 350, 'id_base' => $this->woo_widget_idbase); |
|
42 | 42 | |
43 | 43 | /* Create the widget. */ |
44 | - parent::__construct( $this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops ); |
|
44 | + parent::__construct($this->woo_widget_idbase, $this->woo_widget_title, $widget_ops, $control_ops); |
|
45 | 45 | } // End __construct() |
46 | 46 | |
47 | 47 | /** |
@@ -51,35 +51,35 @@ discard block |
||
51 | 51 | * @param array $instance Widget settings for this instance. |
52 | 52 | * @return void |
53 | 53 | */ |
54 | - public function widget( $args, $instance ) { |
|
54 | + public function widget($args, $instance) { |
|
55 | 55 | |
56 | - $before_widget = $args[ 'before_widget' ]; |
|
57 | - $before_title = $args[ 'before_title' ]; |
|
58 | - $after_title = $args[ 'after_title' ]; |
|
59 | - $after_widget = $args[ 'after_widget' ]; |
|
56 | + $before_widget = $args['before_widget']; |
|
57 | + $before_title = $args['before_title']; |
|
58 | + $after_title = $args['after_title']; |
|
59 | + $after_widget = $args['after_widget']; |
|
60 | 60 | |
61 | - if ( in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) ) && ( 'activecourses' == $instance['component'] || 'completedcourses' == $instance['component'] ) && !is_user_logged_in() ) { |
|
61 | + if (in_array($instance['component'], array_keys($this->woo_widget_componentslist)) && ('activecourses' == $instance['component'] || 'completedcourses' == $instance['component']) && ! is_user_logged_in()) { |
|
62 | 62 | // No Output |
63 | 63 | } else { |
64 | 64 | /* Our variables from the widget settings. */ |
65 | - $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base ); |
|
65 | + $title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base); |
|
66 | 66 | |
67 | 67 | /* Before widget (defined by themes). */ |
68 | 68 | echo $before_widget; |
69 | 69 | |
70 | 70 | /* Display the widget title if one was input (before and after defined by themes). */ |
71 | - if ( $title ) { echo $before_title . $title . $after_title; } |
|
71 | + if ($title) { echo $before_title.$title.$after_title; } |
|
72 | 72 | |
73 | 73 | /* Widget content. */ |
74 | 74 | // Add actions for plugins/themes to hook onto. |
75 | - do_action( $this->woo_widget_cssclass . '_top' ); |
|
75 | + do_action($this->woo_widget_cssclass.'_top'); |
|
76 | 76 | |
77 | - if ( in_array( $instance['component'], array_keys( $this->woo_widget_componentslist ) ) ) { |
|
78 | - $this->load_component( $instance ); |
|
77 | + if (in_array($instance['component'], array_keys($this->woo_widget_componentslist))) { |
|
78 | + $this->load_component($instance); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | // Add actions for plugins/themes to hook onto. |
82 | - do_action( $this->woo_widget_cssclass . '_bottom' ); |
|
82 | + do_action($this->woo_widget_cssclass.'_bottom'); |
|
83 | 83 | |
84 | 84 | /* After widget (defined by themes). */ |
85 | 85 | echo $after_widget; |
@@ -94,17 +94,17 @@ discard block |
||
94 | 94 | * @param array $old_instance Previous settings. |
95 | 95 | * @return array Updated settings. |
96 | 96 | */ |
97 | - public function update ( $new_instance, $old_instance ) { |
|
97 | + public function update($new_instance, $old_instance) { |
|
98 | 98 | $instance = $old_instance; |
99 | 99 | |
100 | 100 | /* Strip tags for title and name to remove HTML (important for text inputs). */ |
101 | - $instance['title'] = strip_tags( $new_instance['title'] ); |
|
101 | + $instance['title'] = strip_tags($new_instance['title']); |
|
102 | 102 | |
103 | 103 | /* The select box is returning a text value, so we escape it. */ |
104 | - $instance['component'] = esc_attr( $new_instance['component'] ); |
|
104 | + $instance['component'] = esc_attr($new_instance['component']); |
|
105 | 105 | |
106 | 106 | /* The select box is returning a text value, so we escape it. */ |
107 | - $instance['limit'] = esc_attr( $new_instance['limit'] ); |
|
107 | + $instance['limit'] = esc_attr($new_instance['limit']); |
|
108 | 108 | |
109 | 109 | |
110 | 110 | return $instance; |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | * @param array $instance The settings for this instance. |
118 | 118 | * @return void |
119 | 119 | */ |
120 | - public function form( $instance ) { |
|
120 | + public function form($instance) { |
|
121 | 121 | |
122 | 122 | /* Set up some default widget settings. */ |
123 | 123 | /* Make sure all keys are added here, even with empty string values. */ |
@@ -127,26 +127,26 @@ discard block |
||
127 | 127 | 'limit' => 3 |
128 | 128 | ); |
129 | 129 | |
130 | - $instance = wp_parse_args( (array) $instance, $defaults ); |
|
130 | + $instance = wp_parse_args((array) $instance, $defaults); |
|
131 | 131 | ?> |
132 | 132 | <!-- Widget Title: Text Input --> |
133 | 133 | <p> |
134 | - <label for="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>"><?php _e( 'Title (optional):', 'woothemes-sensei' ); ?></label> |
|
135 | - <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'title' ) ); ?>" value="<?php echo esc_attr( $instance['title'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'title' ) ); ?>" /> |
|
134 | + <label for="<?php echo esc_attr($this->get_field_id('title')); ?>"><?php _e('Title (optional):', 'woothemes-sensei'); ?></label> |
|
135 | + <input type="text" name="<?php echo esc_attr($this->get_field_name('title')); ?>" value="<?php echo esc_attr($instance['title']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('title')); ?>" /> |
|
136 | 136 | </p> |
137 | 137 | <!-- Widget Component: Select Input --> |
138 | 138 | <p> |
139 | - <label for="<?php echo esc_attr( $this->get_field_id( 'component' ) ); ?>"><?php _e( 'Component:', 'woothemes-sensei' ); ?></label> |
|
140 | - <select name="<?php echo esc_attr( $this->get_field_name( 'component' ) ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'component' ) ); ?>"> |
|
141 | - <?php foreach ( $this->woo_widget_componentslist as $k => $v ) { ?> |
|
142 | - <option value="<?php echo esc_attr( $k ); ?>"<?php selected( $instance['component'], $k ); ?>><?php echo $v; ?></option> |
|
139 | + <label for="<?php echo esc_attr($this->get_field_id('component')); ?>"><?php _e('Component:', 'woothemes-sensei'); ?></label> |
|
140 | + <select name="<?php echo esc_attr($this->get_field_name('component')); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('component')); ?>"> |
|
141 | + <?php foreach ($this->woo_widget_componentslist as $k => $v) { ?> |
|
142 | + <option value="<?php echo esc_attr($k); ?>"<?php selected($instance['component'], $k); ?>><?php echo $v; ?></option> |
|
143 | 143 | <?php } ?> |
144 | 144 | </select> |
145 | 145 | </p> |
146 | 146 | <!-- Widget Limit: Text Input --> |
147 | 147 | <p> |
148 | - <label for="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>"><?php _e( 'Number of Lessons (optional):', 'woothemes-sensei' ); ?></label> |
|
149 | - <input type="text" name="<?php echo esc_attr( $this->get_field_name( 'limit' ) ); ?>" value="<?php echo esc_attr( $instance['limit'] ); ?>" class="widefat" id="<?php echo esc_attr( $this->get_field_id( 'limit' ) ); ?>" /> |
|
148 | + <label for="<?php echo esc_attr($this->get_field_id('limit')); ?>"><?php _e('Number of Lessons (optional):', 'woothemes-sensei'); ?></label> |
|
149 | + <input type="text" name="<?php echo esc_attr($this->get_field_name('limit')); ?>" value="<?php echo esc_attr($instance['limit']); ?>" class="widefat" id="<?php echo esc_attr($this->get_field_id('limit')); ?>" /> |
|
150 | 150 | </p> |
151 | 151 | |
152 | 152 | <?php |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | * @since 5.0.8 |
159 | 159 | * @return void |
160 | 160 | */ |
161 | - protected function load_component ( $instance ) { |
|
161 | + protected function load_component($instance) { |
|
162 | 162 | |
163 | 163 | global $current_user; |
164 | 164 | // Get User Meta |
@@ -169,41 +169,41 @@ discard block |
||
169 | 169 | |
170 | 170 | $posts_array = array(); |
171 | 171 | |
172 | - $post_args = array( 'post_type' => 'lesson', |
|
173 | - 'posts_per_page' => intval( $instance[ 'limit' ] ), |
|
172 | + $post_args = array('post_type' => 'lesson', |
|
173 | + 'posts_per_page' => intval($instance['limit']), |
|
174 | 174 | 'orderby' => 'menu_order date', |
175 | 175 | 'order' => 'DESC', |
176 | 176 | 'post_status' => 'publish', |
177 | 177 | 'suppress_filters' => 0 |
178 | 178 | ); |
179 | - $posts_array = get_posts( $post_args ); |
|
179 | + $posts_array = get_posts($post_args); |
|
180 | 180 | |
181 | - if ( count( $posts_array ) > 0 ) { ?> |
|
181 | + if (count($posts_array) > 0) { ?> |
|
182 | 182 | <ul> |
183 | - <?php foreach ($posts_array as $post_item){ |
|
184 | - $post_id = absint( $post_item->ID ); |
|
183 | + <?php foreach ($posts_array as $post_item) { |
|
184 | + $post_id = absint($post_item->ID); |
|
185 | 185 | $post_title = $post_item->post_title; |
186 | - $user_info = get_userdata( absint( $post_item->post_author ) ); |
|
187 | - $author_link = get_author_posts_url( absint( $post_item->post_author ) ); |
|
186 | + $user_info = get_userdata(absint($post_item->post_author)); |
|
187 | + $author_link = get_author_posts_url(absint($post_item->post_author)); |
|
188 | 188 | $author_display_name = $user_info->display_name; |
189 | 189 | $author_id = $post_item->post_author; |
190 | - $lesson_course_id = get_post_meta( $post_id, '_lesson_course', true ); |
|
190 | + $lesson_course_id = get_post_meta($post_id, '_lesson_course', true); |
|
191 | 191 | ?> |
192 | 192 | <li class="fix"> |
193 | - <?php do_action( 'sensei_lesson_image', $post_id, '100', '100', false, true ); ?> |
|
194 | - <a href="<?php echo esc_url( get_permalink( $post_id ) ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a> |
|
193 | + <?php do_action('sensei_lesson_image', $post_id, '100', '100', false, true); ?> |
|
194 | + <a href="<?php echo esc_url(get_permalink($post_id)); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a> |
|
195 | 195 | <br /> |
196 | - <?php if ( isset( Sensei()->settings->settings[ 'lesson_author' ] ) && ( Sensei()->settings->settings[ 'lesson_author' ] ) ) { ?> |
|
197 | - <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><a href="<?php echo esc_url( $author_link ); ?>" title="<?php echo esc_attr( $author_display_name ); ?>"><?php echo esc_html( $author_display_name ); ?></a></span> |
|
196 | + <?php if (isset(Sensei()->settings->settings['lesson_author']) && (Sensei()->settings->settings['lesson_author'])) { ?> |
|
197 | + <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><a href="<?php echo esc_url($author_link); ?>" title="<?php echo esc_attr($author_display_name); ?>"><?php echo esc_html($author_display_name); ?></a></span> |
|
198 | 198 | <br /> |
199 | 199 | <?php } // End If Statement ?> |
200 | - <?php if ( 0 < $lesson_course_id ) { ?> |
|
201 | - <span class="lesson-course"><?php echo ' ' . sprintf( __( 'Part of: %s', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '" title="' . esc_attr( __( 'View course', 'woothemes-sensei' ) ) . '"><em>' . get_the_title( $lesson_course_id ) . '</em></a>' ); ?></span> |
|
200 | + <?php if (0 < $lesson_course_id) { ?> |
|
201 | + <span class="lesson-course"><?php echo ' '.sprintf(__('Part of: %s', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($lesson_course_id)).'" title="'.esc_attr(__('View course', 'woothemes-sensei')).'"><em>'.get_the_title($lesson_course_id).'</em></a>'); ?></span> |
|
202 | 202 | <?php } ?> |
203 | 203 | <br /> |
204 | 204 | </li> |
205 | 205 | <?php } // End For Loop ?> |
206 | - <?php echo '<li class="my-account fix"><a class="button" href="'. esc_url( get_post_type_archive_link( 'lesson' ) ) .'">'.__('More Lessons', 'woothemes-sensei').'</a></li>'; ?> |
|
206 | + <?php echo '<li class="my-account fix"><a class="button" href="'.esc_url(get_post_type_archive_link('lesson')).'">'.__('More Lessons', 'woothemes-sensei').'</a></li>'; ?> |
|
207 | 207 | </ul> |
208 | 208 | <?php } // End If Statement |
209 | 209 | } // End load_component() |