@@ -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 Grading Overview Data Table in Sensei. |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * Constructor |
22 | 22 | * @since 1.3.0 |
23 | 23 | */ |
24 | - public function __construct ( $args = null ) { |
|
24 | + public function __construct($args = null) { |
|
25 | 25 | |
26 | 26 | $defaults = array( |
27 | 27 | 'course_id' => 0, |
@@ -29,24 +29,24 @@ discard block |
||
29 | 29 | 'user_id' => false, |
30 | 30 | 'view' => 'ungraded', |
31 | 31 | ); |
32 | - $args = wp_parse_args( $args, $defaults ); |
|
32 | + $args = wp_parse_args($args, $defaults); |
|
33 | 33 | |
34 | - $this->course_id = intval( $args['course_id'] ); |
|
35 | - $this->lesson_id = intval( $args['lesson_id'] ); |
|
36 | - if ( !empty($args['user_id']) ) { |
|
37 | - $this->user_id = intval( $args['user_id'] ); |
|
34 | + $this->course_id = intval($args['course_id']); |
|
35 | + $this->lesson_id = intval($args['lesson_id']); |
|
36 | + if ( ! empty($args['user_id'])) { |
|
37 | + $this->user_id = intval($args['user_id']); |
|
38 | 38 | } |
39 | 39 | |
40 | - if( !empty( $args['view'] ) && in_array( $args['view'], array( 'in-progress', 'graded', 'ungraded', 'all' ) ) ) { |
|
40 | + if ( ! empty($args['view']) && in_array($args['view'], array('in-progress', 'graded', 'ungraded', 'all'))) { |
|
41 | 41 | $this->view = $args['view']; |
42 | 42 | } |
43 | 43 | |
44 | 44 | // Load Parent token into constructor |
45 | - parent::__construct( 'grading_main' ); |
|
45 | + parent::__construct('grading_main'); |
|
46 | 46 | |
47 | 47 | // Actions |
48 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
49 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
48 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
49 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
50 | 50 | } // End __construct() |
51 | 51 | |
52 | 52 | /** |
@@ -56,16 +56,16 @@ discard block |
||
56 | 56 | */ |
57 | 57 | function get_columns() { |
58 | 58 | $columns = array( |
59 | - 'title' => __( 'Learner', 'woothemes-sensei' ), |
|
60 | - 'course' => __( 'Course', 'woothemes-sensei' ), |
|
61 | - 'lesson' => __( 'Lesson', 'woothemes-sensei' ), |
|
62 | - 'updated' => __( 'Updated', 'woothemes-sensei' ), |
|
63 | - 'user_status' => __( 'Status', 'woothemes-sensei' ), |
|
64 | - 'user_grade' => __( 'Grade', 'woothemes-sensei' ), |
|
59 | + 'title' => __('Learner', 'woothemes-sensei'), |
|
60 | + 'course' => __('Course', 'woothemes-sensei'), |
|
61 | + 'lesson' => __('Lesson', 'woothemes-sensei'), |
|
62 | + 'updated' => __('Updated', 'woothemes-sensei'), |
|
63 | + 'user_status' => __('Status', 'woothemes-sensei'), |
|
64 | + 'user_grade' => __('Grade', 'woothemes-sensei'), |
|
65 | 65 | 'action' => '', |
66 | 66 | ); |
67 | 67 | |
68 | - $columns = apply_filters( 'sensei_grading_default_columns', $columns, $this ); |
|
68 | + $columns = apply_filters('sensei_grading_default_columns', $columns, $this); |
|
69 | 69 | return $columns; |
70 | 70 | } |
71 | 71 | |
@@ -76,14 +76,14 @@ discard block |
||
76 | 76 | */ |
77 | 77 | function get_sortable_columns() { |
78 | 78 | $columns = array( |
79 | - 'title' => array( 'title', false ), |
|
80 | - 'course' => array( 'course', false ), |
|
81 | - 'lesson' => array( 'lesson', false ), |
|
82 | - 'updated' => array( 'updated', false ), |
|
83 | - 'user_status' => array( 'user_status', false ), |
|
84 | - 'user_grade' => array( 'user_grade', false ), |
|
79 | + 'title' => array('title', false), |
|
80 | + 'course' => array('course', false), |
|
81 | + 'lesson' => array('lesson', false), |
|
82 | + 'updated' => array('updated', false), |
|
83 | + 'user_status' => array('user_status', false), |
|
84 | + 'user_grade' => array('user_grade', false), |
|
85 | 85 | ); |
86 | - $columns = apply_filters( 'sensei_grading_default_columns_sortable', $columns, $this ); |
|
86 | + $columns = apply_filters('sensei_grading_default_columns_sortable', $columns, $this); |
|
87 | 87 | return $columns; |
88 | 88 | } |
89 | 89 | |
@@ -97,47 +97,47 @@ discard block |
||
97 | 97 | |
98 | 98 | // Handle orderby |
99 | 99 | $orderby = ''; |
100 | - if ( !empty( $_GET['orderby'] ) ) { |
|
101 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
102 | - $orderby = esc_html( $_GET['orderby'] ); |
|
100 | + if ( ! empty($_GET['orderby'])) { |
|
101 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
102 | + $orderby = esc_html($_GET['orderby']); |
|
103 | 103 | } // End If Statement |
104 | 104 | } |
105 | 105 | |
106 | 106 | // Handle order |
107 | 107 | $order = 'DESC'; |
108 | - if ( !empty( $_GET['order'] ) ) { |
|
109 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
108 | + if ( ! empty($_GET['order'])) { |
|
109 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // Handle search |
113 | 113 | $search = false; |
114 | - if ( !empty( $_GET['s'] ) ) { |
|
115 | - $search = esc_html( $_GET['s'] ); |
|
114 | + if ( ! empty($_GET['s'])) { |
|
115 | + $search = esc_html($_GET['s']); |
|
116 | 116 | } // End If Statement |
117 | 117 | $this->search = $search; |
118 | 118 | |
119 | 119 | // Searching users on statuses requires sub-selecting the statuses by user_ids |
120 | - if ( $this->search ) { |
|
120 | + if ($this->search) { |
|
121 | 121 | $user_args = array( |
122 | - 'search' => '*' . $this->search . '*', |
|
122 | + 'search' => '*'.$this->search.'*', |
|
123 | 123 | 'fields' => 'ID', |
124 | 124 | ); |
125 | 125 | // Filter for extending |
126 | - $user_args = apply_filters( 'sensei_grading_search_users', $user_args ); |
|
127 | - if ( !empty( $user_args ) ) { |
|
128 | - $learners_search = new WP_User_Query( $user_args ); |
|
126 | + $user_args = apply_filters('sensei_grading_search_users', $user_args); |
|
127 | + if ( ! empty($user_args)) { |
|
128 | + $learners_search = new WP_User_Query($user_args); |
|
129 | 129 | // Store for reuse on counts |
130 | 130 | $this->user_ids = $learners_search->get_results(); |
131 | 131 | } |
132 | 132 | } // End If Statement |
133 | 133 | |
134 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
135 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
134 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
135 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
136 | 136 | |
137 | 137 | $paged = $this->get_pagenum(); |
138 | 138 | $offset = 0; |
139 | - if ( !empty($paged) ) { |
|
140 | - $offset = $per_page * ( $paged - 1 ); |
|
139 | + if ( ! empty($paged)) { |
|
140 | + $offset = $per_page * ($paged - 1); |
|
141 | 141 | } // End If Statement |
142 | 142 | |
143 | 143 | $activity_args = array( |
@@ -149,27 +149,27 @@ discard block |
||
149 | 149 | 'status' => 'any', |
150 | 150 | ); |
151 | 151 | |
152 | - if( $this->lesson_id ) { |
|
152 | + if ($this->lesson_id) { |
|
153 | 153 | $activity_args['post_id'] = $this->lesson_id; |
154 | 154 | } |
155 | - elseif( $this->course_id ) { |
|
155 | + elseif ($this->course_id) { |
|
156 | 156 | // Currently not possible to restrict to a single Course, as that requires WP_Comment to support multiple |
157 | 157 | // post_ids (i.e. every lesson within the Course), WP 4.1 ( https://core.trac.wordpress.org/changeset/29808 ) |
158 | - if ( version_compare($wp_version, '4.1', '>=') ) { |
|
159 | - $activity_args['post__in'] = Sensei()->course->course_lessons( $this->course_id, 'any', 'ids' ); |
|
158 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
159 | + $activity_args['post__in'] = Sensei()->course->course_lessons($this->course_id, 'any', 'ids'); |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | // Sub select to group of learners |
163 | - if ( $this->user_ids ) { |
|
163 | + if ($this->user_ids) { |
|
164 | 164 | $activity_args['user_id'] = (array) $this->user_ids; |
165 | 165 | } |
166 | 166 | // Restrict to a single Learner |
167 | - if( $this->user_id ) { |
|
167 | + if ($this->user_id) { |
|
168 | 168 | $activity_args['user_id'] = $this->user_id; |
169 | 169 | } |
170 | 170 | |
171 | 171 | |
172 | - switch( $this->view ) { |
|
172 | + switch ($this->view) { |
|
173 | 173 | case 'in-progress' : |
174 | 174 | $activity_args['status'] = 'in-progress'; |
175 | 175 | break; |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | break; |
180 | 180 | |
181 | 181 | case 'graded' : |
182 | - $activity_args['status'] = array( 'graded', 'passed', 'failed' ); |
|
182 | + $activity_args['status'] = array('graded', 'passed', 'failed'); |
|
183 | 183 | break; |
184 | 184 | |
185 | 185 | case 'all' : |
@@ -188,31 +188,31 @@ discard block |
||
188 | 188 | break; |
189 | 189 | } // End switch |
190 | 190 | |
191 | - $activity_args = apply_filters( 'sensei_grading_filter_statuses', $activity_args ); |
|
191 | + $activity_args = apply_filters('sensei_grading_filter_statuses', $activity_args); |
|
192 | 192 | |
193 | 193 | // WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice |
194 | - $total_statuses = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); |
|
194 | + $total_statuses = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0))); |
|
195 | 195 | |
196 | 196 | // Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views? |
197 | - if ( $total_statuses < $activity_args['offset'] ) { |
|
198 | - $new_paged = floor( $total_statuses / $activity_args['number'] ); |
|
197 | + if ($total_statuses < $activity_args['offset']) { |
|
198 | + $new_paged = floor($total_statuses / $activity_args['number']); |
|
199 | 199 | $activity_args['offset'] = $new_paged * $activity_args['number']; |
200 | 200 | } |
201 | - $statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true ); |
|
201 | + $statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true); |
|
202 | 202 | // Need to always return an array, even with only 1 item |
203 | - if ( !is_array($statuses) ) { |
|
204 | - $statuses = array( $statuses ); |
|
203 | + if ( ! is_array($statuses)) { |
|
204 | + $statuses = array($statuses); |
|
205 | 205 | } |
206 | 206 | $this->total_items = $total_statuses; |
207 | 207 | $this->items = $statuses; |
208 | 208 | |
209 | 209 | $total_items = $this->total_items; |
210 | - $total_pages = ceil( $total_items / $per_page ); |
|
211 | - $this->set_pagination_args( array( |
|
210 | + $total_pages = ceil($total_items / $per_page); |
|
211 | + $this->set_pagination_args(array( |
|
212 | 212 | 'total_items' => $total_items, |
213 | 213 | 'total_pages' => $total_pages, |
214 | 214 | 'per_page' => $per_page |
215 | - ) ); |
|
215 | + )); |
|
216 | 216 | } |
217 | 217 | |
218 | 218 | /** |
@@ -220,73 +220,73 @@ discard block |
||
220 | 220 | * @since 1.7.0 |
221 | 221 | * @param object $item The current item |
222 | 222 | */ |
223 | - protected function get_row_data( $item ) { |
|
223 | + protected function get_row_data($item) { |
|
224 | 224 | global $wp_version; |
225 | 225 | |
226 | 226 | $grade = ''; |
227 | - if( 'complete' == $item->comment_approved ) { |
|
228 | - $status_html = '<span class="graded">' . __( 'Completed', 'woothemes-sensei' ) . '</span>'; |
|
229 | - $grade = __( 'No Grade', 'woothemes-sensei' ); |
|
227 | + if ('complete' == $item->comment_approved) { |
|
228 | + $status_html = '<span class="graded">'.__('Completed', 'woothemes-sensei').'</span>'; |
|
229 | + $grade = __('No Grade', 'woothemes-sensei'); |
|
230 | 230 | } |
231 | - elseif( 'graded' == $item->comment_approved ) { |
|
232 | - $status_html = '<span class="graded">' . __( 'Graded', 'woothemes-sensei' ) . '</span>'; |
|
233 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true) . '%'; |
|
231 | + elseif ('graded' == $item->comment_approved) { |
|
232 | + $status_html = '<span class="graded">'.__('Graded', 'woothemes-sensei').'</span>'; |
|
233 | + $grade = get_comment_meta($item->comment_ID, 'grade', true).'%'; |
|
234 | 234 | } |
235 | - elseif( 'passed' == $item->comment_approved ) { |
|
236 | - $status_html = '<span class="passed">' . __( 'Passed', 'woothemes-sensei' ) . '</span>'; |
|
237 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true) . '%'; |
|
235 | + elseif ('passed' == $item->comment_approved) { |
|
236 | + $status_html = '<span class="passed">'.__('Passed', 'woothemes-sensei').'</span>'; |
|
237 | + $grade = get_comment_meta($item->comment_ID, 'grade', true).'%'; |
|
238 | 238 | } |
239 | - elseif( 'failed' == $item->comment_approved ) { |
|
240 | - $status_html = '<span class="failed">' . __( 'Failed', 'woothemes-sensei' ) . '</span>'; |
|
241 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true) . '%'; |
|
239 | + elseif ('failed' == $item->comment_approved) { |
|
240 | + $status_html = '<span class="failed">'.__('Failed', 'woothemes-sensei').'</span>'; |
|
241 | + $grade = get_comment_meta($item->comment_ID, 'grade', true).'%'; |
|
242 | 242 | } |
243 | - elseif( 'ungraded' == $item->comment_approved ) { |
|
244 | - $status_html = '<span class="ungraded">' . __( 'Ungraded', 'woothemes-sensei' ) . '</span>'; |
|
245 | - $grade = __( 'N/A', 'woothemes-sensei' ); |
|
243 | + elseif ('ungraded' == $item->comment_approved) { |
|
244 | + $status_html = '<span class="ungraded">'.__('Ungraded', 'woothemes-sensei').'</span>'; |
|
245 | + $grade = __('N/A', 'woothemes-sensei'); |
|
246 | 246 | } |
247 | 247 | else { |
248 | - $status_html = '<span class="in-progress">' . __( 'In Progress', 'woothemes-sensei' ) . '</span>'; |
|
249 | - $grade = __( 'N/A', 'woothemes-sensei' ); |
|
248 | + $status_html = '<span class="in-progress">'.__('In Progress', 'woothemes-sensei').'</span>'; |
|
249 | + $grade = __('N/A', 'woothemes-sensei'); |
|
250 | 250 | } |
251 | 251 | |
252 | - $title = Sensei_Learner::get_full_name( $item->user_id ); |
|
252 | + $title = Sensei_Learner::get_full_name($item->user_id); |
|
253 | 253 | |
254 | 254 | // QuizID to be deprecated |
255 | - $quiz_id = get_post_meta( $item->comment_post_ID, '_lesson_quiz', true ); |
|
256 | - $quiz_link = esc_url( add_query_arg( array( 'page' => $this->page_slug, 'user' => $item->user_id, 'quiz_id' => $quiz_id ), admin_url( 'admin.php' ) ) ); |
|
255 | + $quiz_id = get_post_meta($item->comment_post_ID, '_lesson_quiz', true); |
|
256 | + $quiz_link = esc_url(add_query_arg(array('page' => $this->page_slug, 'user' => $item->user_id, 'quiz_id' => $quiz_id), admin_url('admin.php'))); |
|
257 | 257 | |
258 | 258 | $grade_link = ''; |
259 | - switch( $item->comment_approved ) { |
|
259 | + switch ($item->comment_approved) { |
|
260 | 260 | case 'ungraded': |
261 | - $grade_link = '<a class="button-primary button" href="' . $quiz_link . '">' . __('Grade quiz', 'woothemes-sensei' ) . '</a>'; |
|
261 | + $grade_link = '<a class="button-primary button" href="'.$quiz_link.'">'.__('Grade quiz', 'woothemes-sensei').'</a>'; |
|
262 | 262 | break; |
263 | 263 | |
264 | 264 | case 'graded': |
265 | 265 | case 'passed': |
266 | 266 | case 'failed': |
267 | - $grade_link = '<a class="button-secondary button" href="' . $quiz_link . '">' . __('Review grade', 'woothemes-sensei' ) . '</a>'; |
|
267 | + $grade_link = '<a class="button-secondary button" href="'.$quiz_link.'">'.__('Review grade', 'woothemes-sensei').'</a>'; |
|
268 | 268 | break; |
269 | 269 | } |
270 | 270 | |
271 | - $course_id = get_post_meta( $item->comment_post_ID, '_lesson_course', true ); |
|
271 | + $course_id = get_post_meta($item->comment_post_ID, '_lesson_course', true); |
|
272 | 272 | $course_title = ''; |
273 | - if ( !empty($course_id) && version_compare($wp_version, '4.1', '>=') ) { |
|
274 | - $course_title = '<a href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id ), admin_url( 'admin.php' ) ) ) . '">' . get_the_title( $course_id ) . '</a>'; |
|
273 | + if ( ! empty($course_id) && version_compare($wp_version, '4.1', '>=')) { |
|
274 | + $course_title = '<a href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id), admin_url('admin.php'))).'">'.get_the_title($course_id).'</a>'; |
|
275 | 275 | } |
276 | - else if ( !empty($course_id) ) { |
|
277 | - $course_title = get_the_title( $course_id ); |
|
276 | + else if ( ! empty($course_id)) { |
|
277 | + $course_title = get_the_title($course_id); |
|
278 | 278 | } |
279 | - $lesson_title = '<a href="' . add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $item->comment_post_ID ), admin_url( 'admin.php' ) ) . '">' . get_the_title( $item->comment_post_ID ) . '</a>'; |
|
279 | + $lesson_title = '<a href="'.add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $item->comment_post_ID), admin_url('admin.php')).'">'.get_the_title($item->comment_post_ID).'</a>'; |
|
280 | 280 | |
281 | - $column_data = apply_filters( 'sensei_grading_main_column_data', array( |
|
282 | - 'title' => '<strong><a class="row-title" href="' . esc_url( add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id ), admin_url( 'admin.php' ) ) ) . '"">' . $title . '</a></strong>', |
|
281 | + $column_data = apply_filters('sensei_grading_main_column_data', array( |
|
282 | + 'title' => '<strong><a class="row-title" href="'.esc_url(add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->user_id), admin_url('admin.php'))).'"">'.$title.'</a></strong>', |
|
283 | 283 | 'course' => $course_title, |
284 | 284 | 'lesson' => $lesson_title, |
285 | 285 | 'updated' => $item->comment_date, |
286 | 286 | 'user_status' => $status_html, |
287 | 287 | 'user_grade' => $grade, |
288 | 288 | 'action' => $grade_link, |
289 | - ), $item, $course_id ); |
|
289 | + ), $item, $course_id); |
|
290 | 290 | |
291 | 291 | return $column_data; |
292 | 292 | } |
@@ -299,7 +299,7 @@ discard block |
||
299 | 299 | */ |
300 | 300 | public function no_items() { |
301 | 301 | |
302 | - _e( 'No submissions found.', 'woothemes-sensei' ); |
|
302 | + _e('No submissions found.', 'woothemes-sensei'); |
|
303 | 303 | |
304 | 304 | } // End no_items() |
305 | 305 | |
@@ -312,35 +312,35 @@ discard block |
||
312 | 312 | global $wp_version; |
313 | 313 | |
314 | 314 | echo '<div class="grading-selects">'; |
315 | - do_action( 'sensei_grading_before_dropdown_filters' ); |
|
315 | + do_action('sensei_grading_before_dropdown_filters'); |
|
316 | 316 | |
317 | - echo '<div class="select-box">' . "\n"; |
|
317 | + echo '<div class="select-box">'."\n"; |
|
318 | 318 | |
319 | - echo '<select id="grading-course-options" name="grading_course" class="chosen_select widefat">' . "\n"; |
|
319 | + echo '<select id="grading-course-options" name="grading_course" class="chosen_select widefat">'."\n"; |
|
320 | 320 | |
321 | - echo Sensei()->grading->courses_drop_down_html( $this->course_id ); |
|
321 | + echo Sensei()->grading->courses_drop_down_html($this->course_id); |
|
322 | 322 | |
323 | - echo '</select>' . "\n"; |
|
323 | + echo '</select>'."\n"; |
|
324 | 324 | |
325 | - echo '</div>' . "\n"; |
|
325 | + echo '</div>'."\n"; |
|
326 | 326 | |
327 | - echo '<div class="select-box">' . "\n"; |
|
327 | + echo '<div class="select-box">'."\n"; |
|
328 | 328 | |
329 | - echo '<select id="grading-lesson-options" data-placeholder="← ' . __( 'Select a course', 'woothemes-sensei' ) . '" name="grading_lesson" class="chosen_select widefat">' . "\n"; |
|
329 | + echo '<select id="grading-lesson-options" data-placeholder="← '.__('Select a course', 'woothemes-sensei').'" name="grading_lesson" class="chosen_select widefat">'."\n"; |
|
330 | 330 | |
331 | - echo Sensei()->grading->lessons_drop_down_html( $this->course_id, $this->lesson_id ); |
|
331 | + echo Sensei()->grading->lessons_drop_down_html($this->course_id, $this->lesson_id); |
|
332 | 332 | |
333 | - echo '</select>' . "\n"; |
|
333 | + echo '</select>'."\n"; |
|
334 | 334 | |
335 | - echo '</div>' . "\n"; |
|
335 | + echo '</div>'."\n"; |
|
336 | 336 | |
337 | - if( $this->course_id && $this->lesson_id ) { |
|
337 | + if ($this->course_id && $this->lesson_id) { |
|
338 | 338 | |
339 | - echo '<div class="select-box reset-filter">' . "\n"; |
|
339 | + echo '<div class="select-box reset-filter">'."\n"; |
|
340 | 340 | |
341 | - echo '<a class="button-secondary" href="' . esc_url( remove_query_arg( array( 'lesson_id', 'course_id' ) ) ) . '">' . __( 'Reset filter', 'woothemes-sensei' ) . '</a>' . "\n"; |
|
341 | + echo '<a class="button-secondary" href="'.esc_url(remove_query_arg(array('lesson_id', 'course_id'))).'">'.__('Reset filter', 'woothemes-sensei').'</a>'."\n"; |
|
342 | 342 | |
343 | - echo '</div>' . "\n"; |
|
343 | + echo '</div>'."\n"; |
|
344 | 344 | |
345 | 345 | } |
346 | 346 | |
@@ -355,26 +355,26 @@ discard block |
||
355 | 355 | $query_args = array( |
356 | 356 | 'page' => $this->page_slug, |
357 | 357 | ); |
358 | - if( $this->course_id ) { |
|
358 | + if ($this->course_id) { |
|
359 | 359 | // Currently not possible to restrict to a single Course, as that requires WP_Comment to support multiple |
360 | 360 | // post_ids (i.e. every lesson within the Course), WP 4.1 ( https://core.trac.wordpress.org/changeset/29808 ) |
361 | 361 | $query_args['course_id'] = $this->course_id; |
362 | - if ( version_compare($wp_version, '4.1', '>=') ) { |
|
363 | - $count_args['post__in'] = Sensei()->course->course_lessons( $this->course_id, 'any', 'ids' ); |
|
362 | + if (version_compare($wp_version, '4.1', '>=')) { |
|
363 | + $count_args['post__in'] = Sensei()->course->course_lessons($this->course_id, 'any', 'ids'); |
|
364 | 364 | } |
365 | 365 | } |
366 | - if( $this->lesson_id ) { |
|
366 | + if ($this->lesson_id) { |
|
367 | 367 | $query_args['lesson_id'] = $this->lesson_id; |
368 | 368 | // Restrict to a single lesson |
369 | 369 | $count_args['post_id'] = $this->lesson_id; |
370 | 370 | } |
371 | - if( $this->search ) { |
|
371 | + if ($this->search) { |
|
372 | 372 | $query_args['s'] = $this->search; |
373 | 373 | } |
374 | - if ( !empty($this->user_ids) ) { |
|
374 | + if ( ! empty($this->user_ids)) { |
|
375 | 375 | $count_args['user_id'] = $this->user_ids; |
376 | 376 | } |
377 | - if( !empty($this->user_id) ) { |
|
377 | + if ( ! empty($this->user_id)) { |
|
378 | 378 | $query_args['user_id'] = $this->user_id; |
379 | 379 | $count_args['user_id'] = $this->user_id; |
380 | 380 | } |
@@ -382,7 +382,7 @@ discard block |
||
382 | 382 | $all_lessons_count = $ungraded_lessons_count = $graded_lessons_count = $inprogress_lessons_count = 0; |
383 | 383 | $all_class = $ungraded_class = $graded_class = $inprogress_class = ''; |
384 | 384 | |
385 | - switch( $this->view ) : |
|
385 | + switch ($this->view) : |
|
386 | 386 | case 'all': |
387 | 387 | $all_class = 'current'; |
388 | 388 | break; |
@@ -398,7 +398,7 @@ discard block |
||
398 | 398 | break; |
399 | 399 | endswitch; |
400 | 400 | |
401 | - $counts = Sensei()->grading->count_statuses( apply_filters( 'sensei_grading_count_statues', $count_args ) ); |
|
401 | + $counts = Sensei()->grading->count_statuses(apply_filters('sensei_grading_count_statues', $count_args)); |
|
402 | 402 | |
403 | 403 | $inprogress_lessons_count = $counts['in-progress']; |
404 | 404 | $ungraded_lessons_count = $counts['ungraded']; |
@@ -414,19 +414,19 @@ discard block |
||
414 | 414 | $inprogress_args['view'] = 'in-progress'; |
415 | 415 | |
416 | 416 | $format = '<a class="%s" href="%s">%s <span class="count">(%s)</span></a>'; |
417 | - $menu['all'] = sprintf( $format, $all_class, esc_url( add_query_arg( $all_args, admin_url( 'admin.php' ) ) ), __( 'All', 'woothemes-sensei' ), number_format( (int) $all_lessons_count ) ); |
|
418 | - $menu['ungraded'] = sprintf( $format, $ungraded_class, esc_url( add_query_arg( $ungraded_args, admin_url( 'admin.php' ) ) ), __( 'Ungraded', 'woothemes-sensei' ), number_format( (int) $ungraded_lessons_count ) ); |
|
419 | - $menu['graded'] = sprintf( $format, $graded_class, esc_url( add_query_arg( $graded_args, admin_url( 'admin.php' ) ) ), __( 'Graded', 'woothemes-sensei' ), number_format( (int) $graded_lessons_count ) ); |
|
420 | - $menu['in-progress'] = sprintf( $format, $inprogress_class, esc_url( add_query_arg( $inprogress_args, admin_url( 'admin.php' ) ) ), __( 'In Progress', 'woothemes-sensei' ), number_format( (int) $inprogress_lessons_count ) ); |
|
421 | - |
|
422 | - $menu = apply_filters( 'sensei_grading_sub_menu', $menu ); |
|
423 | - if ( !empty($menu) ) { |
|
424 | - echo '<ul class="subsubsub">' . "\n"; |
|
425 | - foreach ( $menu as $class => $item ) { |
|
426 | - $menu[ $class ] = "\t<li class='$class'>$item"; |
|
417 | + $menu['all'] = sprintf($format, $all_class, esc_url(add_query_arg($all_args, admin_url('admin.php'))), __('All', 'woothemes-sensei'), number_format((int) $all_lessons_count)); |
|
418 | + $menu['ungraded'] = sprintf($format, $ungraded_class, esc_url(add_query_arg($ungraded_args, admin_url('admin.php'))), __('Ungraded', 'woothemes-sensei'), number_format((int) $ungraded_lessons_count)); |
|
419 | + $menu['graded'] = sprintf($format, $graded_class, esc_url(add_query_arg($graded_args, admin_url('admin.php'))), __('Graded', 'woothemes-sensei'), number_format((int) $graded_lessons_count)); |
|
420 | + $menu['in-progress'] = sprintf($format, $inprogress_class, esc_url(add_query_arg($inprogress_args, admin_url('admin.php'))), __('In Progress', 'woothemes-sensei'), number_format((int) $inprogress_lessons_count)); |
|
421 | + |
|
422 | + $menu = apply_filters('sensei_grading_sub_menu', $menu); |
|
423 | + if ( ! empty($menu)) { |
|
424 | + echo '<ul class="subsubsub">'."\n"; |
|
425 | + foreach ($menu as $class => $item) { |
|
426 | + $menu[$class] = "\t<li class='$class'>$item"; |
|
427 | 427 | } |
428 | - echo implode( " |</li>\n", $menu ) . "</li>\n"; |
|
429 | - echo '</ul>' . "\n"; |
|
428 | + echo implode(" |</li>\n", $menu)."</li>\n"; |
|
429 | + echo '</ul>'."\n"; |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | } // End data_table_header() |
@@ -447,4 +447,4 @@ discard block |
||
447 | 447 | * @ignore only for backward compatibility |
448 | 448 | * @since 1.9.0 |
449 | 449 | */ |
450 | -class WooThemes_Sensei_Grading_Main extends Sensei_Grading_Main{} |
|
450 | +class WooThemes_Sensei_Grading_Main extends Sensei_Grading_Main {} |
@@ -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 Lesson Data Table in Sensei. |
@@ -18,18 +18,18 @@ discard block |
||
18 | 18 | * Constructor |
19 | 19 | * @since 1.2.0 |
20 | 20 | */ |
21 | - public function __construct ( $lesson_id = 0 ) { |
|
22 | - $this->lesson_id = intval( $lesson_id ); |
|
23 | - $this->course_id = intval( get_post_meta( $this->lesson_id, '_lesson_course', true ) ); |
|
21 | + public function __construct($lesson_id = 0) { |
|
22 | + $this->lesson_id = intval($lesson_id); |
|
23 | + $this->course_id = intval(get_post_meta($this->lesson_id, '_lesson_course', true)); |
|
24 | 24 | |
25 | 25 | // Load Parent token into constructor |
26 | - parent::__construct( 'analysis_lesson' ); |
|
26 | + parent::__construct('analysis_lesson'); |
|
27 | 27 | |
28 | 28 | // Actions |
29 | - add_action( 'sensei_before_list_table', array( $this, 'data_table_header' ) ); |
|
30 | - add_action( 'sensei_after_list_table', array( $this, 'data_table_footer' ) ); |
|
29 | + add_action('sensei_before_list_table', array($this, 'data_table_header')); |
|
30 | + add_action('sensei_after_list_table', array($this, 'data_table_footer')); |
|
31 | 31 | |
32 | - add_filter( 'sensei_list_table_search_button_text', array( $this, 'search_button' ) ); |
|
32 | + add_filter('sensei_list_table_search_button_text', array($this, 'search_button')); |
|
33 | 33 | } // End __construct() |
34 | 34 | |
35 | 35 | /** |
@@ -39,13 +39,13 @@ discard block |
||
39 | 39 | */ |
40 | 40 | function get_columns() { |
41 | 41 | $columns = array( |
42 | - 'title' => __( 'Learner', 'woothemes-sensei' ), |
|
43 | - 'started' => __( 'Date Started', 'woothemes-sensei' ), |
|
44 | - 'completed' => __( 'Date Completed', 'woothemes-sensei' ), |
|
45 | - 'status' => __( 'Status', 'woothemes-sensei' ), |
|
46 | - 'grade' => __( 'Grade', 'woothemes-sensei' ), |
|
42 | + 'title' => __('Learner', 'woothemes-sensei'), |
|
43 | + 'started' => __('Date Started', 'woothemes-sensei'), |
|
44 | + 'completed' => __('Date Completed', 'woothemes-sensei'), |
|
45 | + 'status' => __('Status', 'woothemes-sensei'), |
|
46 | + 'grade' => __('Grade', 'woothemes-sensei'), |
|
47 | 47 | ); |
48 | - $columns = apply_filters( 'sensei_analysis_lesson_columns', $columns, $this ); |
|
48 | + $columns = apply_filters('sensei_analysis_lesson_columns', $columns, $this); |
|
49 | 49 | return $columns; |
50 | 50 | } |
51 | 51 | |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | */ |
57 | 57 | function get_sortable_columns() { |
58 | 58 | $columns = array( |
59 | - 'title' => array( 'title', false ), |
|
60 | - 'started' => array( 'started', false ), |
|
61 | - 'completed' => array( 'completed', false ), |
|
62 | - 'status' => array( 'status', false ), |
|
63 | - 'grade' => array( 'grade', false ), |
|
59 | + 'title' => array('title', false), |
|
60 | + 'started' => array('started', false), |
|
61 | + 'completed' => array('completed', false), |
|
62 | + 'status' => array('status', false), |
|
63 | + 'grade' => array('grade', false), |
|
64 | 64 | ); |
65 | - $columns = apply_filters( 'sensei_analysis_lesson_columns_sortable', $columns, $this ); |
|
65 | + $columns = apply_filters('sensei_analysis_lesson_columns_sortable', $columns, $this); |
|
66 | 66 | return $columns; |
67 | 67 | } |
68 | 68 | |
@@ -76,32 +76,32 @@ discard block |
||
76 | 76 | |
77 | 77 | // Handle orderby (needs work) |
78 | 78 | $orderby = ''; |
79 | - if ( !empty( $_GET['orderby'] ) ) { |
|
80 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
81 | - $orderby = esc_html( $_GET['orderby'] ); |
|
79 | + if ( ! empty($_GET['orderby'])) { |
|
80 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
81 | + $orderby = esc_html($_GET['orderby']); |
|
82 | 82 | } // End If Statement |
83 | 83 | } |
84 | 84 | |
85 | 85 | // Handle order |
86 | 86 | $order = 'ASC'; |
87 | - if ( !empty( $_GET['order'] ) ) { |
|
88 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
87 | + if ( ! empty($_GET['order'])) { |
|
88 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | // Handle search, need 4.1 version of WP to be able to restrict statuses to known post_ids |
92 | 92 | $search = false; |
93 | - if ( !empty( $_GET['s'] ) ) { |
|
94 | - $search = esc_html( $_GET['s'] ); |
|
93 | + if ( ! empty($_GET['s'])) { |
|
94 | + $search = esc_html($_GET['s']); |
|
95 | 95 | } // End If Statement |
96 | 96 | $this->search = $search; |
97 | 97 | |
98 | - $per_page = $this->get_items_per_page( 'sensei_comments_per_page' ); |
|
99 | - $per_page = apply_filters( 'sensei_comments_per_page', $per_page, 'sensei_comments' ); |
|
98 | + $per_page = $this->get_items_per_page('sensei_comments_per_page'); |
|
99 | + $per_page = apply_filters('sensei_comments_per_page', $per_page, 'sensei_comments'); |
|
100 | 100 | |
101 | 101 | $paged = $this->get_pagenum(); |
102 | 102 | $offset = 0; |
103 | - if ( !empty($paged) ) { |
|
104 | - $offset = $per_page * ( $paged - 1 ); |
|
103 | + if ( ! empty($paged)) { |
|
104 | + $offset = $per_page * ($paged - 1); |
|
105 | 105 | } // End If Statement |
106 | 106 | |
107 | 107 | $args = array( |
@@ -110,19 +110,19 @@ discard block |
||
110 | 110 | 'orderby' => $orderby, |
111 | 111 | 'order' => $order, |
112 | 112 | ); |
113 | - if ( $this->search ) { |
|
113 | + if ($this->search) { |
|
114 | 114 | $args['search'] = $this->search; |
115 | 115 | } // End If Statement |
116 | 116 | |
117 | - $this->items = $this->get_lesson_statuses( $args ); |
|
117 | + $this->items = $this->get_lesson_statuses($args); |
|
118 | 118 | |
119 | 119 | $total_items = $this->total_items; |
120 | - $total_pages = ceil( $total_items / $per_page ); |
|
121 | - $this->set_pagination_args( array( |
|
120 | + $total_pages = ceil($total_items / $per_page); |
|
121 | + $this->set_pagination_args(array( |
|
122 | 122 | 'total_items' => $total_items, |
123 | 123 | 'total_pages' => $total_pages, |
124 | 124 | 'per_page' => $per_page |
125 | - ) ); |
|
125 | + )); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @since 1.7.0 |
131 | 131 | * @return data |
132 | 132 | */ |
133 | - public function generate_report( $report ) { |
|
133 | + public function generate_report($report) { |
|
134 | 134 | |
135 | 135 | $data = array(); |
136 | 136 | |
@@ -138,22 +138,22 @@ discard block |
||
138 | 138 | |
139 | 139 | // Handle orderby |
140 | 140 | $orderby = ''; |
141 | - if ( !empty( $_GET['orderby'] ) ) { |
|
142 | - if ( array_key_exists( esc_html( $_GET['orderby'] ), $this->get_sortable_columns() ) ) { |
|
143 | - $orderby = esc_html( $_GET['orderby'] ); |
|
141 | + if ( ! empty($_GET['orderby'])) { |
|
142 | + if (array_key_exists(esc_html($_GET['orderby']), $this->get_sortable_columns())) { |
|
143 | + $orderby = esc_html($_GET['orderby']); |
|
144 | 144 | } // End If Statement |
145 | 145 | } |
146 | 146 | |
147 | 147 | // Handle order |
148 | 148 | $order = 'ASC'; |
149 | - if ( !empty( $_GET['order'] ) ) { |
|
150 | - $order = ( 'ASC' == strtoupper($_GET['order']) ) ? 'ASC' : 'DESC'; |
|
149 | + if ( ! empty($_GET['order'])) { |
|
150 | + $order = ('ASC' == strtoupper($_GET['order'])) ? 'ASC' : 'DESC'; |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Handle search |
154 | 154 | $search = false; |
155 | - if ( !empty( $_GET['s'] ) ) { |
|
156 | - $search = esc_html( $_GET['s'] ); |
|
155 | + if ( ! empty($_GET['s'])) { |
|
156 | + $search = esc_html($_GET['s']); |
|
157 | 157 | } // End If Statement |
158 | 158 | $this->search = $search; |
159 | 159 | |
@@ -161,23 +161,23 @@ discard block |
||
161 | 161 | 'orderby' => $orderby, |
162 | 162 | 'order' => $order, |
163 | 163 | ); |
164 | - if ( $this->search ) { |
|
164 | + if ($this->search) { |
|
165 | 165 | $args['search'] = $this->search; |
166 | 166 | } // End If Statement |
167 | 167 | |
168 | 168 | // Start the csv with the column headings |
169 | 169 | $column_headers = array(); |
170 | 170 | $columns = $this->get_columns(); |
171 | - foreach( $columns AS $key => $title ) { |
|
171 | + foreach ($columns AS $key => $title) { |
|
172 | 172 | $column_headers[] = $title; |
173 | 173 | } |
174 | 174 | $data[] = $column_headers; |
175 | 175 | |
176 | - $this->items = $this->get_lesson_statuses( $args ); |
|
176 | + $this->items = $this->get_lesson_statuses($args); |
|
177 | 177 | |
178 | 178 | // Process each row |
179 | - foreach( $this->items AS $item) { |
|
180 | - $data[] = $this->get_row_data( $item ); |
|
179 | + foreach ($this->items AS $item) { |
|
180 | + $data[] = $this->get_row_data($item); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | return $data; |
@@ -189,64 +189,64 @@ discard block |
||
189 | 189 | * @since 1.7.0 |
190 | 190 | * @param object $item The current item |
191 | 191 | */ |
192 | - protected function get_row_data( $item ) { |
|
192 | + protected function get_row_data($item) { |
|
193 | 193 | |
194 | - $user_start_date = get_comment_meta( $item->comment_ID, 'start', true ); |
|
194 | + $user_start_date = get_comment_meta($item->comment_ID, 'start', true); |
|
195 | 195 | $user_end_date = $item->comment_date; |
196 | 196 | $status_class = $grade = ''; |
197 | 197 | |
198 | - if( 'complete' == $item->comment_approved ) { |
|
199 | - $status = __( 'Completed', 'woothemes-sensei' ); |
|
198 | + if ('complete' == $item->comment_approved) { |
|
199 | + $status = __('Completed', 'woothemes-sensei'); |
|
200 | 200 | $status_class = 'graded'; |
201 | 201 | |
202 | - $grade = __( 'No Grade', 'woothemes-sensei' ); |
|
202 | + $grade = __('No Grade', 'woothemes-sensei'); |
|
203 | 203 | } |
204 | - elseif( 'graded' == $item->comment_approved ) { |
|
205 | - $status = __( 'Graded', 'woothemes-sensei' ) ; |
|
204 | + elseif ('graded' == $item->comment_approved) { |
|
205 | + $status = __('Graded', 'woothemes-sensei'); |
|
206 | 206 | $status_class = 'graded'; |
207 | 207 | |
208 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
|
208 | + $grade = get_comment_meta($item->comment_ID, 'grade', true); |
|
209 | 209 | } |
210 | - elseif( 'passed' == $item->comment_approved ) { |
|
211 | - $status = __( 'Passed', 'woothemes-sensei' ); |
|
210 | + elseif ('passed' == $item->comment_approved) { |
|
211 | + $status = __('Passed', 'woothemes-sensei'); |
|
212 | 212 | $status_class = 'graded'; |
213 | 213 | |
214 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
|
214 | + $grade = get_comment_meta($item->comment_ID, 'grade', true); |
|
215 | 215 | } |
216 | - elseif( 'failed' == $item->comment_approved ) { |
|
217 | - $status = __( 'Failed', 'woothemes-sensei' ); |
|
216 | + elseif ('failed' == $item->comment_approved) { |
|
217 | + $status = __('Failed', 'woothemes-sensei'); |
|
218 | 218 | $status_class = 'failed'; |
219 | 219 | |
220 | - $grade = get_comment_meta( $item->comment_ID, 'grade', true); |
|
220 | + $grade = get_comment_meta($item->comment_ID, 'grade', true); |
|
221 | 221 | } |
222 | - elseif( 'ungraded' == $item->comment_approved ) { |
|
223 | - $status = __( 'Ungraded', 'woothemes-sensei' ); |
|
222 | + elseif ('ungraded' == $item->comment_approved) { |
|
223 | + $status = __('Ungraded', 'woothemes-sensei'); |
|
224 | 224 | $status_class = 'ungraded'; |
225 | 225 | |
226 | 226 | } |
227 | 227 | else { |
228 | - $status = __( 'In Progress', 'woothemes-sensei' ); |
|
228 | + $status = __('In Progress', 'woothemes-sensei'); |
|
229 | 229 | $user_end_date = ''; |
230 | 230 | } |
231 | 231 | |
232 | 232 | // Output users data |
233 | - $user_name = Sensei_Learner::get_full_name( $item->user_id ); |
|
233 | + $user_name = Sensei_Learner::get_full_name($item->user_id); |
|
234 | 234 | |
235 | - if ( !$this->csv_output ) { |
|
236 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id ), admin_url( 'admin.php' ) ); |
|
235 | + if ( ! $this->csv_output) { |
|
236 | + $url = add_query_arg(array('page' => $this->page_slug, 'user_id' => $item->user_id, 'course_id' => $this->course_id), admin_url('admin.php')); |
|
237 | 237 | |
238 | - $user_name = '<strong><a class="row-title" href="' . esc_url( $url ) . '">' . $user_name . '</a></strong>'; |
|
239 | - $status = sprintf( '<span class="%s">%s</span>', $item->comment_approved, $status ); |
|
240 | - if ( is_numeric($grade) ) { |
|
238 | + $user_name = '<strong><a class="row-title" href="'.esc_url($url).'">'.$user_name.'</a></strong>'; |
|
239 | + $status = sprintf('<span class="%s">%s</span>', $item->comment_approved, $status); |
|
240 | + if (is_numeric($grade)) { |
|
241 | 241 | $grade .= '%'; |
242 | 242 | } |
243 | 243 | } // End If Statement |
244 | - $column_data = apply_filters( 'sensei_analysis_lesson_column_data', array( 'title' => $user_name, |
|
244 | + $column_data = apply_filters('sensei_analysis_lesson_column_data', array('title' => $user_name, |
|
245 | 245 | 'started' => $user_start_date, |
246 | 246 | 'completed' => $user_end_date, |
247 | 247 | 'status' => $status, |
248 | 248 | 'grade' => $grade, |
249 | - ), $item, $this ); |
|
249 | + ), $item, $this); |
|
250 | 250 | |
251 | 251 | return $column_data; |
252 | 252 | } |
@@ -256,7 +256,7 @@ discard block |
||
256 | 256 | * @since 1.7.0 |
257 | 257 | * @return array statuses |
258 | 258 | */ |
259 | - private function get_lesson_statuses( $args ) { |
|
259 | + private function get_lesson_statuses($args) { |
|
260 | 260 | |
261 | 261 | $activity_args = array( |
262 | 262 | 'post_id' => $this->lesson_id, |
@@ -269,34 +269,34 @@ discard block |
||
269 | 269 | ); |
270 | 270 | |
271 | 271 | // Searching users on statuses requires sub-selecting the statuses by user_ids |
272 | - if ( $this->search ) { |
|
272 | + if ($this->search) { |
|
273 | 273 | $user_args = array( |
274 | - 'search' => '*' . $this->search . '*', |
|
274 | + 'search' => '*'.$this->search.'*', |
|
275 | 275 | 'fields' => 'ID', |
276 | 276 | ); |
277 | 277 | // Filter for extending |
278 | - $user_args = apply_filters( 'sensei_analysis_lesson_search_users', $user_args ); |
|
279 | - if ( !empty( $user_args ) ) { |
|
280 | - $learners_search = new WP_User_Query( $user_args ); |
|
278 | + $user_args = apply_filters('sensei_analysis_lesson_search_users', $user_args); |
|
279 | + if ( ! empty($user_args)) { |
|
280 | + $learners_search = new WP_User_Query($user_args); |
|
281 | 281 | // Store for reuse on counts |
282 | 282 | $activity_args['user_id'] = (array) $learners_search->get_results(); |
283 | 283 | } |
284 | 284 | } // End If Statement |
285 | 285 | |
286 | - $activity_args = apply_filters( 'sensei_analysis_lesson_filter_statuses', $activity_args ); |
|
286 | + $activity_args = apply_filters('sensei_analysis_lesson_filter_statuses', $activity_args); |
|
287 | 287 | |
288 | 288 | // WP_Comment_Query doesn't support SQL_CALC_FOUND_ROWS, so instead do this twice |
289 | - $this->total_items = Sensei_Utils::sensei_check_for_activity( array_merge( $activity_args, array('count' => true, 'offset' => 0, 'number' => 0) ) ); |
|
289 | + $this->total_items = Sensei_Utils::sensei_check_for_activity(array_merge($activity_args, array('count' => true, 'offset' => 0, 'number' => 0))); |
|
290 | 290 | |
291 | 291 | // Ensure we change our range to fit (in case a search threw off the pagination) - Should this be added to all views? |
292 | - if ( $this->total_items < $activity_args['offset'] ) { |
|
293 | - $new_paged = floor( $total_statuses / $activity_args['number'] ); |
|
292 | + if ($this->total_items < $activity_args['offset']) { |
|
293 | + $new_paged = floor($total_statuses / $activity_args['number']); |
|
294 | 294 | $activity_args['offset'] = $new_paged * $activity_args['number']; |
295 | 295 | } |
296 | - $statuses = Sensei_Utils::sensei_check_for_activity( $activity_args, true ); |
|
296 | + $statuses = Sensei_Utils::sensei_check_for_activity($activity_args, true); |
|
297 | 297 | // Need to always return an array, even with only 1 item |
298 | - if ( !is_array($statuses) ) { |
|
299 | - $statuses = array( $statuses ); |
|
298 | + if ( ! is_array($statuses)) { |
|
299 | + $statuses = array($statuses); |
|
300 | 300 | } |
301 | 301 | return $statuses; |
302 | 302 | } // End get_lesson_statuses() |
@@ -308,7 +308,7 @@ discard block |
||
308 | 308 | * @return void |
309 | 309 | */ |
310 | 310 | public function no_items() { |
311 | - _e( 'No learners found.', 'woothemes-sensei' ); |
|
311 | + _e('No learners found.', 'woothemes-sensei'); |
|
312 | 312 | } // End no_items() |
313 | 313 | |
314 | 314 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @return void |
318 | 318 | */ |
319 | 319 | public function data_table_header() { |
320 | - echo '<strong>' . __( 'Learners taking this Lesson', 'woothemes-sensei' ) . '</strong>'; |
|
320 | + echo '<strong>'.__('Learners taking this Lesson', 'woothemes-sensei').'</strong>'; |
|
321 | 321 | } // End data_table_header() |
322 | 322 | |
323 | 323 | /** |
@@ -326,10 +326,10 @@ discard block |
||
326 | 326 | * @return void |
327 | 327 | */ |
328 | 328 | public function data_table_footer() { |
329 | - $lesson = get_post( $this->lesson_id ); |
|
330 | - $report = sanitize_title( $lesson->post_title ) . '-learners-overview'; |
|
331 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'lesson_id' => $this->lesson_id, 'sensei_report_download' => $report ), admin_url( 'admin.php' ) ); |
|
332 | - echo '<a class="button button-primary" href="' . esc_url( wp_nonce_url( $url, 'sensei_csv_download-' . $report, '_sdl_nonce' ) ) . '">' . __( 'Export all rows (CSV)', 'woothemes-sensei' ) . '</a>'; |
|
329 | + $lesson = get_post($this->lesson_id); |
|
330 | + $report = sanitize_title($lesson->post_title).'-learners-overview'; |
|
331 | + $url = add_query_arg(array('page' => $this->page_slug, 'lesson_id' => $this->lesson_id, 'sensei_report_download' => $report), admin_url('admin.php')); |
|
332 | + echo '<a class="button button-primary" href="'.esc_url(wp_nonce_url($url, 'sensei_csv_download-'.$report, '_sdl_nonce')).'">'.__('Export all rows (CSV)', 'woothemes-sensei').'</a>'; |
|
333 | 333 | } // End data_table_footer() |
334 | 334 | |
335 | 335 | /** |
@@ -337,9 +337,9 @@ discard block |
||
337 | 337 | * @since 1.7.0 |
338 | 338 | * @return string $text |
339 | 339 | */ |
340 | - public function search_button( $text = '' ) { |
|
340 | + public function search_button($text = '') { |
|
341 | 341 | |
342 | - $text = __( 'Search Learners', 'woothemes-sensei' ); |
|
342 | + $text = __('Search Learners', 'woothemes-sensei'); |
|
343 | 343 | |
344 | 344 | return $text; |
345 | 345 |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * |
9 | 9 | * @since 1.9.0 |
10 | 10 | */ |
11 | -class Sensei_Learner{ |
|
11 | +class Sensei_Learner { |
|
12 | 12 | |
13 | 13 | /** |
14 | 14 | * Get the students full name |
@@ -19,25 +19,25 @@ discard block |
||
19 | 19 | * @param $user_id |
20 | 20 | * @return bool|mixed|void |
21 | 21 | */ |
22 | - public static function get_full_name( $user_id ){ |
|
22 | + public static function get_full_name($user_id) { |
|
23 | 23 | |
24 | 24 | $full_name = ''; |
25 | 25 | |
26 | - if( empty( $user_id ) || ! ( 0 < intval( $user_id ) ) |
|
27 | - || !( get_userdata( $user_id ) ) ){ |
|
26 | + if (empty($user_id) || ! (0 < intval($user_id)) |
|
27 | + || ! (get_userdata($user_id))) { |
|
28 | 28 | return false; |
29 | 29 | } |
30 | 30 | |
31 | 31 | // get the user details |
32 | - $user = get_user_by( 'id', $user_id ); |
|
32 | + $user = get_user_by('id', $user_id); |
|
33 | 33 | |
34 | - if( ! empty( $user->first_name ) && ! empty( $user->last_name ) ){ |
|
34 | + if ( ! empty($user->first_name) && ! empty($user->last_name)) { |
|
35 | 35 | |
36 | - $full_name = trim( $user->first_name ) . ' ' . trim( $user->last_name ); |
|
36 | + $full_name = trim($user->first_name).' '.trim($user->last_name); |
|
37 | 37 | |
38 | - }else{ |
|
38 | + } else { |
|
39 | 39 | |
40 | - $full_name = $user->display_name; |
|
40 | + $full_name = $user->display_name; |
|
41 | 41 | |
42 | 42 | } |
43 | 43 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param $full_name |
49 | 49 | * @param $user_id |
50 | 50 | */ |
51 | - return apply_filters( 'sensei_learner_full_name' , $full_name , $user_id ); |
|
51 | + return apply_filters('sensei_learner_full_name', $full_name, $user_id); |
|
52 | 52 | |
53 | 53 | }// end get_full_name |
54 | 54 |
@@ -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,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,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,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
3 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
4 | 4 | |
5 | -if ( ! class_exists( 'WooThemes_Sensei_Email_New_Message_Reply' ) ) : |
|
5 | +if ( ! class_exists('WooThemes_Sensei_Email_New_Message_Reply')) : |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * Teacher New Message |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | */ |
58 | 58 | function __construct() { |
59 | 59 | $this->template = 'new-message-reply'; |
60 | - $this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] You have a new message', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template ); |
|
61 | - $this->heading = apply_filters( 'sensei_email_heading', __( 'You have received a reply to your private message', 'woothemes-sensei' ), $this->template ); |
|
60 | + $this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] You have a new message', 'woothemes-sensei'), get_bloginfo('name')), $this->template); |
|
61 | + $this->heading = apply_filters('sensei_email_heading', __('You have received a reply to your private message', 'woothemes-sensei'), $this->template); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -69,35 +69,35 @@ discard block |
||
69 | 69 | * |
70 | 70 | * @return void |
71 | 71 | */ |
72 | - function trigger ( $comment, $message ) { |
|
72 | + function trigger($comment, $message) { |
|
73 | 73 | |
74 | 74 | global $sensei_email_data; |
75 | 75 | |
76 | 76 | $this->comment = $comment; |
77 | 77 | $this->message = $message; |
78 | 78 | |
79 | - $this->commenter = get_userdata( $comment->user_id ); |
|
79 | + $this->commenter = get_userdata($comment->user_id); |
|
80 | 80 | |
81 | - $original_sender = get_post_meta( $this->message->ID, '_sender', true ); |
|
82 | - $this->original_sender = get_user_by( 'login', $original_sender ); |
|
81 | + $original_sender = get_post_meta($this->message->ID, '_sender', true); |
|
82 | + $this->original_sender = get_user_by('login', $original_sender); |
|
83 | 83 | |
84 | - $original_receiver = get_post_meta( $this->message->ID, '_receiver', true ); |
|
85 | - $this->original_receiver = get_user_by( 'login', $original_receiver ); |
|
84 | + $original_receiver = get_post_meta($this->message->ID, '_receiver', true); |
|
85 | + $this->original_receiver = get_user_by('login', $original_receiver); |
|
86 | 86 | |
87 | - $content_type = get_post_meta( $this->message->ID, '_posttype', true ); |
|
88 | - $content_id = get_post_meta( $this->message->ID, '_post', true ); |
|
89 | - $content_title = get_the_title( $content_id ); |
|
87 | + $content_type = get_post_meta($this->message->ID, '_posttype', true); |
|
88 | + $content_id = get_post_meta($this->message->ID, '_post', true); |
|
89 | + $content_title = get_the_title($content_id); |
|
90 | 90 | |
91 | - $comment_link = get_comment_link( $comment ); |
|
91 | + $comment_link = get_comment_link($comment); |
|
92 | 92 | |
93 | 93 | // setup the post type parameter |
94 | - $content_type = get_post_type( $content_id ); |
|
95 | - if( !$content_type ){ |
|
96 | - $content_type =''; |
|
94 | + $content_type = get_post_type($content_id); |
|
95 | + if ( ! $content_type) { |
|
96 | + $content_type = ''; |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Construct data array |
100 | - $sensei_email_data = apply_filters( 'sensei_email_data', array( |
|
100 | + $sensei_email_data = apply_filters('sensei_email_data', array( |
|
101 | 101 | 'template' => $this->template, |
102 | 102 | $content_type.'_id' => $content_id, |
103 | 103 | 'heading' => $this->heading, |
@@ -106,17 +106,17 @@ discard block |
||
106 | 106 | 'comment_link' => $comment_link, |
107 | 107 | 'content_title' => $content_title, |
108 | 108 | 'content_type' => $content_type, |
109 | - ), $this->template ); |
|
109 | + ), $this->template); |
|
110 | 110 | |
111 | 111 | // Set recipient |
112 | - if( $this->commenter->user_login == $original_sender ) { |
|
113 | - $this->recipient = stripslashes( $this->original_receiver->user_email ); |
|
112 | + if ($this->commenter->user_login == $original_sender) { |
|
113 | + $this->recipient = stripslashes($this->original_receiver->user_email); |
|
114 | 114 | } else { |
115 | - $this->recipient = stripslashes( $this->original_sender->user_email ); |
|
115 | + $this->recipient = stripslashes($this->original_sender->user_email); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | // Send mail |
119 | - Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) ); |
|
119 | + Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template)); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
3 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
4 | 4 | |
5 | -if ( ! class_exists( 'WooThemes_Sensei_Email_Learner_Graded_Quiz' ) ) : |
|
5 | +if ( ! class_exists('WooThemes_Sensei_Email_Learner_Graded_Quiz')) : |
|
6 | 6 | |
7 | 7 | /** |
8 | 8 | * Learner Graded Quiz |
@@ -29,8 +29,8 @@ discard block |
||
29 | 29 | */ |
30 | 30 | function __construct() { |
31 | 31 | $this->template = 'learner-graded-quiz'; |
32 | - $this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] Your quiz has been graded', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template ); |
|
33 | - $this->heading = apply_filters( 'sensei_email_heading', __( 'Your quiz has been graded', 'woothemes-sensei' ), $this->template ); |
|
32 | + $this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] Your quiz has been graded', 'woothemes-sensei'), get_bloginfo('name')), $this->template); |
|
33 | + $this->heading = apply_filters('sensei_email_heading', __('Your quiz has been graded', 'woothemes-sensei'), $this->template); |
|
34 | 34 | } |
35 | 35 | |
36 | 36 | /** |
@@ -43,48 +43,48 @@ discard block |
||
43 | 43 | * |
44 | 44 | * @return void |
45 | 45 | */ |
46 | - function trigger ( $user_id = 0, $quiz_id = 0, $grade = 0, $passmark = 0 ) { |
|
46 | + function trigger($user_id = 0, $quiz_id = 0, $grade = 0, $passmark = 0) { |
|
47 | 47 | |
48 | 48 | global $sensei_email_data; |
49 | 49 | |
50 | 50 | // Get learner user object |
51 | - $this->user = new WP_User( $user_id ); |
|
51 | + $this->user = new WP_User($user_id); |
|
52 | 52 | |
53 | 53 | // Get passed flag |
54 | - $passed = __( 'failed', 'woothemes-sensei' ); |
|
55 | - if( $grade >= $passmark ) { |
|
56 | - $passed = __( 'passed', 'woothemes-sensei' ); |
|
54 | + $passed = __('failed', 'woothemes-sensei'); |
|
55 | + if ($grade >= $passmark) { |
|
56 | + $passed = __('passed', 'woothemes-sensei'); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | // Get grade tye (auto/manual) |
60 | - $grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true ); |
|
60 | + $grade_type = get_post_meta($quiz_id, '_quiz_grade_type', true); |
|
61 | 61 | |
62 | - if( 'auto' == $grade_type ) { |
|
63 | - $this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] You have completed a quiz', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template ); |
|
64 | - $this->heading = apply_filters( 'sensei_email_heading', __( 'You have completed a quiz', 'woothemes-sensei' ), $this->template ); |
|
62 | + if ('auto' == $grade_type) { |
|
63 | + $this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] You have completed a quiz', 'woothemes-sensei'), get_bloginfo('name')), $this->template); |
|
64 | + $this->heading = apply_filters('sensei_email_heading', __('You have completed a quiz', 'woothemes-sensei'), $this->template); |
|
65 | 65 | } |
66 | 66 | |
67 | - $lesson_id = get_post_meta( $quiz_id, '_quiz_lesson', true ); |
|
67 | + $lesson_id = get_post_meta($quiz_id, '_quiz_lesson', true); |
|
68 | 68 | |
69 | 69 | // Construct data array |
70 | - $sensei_email_data = apply_filters( 'sensei_email_data', array( |
|
70 | + $sensei_email_data = apply_filters('sensei_email_data', array( |
|
71 | 71 | 'template' => $this->template, |
72 | 72 | 'heading' => $this->heading, |
73 | 73 | 'user_id' => $user_id, |
74 | - 'user_name' => stripslashes( $this->user->display_name ), |
|
74 | + 'user_name' => stripslashes($this->user->display_name), |
|
75 | 75 | 'lesson_id' => $lesson_id, |
76 | 76 | 'quiz_id' => $quiz_id, |
77 | 77 | 'grade' => $grade, |
78 | 78 | 'passmark' => $passmark, |
79 | 79 | 'passed' => $passed, |
80 | 80 | 'grade_type' => $grade_type, |
81 | - ), $this->template ); |
|
81 | + ), $this->template); |
|
82 | 82 | |
83 | 83 | // Set recipient (learner) |
84 | - $this->recipient = stripslashes( $this->user->user_email ); |
|
84 | + $this->recipient = stripslashes($this->user->user_email); |
|
85 | 85 | |
86 | 86 | // Send mail |
87 | - Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) ); |
|
87 | + Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template)); |
|
88 | 88 | } |
89 | 89 | } |
90 | 90 |
@@ -3,9 +3,9 @@ discard block |
||
3 | 3 | * This email will be sent to a teacher when a course is assigned to them. |
4 | 4 | */ |
5 | 5 | |
6 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
6 | +if ( ! defined('ABSPATH')) exit; // Exit if accessed directly |
|
7 | 7 | |
8 | -if ( class_exists('Sensei_Email_Teacher_New_Course_Assignment') ){ |
|
8 | +if (class_exists('Sensei_Email_Teacher_New_Course_Assignment')) { |
|
9 | 9 | return; |
10 | 10 | } |
11 | 11 | |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | function __construct() { |
37 | 37 | |
38 | 38 | $this->template = 'teacher-new-course-assignment'; |
39 | - $this->subject = apply_filters( 'sensei_email_subject', sprintf( __( '[%1$s] You have been assigned to a course', 'woothemes-sensei' ), get_bloginfo( 'name' ) ), $this->template ); |
|
40 | - $this->heading = apply_filters( 'sensei_email_heading', __( 'Course assigned to you', 'woothemes-sensei' ), $this->template ); |
|
39 | + $this->subject = apply_filters('sensei_email_subject', sprintf(__('[%1$s] You have been assigned to a course', 'woothemes-sensei'), get_bloginfo('name')), $this->template); |
|
40 | + $this->heading = apply_filters('sensei_email_heading', __('Course assigned to you', 'woothemes-sensei'), $this->template); |
|
41 | 41 | return; |
42 | 42 | } |
43 | 43 | |
@@ -49,30 +49,30 @@ discard block |
||
49 | 49 | * @param $course_id |
50 | 50 | * @return void |
51 | 51 | */ |
52 | - function trigger( $teacher_id = 0, $course_id = 0 ) { |
|
52 | + function trigger($teacher_id = 0, $course_id = 0) { |
|
53 | 53 | global $sensei_email_data; |
54 | 54 | |
55 | - $this->teacher = new WP_User( $teacher_id ); |
|
56 | - $this->recipient = stripslashes( $this->teacher->user_email ); |
|
57 | - $this->subject = __( 'New course assigned to you', 'woothemes-sensei' ); |
|
55 | + $this->teacher = new WP_User($teacher_id); |
|
56 | + $this->recipient = stripslashes($this->teacher->user_email); |
|
57 | + $this->subject = __('New course assigned to you', 'woothemes-sensei'); |
|
58 | 58 | |
59 | 59 | //course edit link |
60 | - $course_edit_link = admin_url('post.php?post=' . $course_id . '&action=edit' ); |
|
60 | + $course_edit_link = admin_url('post.php?post='.$course_id.'&action=edit'); |
|
61 | 61 | |
62 | 62 | // Course name |
63 | - $course = get_post( $course_id); |
|
63 | + $course = get_post($course_id); |
|
64 | 64 | // Construct data array |
65 | - $sensei_email_data = apply_filters( 'sensei_email_data', array( |
|
65 | + $sensei_email_data = apply_filters('sensei_email_data', array( |
|
66 | 66 | 'template' => $this->template, |
67 | 67 | 'heading' => $this->heading, |
68 | 68 | 'teacher_id' => $teacher_id, |
69 | 69 | 'course_id' => $course_id, |
70 | 70 | 'course_name' => $course->post_title, |
71 | 71 | 'course_edit_link' => $course_edit_link, |
72 | - ), $this->template ); |
|
72 | + ), $this->template); |
|
73 | 73 | |
74 | 74 | // Send mail |
75 | - Sensei()->emails->send( $this->recipient, $this->subject, Sensei()->emails->get_content( $this->template ) ); |
|
75 | + Sensei()->emails->send($this->recipient, $this->subject, Sensei()->emails->get_content($this->template)); |
|
76 | 76 | } |
77 | 77 | } |
78 | 78 |