@@ -181,7 +181,9 @@ discard block |
||
181 | 181 | * @return void |
182 | 182 | */ |
183 | 183 | function sensei_recent_comments_widget_filter( $widget_args = array() ) { |
184 | - if ( ! isset( $widget_args['post_type'] ) ) $widget_args['post_type'] = array( 'post', 'page' ); |
|
184 | + if ( ! isset( $widget_args['post_type'] ) ) { |
|
185 | + $widget_args['post_type'] = array( 'post', 'page' ); |
|
186 | + } |
|
185 | 187 | return $widget_args; |
186 | 188 | } // End sensei_recent_comments_widget_filter() |
187 | 189 | add_filter( 'widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1 ); |
@@ -196,8 +198,9 @@ discard block |
||
196 | 198 | function sensei_course_archive_filter( $query ) { |
197 | 199 | |
198 | 200 | |
199 | - if ( ! $query->is_main_query() ) |
|
200 | - return; |
|
201 | + if ( ! $query->is_main_query() ) { |
|
202 | + return; |
|
203 | + } |
|
201 | 204 | |
202 | 205 | // Apply Filter only if on frontend and when course archive is running |
203 | 206 | $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
@@ -412,7 +415,7 @@ discard block |
||
412 | 415 | |
413 | 416 | return false; |
414 | 417 | |
415 | - }else{ |
|
418 | + } else{ |
|
416 | 419 | |
417 | 420 | return true; |
418 | 421 | |
@@ -446,7 +449,7 @@ discard block |
||
446 | 449 | |
447 | 450 | $wp_query = $modules_query; |
448 | 451 | |
449 | - }else{ |
|
452 | + } else{ |
|
450 | 453 | |
451 | 454 | wp_reset_query(); |
452 | 455 | |
@@ -478,7 +481,7 @@ discard block |
||
478 | 481 | |
479 | 482 | return have_posts(); |
480 | 483 | |
481 | - }else{ |
|
484 | + } else{ |
|
482 | 485 | |
483 | 486 | // if the loop has not been initiated check the first module has lessons |
484 | 487 | if( -1 == $sensei_modules_loop[ 'current' ] ){ |
@@ -622,7 +625,7 @@ discard block |
||
622 | 625 | |
623 | 626 | return true; |
624 | 627 | |
625 | - }else{ |
|
628 | + } else{ |
|
626 | 629 | |
627 | 630 | return false; |
628 | 631 | |
@@ -865,7 +868,9 @@ discard block |
||
865 | 868 | */ |
866 | 869 | function get_sensei_header(){ |
867 | 870 | |
868 | - if ( ! defined( 'ABSPATH' ) ) exit; |
|
871 | + if ( ! defined( 'ABSPATH' ) ) { |
|
872 | + exit; |
|
873 | + } |
|
869 | 874 | |
870 | 875 | get_header(); |
871 | 876 |
@@ -143,7 +143,7 @@ |
||
143 | 143 | * sensei_check_if_product_is_in_cart function. |
144 | 144 | * |
145 | 145 | * @deprecated since 1.9.0 |
146 | - * @param int $wc_post_id (default: 0) |
|
146 | + * @param int $wc_product_id (default: 0) |
|
147 | 147 | * @return bool |
148 | 148 | */ |
149 | 149 | function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) { |
@@ -5,18 +5,18 @@ discard block |
||
5 | 5 | * Output tags. |
6 | 6 | ***************************************************************************************************/ |
7 | 7 | |
8 | - /** |
|
9 | - * sensei_course_archive_next_link function. |
|
10 | - * |
|
11 | - * @access public |
|
12 | - * @param string $type (default: 'newcourses') |
|
13 | - * @return void |
|
14 | - */ |
|
15 | - function sensei_course_archive_next_link( $type = 'newcourses' ) { |
|
8 | + /** |
|
9 | + * sensei_course_archive_next_link function. |
|
10 | + * |
|
11 | + * @access public |
|
12 | + * @param string $type (default: 'newcourses') |
|
13 | + * @return void |
|
14 | + */ |
|
15 | + function sensei_course_archive_next_link( $type = 'newcourses' ) { |
|
16 | 16 | |
17 | - _deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.'); |
|
17 | + _deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.'); |
|
18 | 18 | |
19 | - } // End sensei_course_archive_next_link() |
|
19 | + } // End sensei_course_archive_next_link() |
|
20 | 20 | |
21 | 21 | /** |
22 | 22 | * course_single_lessons function. |
@@ -26,14 +26,14 @@ discard block |
||
26 | 26 | */ |
27 | 27 | function course_single_lessons() { |
28 | 28 | |
29 | - // load backwards compatible template name if it exists in the users theme |
|
30 | - $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' ); |
|
31 | - if( $located_template ){ |
|
29 | + // load backwards compatible template name if it exists in the users theme |
|
30 | + $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' ); |
|
31 | + if( $located_template ){ |
|
32 | 32 | |
33 | - Sensei_Templates::get_template( 'single-course/course-lessons.php' ); |
|
34 | - return; |
|
33 | + Sensei_Templates::get_template( 'single-course/course-lessons.php' ); |
|
34 | + return; |
|
35 | 35 | |
36 | - } |
|
36 | + } |
|
37 | 37 | |
38 | 38 | Sensei_Templates::get_template( 'single-course/lessons.php' ); |
39 | 39 | |
@@ -48,8 +48,8 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function lesson_single_meta() { |
50 | 50 | |
51 | - _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' ); |
|
52 | - sensei_the_single_lesson_meta(); |
|
51 | + _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' ); |
|
52 | + sensei_the_single_lesson_meta(); |
|
53 | 53 | |
54 | 54 | } // End lesson_single_meta() |
55 | 55 | |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @access public |
61 | 61 | * @param bool $return (default: false) |
62 | 62 | * @return void |
63 | - * @deprecated since 1.9.0 |
|
63 | + * @deprecated since 1.9.0 |
|
64 | 64 | */ |
65 | 65 | function quiz_questions( $return = false ) { |
66 | 66 | |
@@ -74,11 +74,11 @@ discard block |
||
74 | 74 | * @access public |
75 | 75 | * @since 1.3.0 |
76 | 76 | * @return void |
77 | - * @deprecated |
|
77 | + * @deprecated |
|
78 | 78 | */ |
79 | 79 | function quiz_question_type( $question_type = 'multiple-choice' ) { |
80 | 80 | |
81 | - Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' ); |
|
81 | + Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' ); |
|
82 | 82 | |
83 | 83 | } // End lesson_single_meta() |
84 | 84 | |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | /** |
90 | 90 | * sensei_check_prerequisite_course function. |
91 | 91 | * |
92 | - * @deprecated since 1.9.0 use Sensei_Course::is_prerequisite_complete( $course_id ); |
|
92 | + * @deprecated since 1.9.0 use Sensei_Course::is_prerequisite_complete( $course_id ); |
|
93 | 93 | * @access public |
94 | 94 | * @param mixed $course_id |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | 97 | function sensei_check_prerequisite_course( $course_id ) { |
98 | 98 | |
99 | - return Sensei_Course::is_prerequisite_complete( $course_id ); |
|
99 | + return Sensei_Course::is_prerequisite_complete( $course_id ); |
|
100 | 100 | |
101 | 101 | } // End sensei_check_prerequisite_course() |
102 | 102 | |
@@ -120,14 +120,14 @@ discard block |
||
120 | 120 | <span><input name="course_start" type="submit" class="course-start" value="<?php _e( 'Start taking this Course', 'woothemes-sensei' ); ?>"/></span> |
121 | 121 | |
122 | 122 | </form><?php |
123 | - } // End If Statement |
|
123 | + } // End If Statement |
|
124 | 124 | } // End sensei_start_course_form() |
125 | 125 | |
126 | 126 | |
127 | 127 | /** |
128 | 128 | * sensei_wc_add_to_cart function. |
129 | 129 | * |
130 | - * @deprecated since Sensei_WC::the_add_to_cart_button_html( $course_id ); |
|
130 | + * @deprecated since Sensei_WC::the_add_to_cart_button_html( $course_id ); |
|
131 | 131 | * @access public |
132 | 132 | * @param mixed $course_id |
133 | 133 | * @return void |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return bool |
148 | 148 | */ |
149 | 149 | function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) { |
150 | - return Sensei_WC::is_product_in_cart( $wc_product_id ); |
|
150 | + return Sensei_WC::is_product_in_cart( $wc_product_id ); |
|
151 | 151 | } // End sensei_check_if_product_is_in_cart() |
152 | 152 | |
153 | 153 | /** |
@@ -160,17 +160,17 @@ discard block |
||
160 | 160 | function sensei_simple_course_price( $post_id ) { |
161 | 161 | |
162 | 162 | //WooCommerce Pricing |
163 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
164 | - $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true ); |
|
165 | - if ( 0 < $wc_post_id ) { |
|
166 | - // Get the product |
|
167 | - $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); |
|
163 | + if ( Sensei_WC::is_woocommerce_active() ) { |
|
164 | + $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true ); |
|
165 | + if ( 0 < $wc_post_id ) { |
|
166 | + // Get the product |
|
167 | + $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); |
|
168 | 168 | |
169 | - if ( isset( $product ) && !empty( $product ) && $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?> |
|
169 | + if ( isset( $product ) && !empty( $product ) && $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?> |
|
170 | 170 | <span class="course-price"><?php echo $product->get_price_html(); ?></span> |
171 | 171 | <?php } // End If Statement |
172 | - } // End If Statement |
|
173 | - } // End If Statement |
|
172 | + } // End If Statement |
|
173 | + } // End If Statement |
|
174 | 174 | } // End sensei_simple_course_price() |
175 | 175 | |
176 | 176 | /** |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | |
198 | 198 | |
199 | 199 | if ( ! $query->is_main_query() ) |
200 | - return; |
|
200 | + return; |
|
201 | 201 | |
202 | 202 | // Apply Filter only if on frontend and when course archive is running |
203 | 203 | $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | if ( ! is_admin() && 0 < $course_page_id && 0 < intval( $query->get( 'page_id' ) ) && $query->get( 'page_id' ) == $course_page_id ) { |
206 | 206 | // Check for pagination settings |
207 | 207 | if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) { |
208 | - $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); |
|
209 | - } else { |
|
210 | - $amount = $query->get( 'posts_per_page' ); |
|
211 | - } // End If Statement |
|
212 | - $query->set( 'posts_per_page', $amount ); |
|
208 | + $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); |
|
209 | + } else { |
|
210 | + $amount = $query->get( 'posts_per_page' ); |
|
211 | + } // End If Statement |
|
212 | + $query->set( 'posts_per_page', $amount ); |
|
213 | 213 | } // End If Statement |
214 | 214 | } // End sensei_course_archive_filter() |
215 | 215 | add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 ); |
@@ -248,66 +248,66 @@ discard block |
||
248 | 248 | $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
249 | 249 | $all_lessons = array(); |
250 | 250 | |
251 | - $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) ); |
|
252 | - |
|
253 | - foreach( (array) $modules as $module ) { |
|
254 | - |
|
255 | - $args = array( |
|
256 | - 'post_type' => 'lesson', |
|
257 | - 'post_status' => 'publish', |
|
258 | - 'posts_per_page' => -1, |
|
259 | - 'meta_query' => array( |
|
260 | - array( |
|
261 | - 'key' => '_lesson_course', |
|
262 | - 'value' => intval( $lesson_course_id ), |
|
263 | - 'compare' => '=' |
|
264 | - ) |
|
265 | - ), |
|
266 | - 'tax_query' => array( |
|
267 | - array( |
|
268 | - 'taxonomy' => Sensei()->modules->taxonomy, |
|
269 | - 'field' => 'id', |
|
270 | - 'terms' => intval( $module->term_id ) |
|
271 | - ) |
|
272 | - ), |
|
273 | - 'meta_key' => '_order_module_' . $module->term_id, |
|
274 | - 'orderby' => 'meta_value_num date', |
|
275 | - 'order' => 'ASC', |
|
276 | - 'suppress_filters' => 0 |
|
277 | - ); |
|
278 | - |
|
279 | - $lessons = get_posts( $args ); |
|
280 | - if ( 0 < count( $lessons ) ) { |
|
281 | - foreach ($lessons as $lesson_item){ |
|
282 | - $all_lessons[] = $lesson_item->ID; |
|
283 | - } // End For Loop |
|
284 | - } // End If Statement |
|
285 | - } |
|
286 | - |
|
287 | - $args = array( |
|
288 | - 'post_type' => 'lesson', |
|
289 | - 'posts_per_page' => -1, |
|
290 | - 'suppress_filters' => 0, |
|
291 | - 'meta_key' => '_order_' . $lesson_course_id, |
|
292 | - 'orderby' => 'meta_value_num date', |
|
293 | - 'order' => 'ASC', |
|
294 | - 'meta_query' => array( |
|
295 | - array( |
|
296 | - 'key' => '_lesson_course', |
|
297 | - 'value' => intval( $lesson_course_id ), |
|
298 | - ), |
|
299 | - ), |
|
300 | - 'post__not_in' => $all_lessons, |
|
301 | - ); |
|
302 | - |
|
303 | - $other_lessons = get_posts( $args ); |
|
304 | - if ( 0 < count( $other_lessons ) ) { |
|
251 | + $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) ); |
|
252 | + |
|
253 | + foreach( (array) $modules as $module ) { |
|
254 | + |
|
255 | + $args = array( |
|
256 | + 'post_type' => 'lesson', |
|
257 | + 'post_status' => 'publish', |
|
258 | + 'posts_per_page' => -1, |
|
259 | + 'meta_query' => array( |
|
260 | + array( |
|
261 | + 'key' => '_lesson_course', |
|
262 | + 'value' => intval( $lesson_course_id ), |
|
263 | + 'compare' => '=' |
|
264 | + ) |
|
265 | + ), |
|
266 | + 'tax_query' => array( |
|
267 | + array( |
|
268 | + 'taxonomy' => Sensei()->modules->taxonomy, |
|
269 | + 'field' => 'id', |
|
270 | + 'terms' => intval( $module->term_id ) |
|
271 | + ) |
|
272 | + ), |
|
273 | + 'meta_key' => '_order_module_' . $module->term_id, |
|
274 | + 'orderby' => 'meta_value_num date', |
|
275 | + 'order' => 'ASC', |
|
276 | + 'suppress_filters' => 0 |
|
277 | + ); |
|
278 | + |
|
279 | + $lessons = get_posts( $args ); |
|
280 | + if ( 0 < count( $lessons ) ) { |
|
281 | + foreach ($lessons as $lesson_item){ |
|
282 | + $all_lessons[] = $lesson_item->ID; |
|
283 | + } // End For Loop |
|
284 | + } // End If Statement |
|
285 | + } |
|
286 | + |
|
287 | + $args = array( |
|
288 | + 'post_type' => 'lesson', |
|
289 | + 'posts_per_page' => -1, |
|
290 | + 'suppress_filters' => 0, |
|
291 | + 'meta_key' => '_order_' . $lesson_course_id, |
|
292 | + 'orderby' => 'meta_value_num date', |
|
293 | + 'order' => 'ASC', |
|
294 | + 'meta_query' => array( |
|
295 | + array( |
|
296 | + 'key' => '_lesson_course', |
|
297 | + 'value' => intval( $lesson_course_id ), |
|
298 | + ), |
|
299 | + ), |
|
300 | + 'post__not_in' => $all_lessons, |
|
301 | + ); |
|
302 | + |
|
303 | + $other_lessons = get_posts( $args ); |
|
304 | + if ( 0 < count( $other_lessons ) ) { |
|
305 | 305 | foreach ($other_lessons as $lesson_item){ |
306 | 306 | $all_lessons[] = $lesson_item->ID; |
307 | 307 | } // End For Loop |
308 | 308 | } // End If Statement |
309 | 309 | |
310 | - if ( 0 < count( $all_lessons ) ) { |
|
310 | + if ( 0 < count( $all_lessons ) ) { |
|
311 | 311 | $found_index = false; |
312 | 312 | foreach ( $all_lessons as $lesson ){ |
313 | 313 | if ( $found_index && $return_values['next_lesson'] == 0 ) { |
@@ -338,9 +338,9 @@ discard block |
||
338 | 338 | */ |
339 | 339 | function sensei_get_excerpt( $post_id = '' ) { |
340 | 340 | |
341 | - global $post; |
|
342 | - _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.'); |
|
343 | - return get_the_excerpt(); |
|
341 | + global $post; |
|
342 | + _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.'); |
|
343 | + return get_the_excerpt(); |
|
344 | 344 | |
345 | 345 | } |
346 | 346 | |
@@ -365,7 +365,7 @@ discard block |
||
365 | 365 | */ |
366 | 366 | function sensei_has_user_completed_prerequisite_lesson( $current_lesson_id, $user_id ) { |
367 | 367 | |
368 | - return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id ); |
|
368 | + return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id ); |
|
369 | 369 | |
370 | 370 | } // End sensei_has_user_completed_prerequisite_lesson() |
371 | 371 | |
@@ -480,27 +480,27 @@ discard block |
||
480 | 480 | |
481 | 481 | }else{ |
482 | 482 | |
483 | - // if the loop has not been initiated check the first module has lessons |
|
484 | - if( -1 == $sensei_modules_loop[ 'current' ] ){ |
|
483 | + // if the loop has not been initiated check the first module has lessons |
|
484 | + if( -1 == $sensei_modules_loop[ 'current' ] ){ |
|
485 | 485 | |
486 | - $index = 0; |
|
486 | + $index = 0; |
|
487 | 487 | |
488 | - if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { |
|
489 | - // setup the query for the module lessons |
|
490 | - $course_id = $sensei_modules_loop['course_id']; |
|
488 | + if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { |
|
489 | + // setup the query for the module lessons |
|
490 | + $course_id = $sensei_modules_loop['course_id']; |
|
491 | 491 | |
492 | - $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id; |
|
493 | - $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); |
|
492 | + $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id; |
|
493 | + $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); |
|
494 | 494 | |
495 | - // setup the global wp-query only if the lessons |
|
496 | - if( $modules_query->have_posts() ){ |
|
495 | + // setup the global wp-query only if the lessons |
|
496 | + if( $modules_query->have_posts() ){ |
|
497 | 497 | |
498 | - return true; |
|
498 | + return true; |
|
499 | 499 | |
500 | - } |
|
501 | - } |
|
502 | - } |
|
503 | - // default to false if the first module doesn't have posts |
|
500 | + } |
|
501 | + } |
|
502 | + } |
|
503 | + // default to false if the first module doesn't have posts |
|
504 | 504 | return false; |
505 | 505 | |
506 | 506 | } |
@@ -612,21 +612,21 @@ discard block |
||
612 | 612 | */ |
613 | 613 | function sensei_quiz_has_questions(){ |
614 | 614 | |
615 | - global $sensei_question_loop; |
|
615 | + global $sensei_question_loop; |
|
616 | 616 | |
617 | - if( !isset( $sensei_question_loop['total'] ) ){ |
|
618 | - return false; |
|
619 | - } |
|
617 | + if( !isset( $sensei_question_loop['total'] ) ){ |
|
618 | + return false; |
|
619 | + } |
|
620 | 620 | |
621 | - if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total'] ){ |
|
621 | + if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total'] ){ |
|
622 | 622 | |
623 | - return true; |
|
623 | + return true; |
|
624 | 624 | |
625 | - }else{ |
|
625 | + }else{ |
|
626 | 626 | |
627 | - return false; |
|
627 | + return false; |
|
628 | 628 | |
629 | - } |
|
629 | + } |
|
630 | 630 | |
631 | 631 | }// end sensei_quiz_has_questions |
632 | 632 | |
@@ -637,15 +637,14 @@ discard block |
||
637 | 637 | * execution. |
638 | 638 | * |
639 | 639 | * @since 1.9.0 |
640 | - |
|
641 | 640 | */ |
642 | 641 | function sensei_setup_the_question(){ |
643 | 642 | |
644 | - global $sensei_question_loop; |
|
643 | + global $sensei_question_loop; |
|
645 | 644 | |
646 | - $sensei_question_loop['current']++; |
|
647 | - $index = $sensei_question_loop['current']; |
|
648 | - $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][ $index ] ; |
|
645 | + $sensei_question_loop['current']++; |
|
646 | + $index = $sensei_question_loop['current']; |
|
647 | + $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][ $index ] ; |
|
649 | 648 | |
650 | 649 | |
651 | 650 | }// end sensei_setup_the_question |
@@ -658,12 +657,12 @@ discard block |
||
658 | 657 | */ |
659 | 658 | function sensei_the_question_content(){ |
660 | 659 | |
661 | - global $sensei_question_loop; |
|
660 | + global $sensei_question_loop; |
|
662 | 661 | |
663 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); |
|
662 | + $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); |
|
664 | 663 | |
665 | - // load the template that displays the question information. |
|
666 | - WooThemes_Sensei_Question::load_question_template( $question_type ); |
|
664 | + // load the template that displays the question information. |
|
665 | + WooThemes_Sensei_Question::load_question_template( $question_type ); |
|
667 | 666 | |
668 | 667 | }// end sensei_the_question_content |
669 | 668 | |
@@ -674,26 +673,26 @@ discard block |
||
674 | 673 | */ |
675 | 674 | function sensei_the_question_class(){ |
676 | 675 | |
677 | - global $sensei_question_loop; |
|
676 | + global $sensei_question_loop; |
|
678 | 677 | |
679 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); |
|
678 | + $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); |
|
680 | 679 | |
681 | - /** |
|
682 | - * filter the sensei question class within |
|
683 | - * the quiz question loop. |
|
684 | - * |
|
685 | - * @since 1.9.0 |
|
686 | - */ |
|
687 | - $classes = apply_filters( 'sensei_question_classes', array( $question_type ) ); |
|
680 | + /** |
|
681 | + * filter the sensei question class within |
|
682 | + * the quiz question loop. |
|
683 | + * |
|
684 | + * @since 1.9.0 |
|
685 | + */ |
|
686 | + $classes = apply_filters( 'sensei_question_classes', array( $question_type ) ); |
|
688 | 687 | |
689 | - $html_classes = ''; |
|
690 | - foreach( $classes as $class ){ |
|
688 | + $html_classes = ''; |
|
689 | + foreach( $classes as $class ){ |
|
691 | 690 | |
692 | - $html_classes .= $class . ' '; |
|
691 | + $html_classes .= $class . ' '; |
|
693 | 692 | |
694 | - }// end foreach |
|
693 | + }// end foreach |
|
695 | 694 | |
696 | - esc_attr_e( trim( $html_classes ) ); |
|
695 | + esc_attr_e( trim( $html_classes ) ); |
|
697 | 696 | |
698 | 697 | } |
699 | 698 | |
@@ -704,12 +703,12 @@ discard block |
||
704 | 703 | */ |
705 | 704 | function sensei_get_the_question_id( ){ |
706 | 705 | |
707 | - global $sensei_question_loop; |
|
708 | - if( isset( $sensei_question_loop['current_question']->ID ) ){ |
|
706 | + global $sensei_question_loop; |
|
707 | + if( isset( $sensei_question_loop['current_question']->ID ) ){ |
|
709 | 708 | |
710 | - return $sensei_question_loop['current_question']->ID; |
|
709 | + return $sensei_question_loop['current_question']->ID; |
|
711 | 710 | |
712 | - } |
|
711 | + } |
|
713 | 712 | |
714 | 713 | }// end sensei_the_question_id |
715 | 714 | |
@@ -736,63 +735,63 @@ discard block |
||
736 | 735 | */ |
737 | 736 | function sensei_can_user_view_lesson( $lesson_id = '', $user_id = '' ){ |
738 | 737 | |
739 | - if( empty( $lesson_id ) ){ |
|
738 | + if( empty( $lesson_id ) ){ |
|
740 | 739 | |
741 | - $lesson_id = get_the_ID(); |
|
740 | + $lesson_id = get_the_ID(); |
|
742 | 741 | |
743 | - } |
|
742 | + } |
|
744 | 743 | |
745 | - if( empty( $user_id ) ){ |
|
744 | + if( empty( $user_id ) ){ |
|
746 | 745 | |
747 | - $user_id = get_current_user_id(); |
|
746 | + $user_id = get_current_user_id(); |
|
748 | 747 | |
749 | - } |
|
748 | + } |
|
750 | 749 | |
751 | - // Check for prerequisite lesson completions |
|
752 | - $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id ); |
|
753 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
754 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id ); |
|
750 | + // Check for prerequisite lesson completions |
|
751 | + $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id ); |
|
752 | + $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
753 | + $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id ); |
|
755 | 754 | |
756 | - $is_preview = false; |
|
757 | - if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) { |
|
755 | + $is_preview = false; |
|
756 | + if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) { |
|
758 | 757 | |
759 | - $is_preview = true; |
|
760 | - $pre_requisite_complete = true; |
|
758 | + $is_preview = true; |
|
759 | + $pre_requisite_complete = true; |
|
761 | 760 | |
762 | - }; |
|
761 | + }; |
|
763 | 762 | |
764 | 763 | |
765 | - $user_can_access_lesson = false; |
|
764 | + $user_can_access_lesson = false; |
|
766 | 765 | |
767 | - if( is_user_logged_in() && $user_taking_course ){ |
|
766 | + if( is_user_logged_in() && $user_taking_course ){ |
|
768 | 767 | |
769 | - $user_can_access_lesson = true; |
|
768 | + $user_can_access_lesson = true; |
|
770 | 769 | |
771 | - } |
|
770 | + } |
|
772 | 771 | |
773 | 772 | |
774 | - $access_permission = false; |
|
773 | + $access_permission = false; |
|
775 | 774 | |
776 | - if ( ! Sensei()->settings->get('access_permission') || sensei_all_access() ) { |
|
775 | + if ( ! Sensei()->settings->get('access_permission') || sensei_all_access() ) { |
|
777 | 776 | |
778 | - $access_permission = true; |
|
777 | + $access_permission = true; |
|
779 | 778 | |
780 | - } |
|
779 | + } |
|
781 | 780 | |
782 | - $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview; |
|
781 | + $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview; |
|
783 | 782 | |
784 | - /** |
|
785 | - * Filter the can user view lesson function |
|
786 | - * |
|
787 | - * @since 1.9.0 |
|
788 | - * |
|
789 | - * @hooked Sensei_WC::alter_can_user_view_lesson |
|
790 | - * |
|
791 | - * @param bool $can_user_view_lesson |
|
792 | - * @param string $lesson_id |
|
793 | - * @param string $user_id |
|
794 | - */ |
|
795 | - return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id ); |
|
783 | + /** |
|
784 | + * Filter the can user view lesson function |
|
785 | + * |
|
786 | + * @since 1.9.0 |
|
787 | + * |
|
788 | + * @hooked Sensei_WC::alter_can_user_view_lesson |
|
789 | + * |
|
790 | + * @param bool $can_user_view_lesson |
|
791 | + * @param string $lesson_id |
|
792 | + * @param string $user_id |
|
793 | + */ |
|
794 | + return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id ); |
|
796 | 795 | |
797 | 796 | } // end sensei_can_current_user_view_lesson |
798 | 797 | |
@@ -804,52 +803,52 @@ discard block |
||
804 | 803 | */ |
805 | 804 | function sensei_the_single_lesson_meta(){ |
806 | 805 | |
807 | - // if the lesson meta is included within theme load that instead of the function content |
|
808 | - $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' ); |
|
809 | - if( ! empty( $template ) ){ |
|
806 | + // if the lesson meta is included within theme load that instead of the function content |
|
807 | + $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' ); |
|
808 | + if( ! empty( $template ) ){ |
|
810 | 809 | |
811 | - Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' ); |
|
812 | - return; |
|
810 | + Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' ); |
|
811 | + return; |
|
813 | 812 | |
814 | - } |
|
813 | + } |
|
815 | 814 | |
816 | - // Get the meta info |
|
817 | - $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) ); |
|
818 | - $is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() ); |
|
815 | + // Get the meta info |
|
816 | + $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) ); |
|
817 | + $is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() ); |
|
819 | 818 | |
820 | - // Get User Meta |
|
821 | - get_currentuserinfo(); |
|
819 | + // Get User Meta |
|
820 | + get_currentuserinfo(); |
|
822 | 821 | |
823 | - // Complete Lesson Logic |
|
824 | - do_action( 'sensei_complete_lesson' ); |
|
825 | - // Check that the course has been started |
|
826 | - if ( Sensei()->access_settings() |
|
827 | - || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) |
|
828 | - || $is_preview ) { |
|
829 | - ?> |
|
822 | + // Complete Lesson Logic |
|
823 | + do_action( 'sensei_complete_lesson' ); |
|
824 | + // Check that the course has been started |
|
825 | + if ( Sensei()->access_settings() |
|
826 | + || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) |
|
827 | + || $is_preview ) { |
|
828 | + ?> |
|
830 | 829 | <section class="lesson-meta"> |
831 | 830 | <?php |
832 | - if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) { |
|
831 | + if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) { |
|
833 | 832 | |
834 | - do_action( 'sensei_lesson_video', get_the_ID() ); |
|
833 | + do_action( 'sensei_lesson_video', get_the_ID() ); |
|
835 | 834 | |
836 | - } |
|
837 | - ?> |
|
835 | + } |
|
836 | + ?> |
|
838 | 837 | <?php do_action( 'sensei_frontend_messages' ); ?> |
839 | 838 | |
840 | 839 | <?php if ( ! $is_preview |
841 | - || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) { |
|
840 | + || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) { |
|
842 | 841 | |
843 | - sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() ) ); |
|
842 | + sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() ) ); |
|
844 | 843 | |
845 | - } ?> |
|
844 | + } ?> |
|
846 | 845 | </section> |
847 | 846 | |
848 | 847 | <?php do_action( 'sensei_lesson_back_link', $lesson_course_id ); ?> |
849 | 848 | |
850 | 849 | <?php } |
851 | 850 | |
852 | - do_action( 'sensei_lesson_meta_extra', get_the_ID() ); |
|
851 | + do_action( 'sensei_lesson_meta_extra', get_the_ID() ); |
|
853 | 852 | |
854 | 853 | } // end the_single_lesson_meta |
855 | 854 | |
@@ -865,16 +864,16 @@ discard block |
||
865 | 864 | */ |
866 | 865 | function get_sensei_header(){ |
867 | 866 | |
868 | - if ( ! defined( 'ABSPATH' ) ) exit; |
|
867 | + if ( ! defined( 'ABSPATH' ) ) exit; |
|
869 | 868 | |
870 | - get_header(); |
|
869 | + get_header(); |
|
871 | 870 | |
872 | - /** |
|
873 | - * sensei_before_main_content hook |
|
874 | - * |
|
875 | - * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content) |
|
876 | - */ |
|
877 | - do_action( 'sensei_before_main_content' ); |
|
871 | + /** |
|
872 | + * sensei_before_main_content hook |
|
873 | + * |
|
874 | + * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content) |
|
875 | + */ |
|
876 | + do_action( 'sensei_before_main_content' ); |
|
878 | 877 | |
879 | 878 | }// end get_sensei_header |
880 | 879 | |
@@ -890,28 +889,28 @@ discard block |
||
890 | 889 | */ |
891 | 890 | function get_sensei_footer(){ |
892 | 891 | |
893 | - /** |
|
894 | - * sensei_pagination hook |
|
895 | - * |
|
896 | - * @hooked sensei_pagination - 10 (outputs pagination) |
|
897 | - */ |
|
898 | - do_action( 'sensei_pagination' ); |
|
899 | - |
|
900 | - /** |
|
901 | - * sensei_after_main_content hook |
|
902 | - * |
|
903 | - * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content) |
|
904 | - */ |
|
905 | - do_action( 'sensei_after_main_content' ); |
|
906 | - |
|
907 | - /** |
|
908 | - * sensei_sidebar hook |
|
909 | - * |
|
910 | - * @hooked sensei_get_sidebar - 10 |
|
911 | - */ |
|
912 | - do_action( 'sensei_sidebar' ); |
|
913 | - |
|
914 | - get_footer(); |
|
892 | + /** |
|
893 | + * sensei_pagination hook |
|
894 | + * |
|
895 | + * @hooked sensei_pagination - 10 (outputs pagination) |
|
896 | + */ |
|
897 | + do_action( 'sensei_pagination' ); |
|
898 | + |
|
899 | + /** |
|
900 | + * sensei_after_main_content hook |
|
901 | + * |
|
902 | + * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content) |
|
903 | + */ |
|
904 | + do_action( 'sensei_after_main_content' ); |
|
905 | + |
|
906 | + /** |
|
907 | + * sensei_sidebar hook |
|
908 | + * |
|
909 | + * @hooked sensei_get_sidebar - 10 |
|
910 | + */ |
|
911 | + do_action( 'sensei_sidebar' ); |
|
912 | + |
|
913 | + get_footer(); |
|
915 | 914 | |
916 | 915 | }// end get_sensei_header |
917 | 916 | |
@@ -923,14 +922,14 @@ discard block |
||
923 | 922 | */ |
924 | 923 | function the_no_permissions_title(){ |
925 | 924 | |
926 | - /** |
|
927 | - * Filter the no permissions title just before it is echo'd on the |
|
928 | - * no-permissions.php file. |
|
929 | - * |
|
930 | - * @since 1.9.0 |
|
931 | - * @param $no_permissions_title |
|
932 | - */ |
|
933 | - echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] ); |
|
925 | + /** |
|
926 | + * Filter the no permissions title just before it is echo'd on the |
|
927 | + * no-permissions.php file. |
|
928 | + * |
|
929 | + * @since 1.9.0 |
|
930 | + * @param $no_permissions_title |
|
931 | + */ |
|
932 | + echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] ); |
|
934 | 933 | |
935 | 934 | } |
936 | 935 | |
@@ -941,14 +940,14 @@ discard block |
||
941 | 940 | */ |
942 | 941 | function the_no_permissions_message( $post_id ){ |
943 | 942 | |
944 | - /** |
|
945 | - * Filter the no permissions message just before it is echo'd on the |
|
946 | - * no-permissions.php file. |
|
947 | - * |
|
948 | - * @since 1.9.0 |
|
949 | - * @param $no_permissions_message |
|
950 | - */ |
|
951 | - echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id ); |
|
943 | + /** |
|
944 | + * Filter the no permissions message just before it is echo'd on the |
|
945 | + * no-permissions.php file. |
|
946 | + * |
|
947 | + * @since 1.9.0 |
|
948 | + * @param $no_permissions_message |
|
949 | + */ |
|
950 | + echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id ); |
|
952 | 951 | |
953 | 952 | } |
954 | 953 | |
@@ -959,8 +958,8 @@ discard block |
||
959 | 958 | */ |
960 | 959 | function sensei_the_excerpt( $post_id ){ |
961 | 960 | |
962 | - global $post; |
|
963 | - the_excerpt( $post ); |
|
961 | + global $post; |
|
962 | + the_excerpt( $post ); |
|
964 | 963 | |
965 | 964 | } |
966 | 965 | |
@@ -974,9 +973,9 @@ discard block |
||
974 | 973 | */ |
975 | 974 | function sensei_get_current_page_url(){ |
976 | 975 | |
977 | - global $wp; |
|
978 | - $current_page_url = home_url( $wp->request ); |
|
979 | - return $current_page_url; |
|
976 | + global $wp; |
|
977 | + $current_page_url = home_url( $wp->request ); |
|
978 | + return $current_page_url; |
|
980 | 979 | |
981 | 980 | } |
982 | 981 | |
@@ -988,7 +987,7 @@ discard block |
||
988 | 987 | */ |
989 | 988 | function sensei_the_my_courses_content(){ |
990 | 989 | |
991 | - echo Sensei()->course->load_user_courses_content( wp_get_current_user() ); |
|
990 | + echo Sensei()->course->load_user_courses_content( wp_get_current_user() ); |
|
992 | 991 | |
993 | 992 | } // sensei_the_my_courses_content |
994 | 993 | |
@@ -1003,7 +1002,7 @@ discard block |
||
1003 | 1002 | */ |
1004 | 1003 | function sensei_load_template( $template_name ){ |
1005 | 1004 | |
1006 | - Sensei_Templates::get_template( $template_name ); |
|
1005 | + Sensei_Templates::get_template( $template_name ); |
|
1007 | 1006 | |
1008 | 1007 | } |
1009 | 1008 | |
@@ -1017,7 +1016,7 @@ discard block |
||
1017 | 1016 | */ |
1018 | 1017 | function sensei_load_template_part( $slug, $name ){ |
1019 | 1018 | |
1020 | - Sensei_Templates::get_part( $slug, $name ); |
|
1019 | + Sensei_Templates::get_part( $slug, $name ); |
|
1021 | 1020 | |
1022 | 1021 | } |
1023 | 1022 | |
@@ -1036,17 +1035,17 @@ discard block |
||
1036 | 1035 | */ |
1037 | 1036 | function sensei_the_lesson_excerpt( $lesson_id = '' ) { |
1038 | 1037 | |
1039 | - if( empty( $lesson_id )){ |
|
1038 | + if( empty( $lesson_id )){ |
|
1040 | 1039 | |
1041 | - $lesson_id = get_the_ID(); |
|
1040 | + $lesson_id = get_the_ID(); |
|
1042 | 1041 | |
1043 | - } |
|
1042 | + } |
|
1044 | 1043 | |
1045 | - if( 'lesson' != get_post_type( $lesson_id ) ){ |
|
1046 | - return; |
|
1047 | - } |
|
1044 | + if( 'lesson' != get_post_type( $lesson_id ) ){ |
|
1045 | + return; |
|
1046 | + } |
|
1048 | 1047 | |
1049 | - echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false ); |
|
1048 | + echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false ); |
|
1050 | 1049 | |
1051 | 1050 | }// End lesson_excerpt() |
1052 | 1051 | |
@@ -1056,16 +1055,16 @@ discard block |
||
1056 | 1055 | * @since 1.9.0 |
1057 | 1056 | */ |
1058 | 1057 | function sensei_the_course_results_lessons(){ |
1059 | - // load backwards compatible template name if it exists in the users theme |
|
1060 | - $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' ); |
|
1061 | - if( $located_template ){ |
|
1058 | + // load backwards compatible template name if it exists in the users theme |
|
1059 | + $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' ); |
|
1060 | + if( $located_template ){ |
|
1062 | 1061 | |
1063 | - Sensei_Templates::get_template( 'course-results/course-lessons.php' ); |
|
1064 | - return; |
|
1062 | + Sensei_Templates::get_template( 'course-results/course-lessons.php' ); |
|
1063 | + return; |
|
1065 | 1064 | |
1066 | - } |
|
1065 | + } |
|
1067 | 1066 | |
1068 | - Sensei_Templates::get_template( 'course-results/lessons.php' ); |
|
1067 | + Sensei_Templates::get_template( 'course-results/lessons.php' ); |
|
1069 | 1068 | } |
1070 | 1069 | |
1071 | 1070 | /** |
@@ -1077,7 +1076,7 @@ discard block |
||
1077 | 1076 | */ |
1078 | 1077 | function sensei_courses_per_row(){ |
1079 | 1078 | |
1080 | - echo Sensei_Course::get_loop_number_of_columns(); |
|
1079 | + echo Sensei_Course::get_loop_number_of_columns(); |
|
1081 | 1080 | |
1082 | 1081 | } |
1083 | 1082 | |
@@ -1091,6 +1090,6 @@ discard block |
||
1091 | 1090 | */ |
1092 | 1091 | function sensei_get_template( $template_name, $args, $path ){ |
1093 | 1092 | |
1094 | - Sensei_Templates::get_template( $template_name, $args, $path ); |
|
1093 | + Sensei_Templates::get_template( $template_name, $args, $path ); |
|
1095 | 1094 | |
1096 | 1095 | } |
@@ -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 | * Output tags. |
@@ -12,9 +12,9 @@ discard block |
||
12 | 12 | * @param string $type (default: 'newcourses') |
13 | 13 | * @return void |
14 | 14 | */ |
15 | - function sensei_course_archive_next_link( $type = 'newcourses' ) { |
|
15 | + function sensei_course_archive_next_link($type = 'newcourses') { |
|
16 | 16 | |
17 | - _deprecated_function('sensei_course_archive_next_link', '1.9.0','This is no longer used or required in Sensei.'); |
|
17 | + _deprecated_function('sensei_course_archive_next_link', '1.9.0', 'This is no longer used or required in Sensei.'); |
|
18 | 18 | |
19 | 19 | } // End sensei_course_archive_next_link() |
20 | 20 | |
@@ -27,15 +27,15 @@ discard block |
||
27 | 27 | function course_single_lessons() { |
28 | 28 | |
29 | 29 | // load backwards compatible template name if it exists in the users theme |
30 | - $located_template= locate_template( Sensei()->template_url . 'single-course/course-lessons.php' ); |
|
31 | - if( $located_template ){ |
|
30 | + $located_template = locate_template(Sensei()->template_url.'single-course/course-lessons.php'); |
|
31 | + if ($located_template) { |
|
32 | 32 | |
33 | - Sensei_Templates::get_template( 'single-course/course-lessons.php' ); |
|
33 | + Sensei_Templates::get_template('single-course/course-lessons.php'); |
|
34 | 34 | return; |
35 | 35 | |
36 | 36 | } |
37 | 37 | |
38 | - Sensei_Templates::get_template( 'single-course/lessons.php' ); |
|
38 | + Sensei_Templates::get_template('single-course/lessons.php'); |
|
39 | 39 | |
40 | 40 | } // End course_single_lessons() |
41 | 41 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | function lesson_single_meta() { |
50 | 50 | |
51 | - _deprecated_function('lesson_single_meta','1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta' ); |
|
51 | + _deprecated_function('lesson_single_meta', '1.9;0', 'WooThemes_Sensei_Lesson::the_lesson_meta'); |
|
52 | 52 | sensei_the_single_lesson_meta(); |
53 | 53 | |
54 | 54 | } // End lesson_single_meta() |
@@ -62,9 +62,9 @@ discard block |
||
62 | 62 | * @return void |
63 | 63 | * @deprecated since 1.9.0 |
64 | 64 | */ |
65 | - function quiz_questions( $return = false ) { |
|
65 | + function quiz_questions($return = false) { |
|
66 | 66 | |
67 | - Sensei_Templates::get_template( 'single-quiz/quiz-questions.php' ); |
|
67 | + Sensei_Templates::get_template('single-quiz/quiz-questions.php'); |
|
68 | 68 | |
69 | 69 | } // End quiz_questions() |
70 | 70 | |
@@ -76,9 +76,9 @@ discard block |
||
76 | 76 | * @return void |
77 | 77 | * @deprecated |
78 | 78 | */ |
79 | - function quiz_question_type( $question_type = 'multiple-choice' ) { |
|
79 | + function quiz_question_type($question_type = 'multiple-choice') { |
|
80 | 80 | |
81 | - Sensei_Templates::get_template( 'single-quiz/question_type-' . $question_type . '.php' ); |
|
81 | + Sensei_Templates::get_template('single-quiz/question_type-'.$question_type.'.php'); |
|
82 | 82 | |
83 | 83 | } // End lesson_single_meta() |
84 | 84 | |
@@ -94,9 +94,9 @@ discard block |
||
94 | 94 | * @param mixed $course_id |
95 | 95 | * @return bool |
96 | 96 | */ |
97 | - function sensei_check_prerequisite_course( $course_id ) { |
|
97 | + function sensei_check_prerequisite_course($course_id) { |
|
98 | 98 | |
99 | - return Sensei_Course::is_prerequisite_complete( $course_id ); |
|
99 | + return Sensei_Course::is_prerequisite_complete($course_id); |
|
100 | 100 | |
101 | 101 | } // End sensei_check_prerequisite_course() |
102 | 102 | |
@@ -108,16 +108,16 @@ discard block |
||
108 | 108 | * @param mixed $course_id |
109 | 109 | * @return void |
110 | 110 | */ |
111 | - function sensei_start_course_form( $course_id ) { |
|
111 | + function sensei_start_course_form($course_id) { |
|
112 | 112 | |
113 | - $prerequisite_complete = sensei_check_prerequisite_course( $course_id ); |
|
113 | + $prerequisite_complete = sensei_check_prerequisite_course($course_id); |
|
114 | 114 | |
115 | - if ( $prerequisite_complete ) { |
|
116 | - ?><form method="POST" action="<?php echo esc_url( get_permalink() ); ?>"> |
|
115 | + if ($prerequisite_complete) { |
|
116 | + ?><form method="POST" action="<?php echo esc_url(get_permalink()); ?>"> |
|
117 | 117 | |
118 | - <input type="hidden" name="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" id="<?php echo esc_attr( 'woothemes_sensei_start_course_noonce' ); ?>" value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_start_course_noonce' ) ); ?>" /> |
|
118 | + <input type="hidden" name="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" id="<?php echo esc_attr('woothemes_sensei_start_course_noonce'); ?>" value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_start_course_noonce')); ?>" /> |
|
119 | 119 | |
120 | - <span><input name="course_start" type="submit" class="course-start" value="<?php _e( 'Start taking this Course', 'woothemes-sensei' ); ?>"/></span> |
|
120 | + <span><input name="course_start" type="submit" class="course-start" value="<?php _e('Start taking this Course', 'woothemes-sensei'); ?>"/></span> |
|
121 | 121 | |
122 | 122 | </form><?php |
123 | 123 | } // End If Statement |
@@ -132,9 +132,9 @@ discard block |
||
132 | 132 | * @param mixed $course_id |
133 | 133 | * @return void |
134 | 134 | */ |
135 | - function sensei_wc_add_to_cart( $course_id ) { |
|
135 | + function sensei_wc_add_to_cart($course_id) { |
|
136 | 136 | |
137 | - Sensei_WC::the_add_to_cart_button_html( $course_id ); |
|
137 | + Sensei_WC::the_add_to_cart_button_html($course_id); |
|
138 | 138 | |
139 | 139 | } // End sensei_wc_add_to_cart() |
140 | 140 | |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | * @param int $wc_post_id (default: 0) |
147 | 147 | * @return bool |
148 | 148 | */ |
149 | - function sensei_check_if_product_is_in_cart( $wc_product_id = 0 ) { |
|
150 | - return Sensei_WC::is_product_in_cart( $wc_product_id ); |
|
149 | + function sensei_check_if_product_is_in_cart($wc_product_id = 0) { |
|
150 | + return Sensei_WC::is_product_in_cart($wc_product_id); |
|
151 | 151 | } // End sensei_check_if_product_is_in_cart() |
152 | 152 | |
153 | 153 | /** |
@@ -157,16 +157,16 @@ discard block |
||
157 | 157 | * @param mixed $post_id |
158 | 158 | * @return void |
159 | 159 | */ |
160 | - function sensei_simple_course_price( $post_id ) { |
|
160 | + function sensei_simple_course_price($post_id) { |
|
161 | 161 | |
162 | 162 | //WooCommerce Pricing |
163 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
164 | - $wc_post_id = get_post_meta( $post_id, '_course_woocommerce_product', true ); |
|
165 | - if ( 0 < $wc_post_id ) { |
|
163 | + if (Sensei_WC::is_woocommerce_active()) { |
|
164 | + $wc_post_id = get_post_meta($post_id, '_course_woocommerce_product', true); |
|
165 | + if (0 < $wc_post_id) { |
|
166 | 166 | // Get the product |
167 | - $product = Sensei()->sensei_get_woocommerce_product_object( $wc_post_id ); |
|
167 | + $product = Sensei()->sensei_get_woocommerce_product_object($wc_post_id); |
|
168 | 168 | |
169 | - if ( isset( $product ) && !empty( $product ) && $product->is_purchasable() && $product->is_in_stock() && !sensei_check_if_product_is_in_cart( $wc_post_id ) ) { ?> |
|
169 | + if (isset($product) && ! empty($product) && $product->is_purchasable() && $product->is_in_stock() && ! sensei_check_if_product_is_in_cart($wc_post_id)) { ?> |
|
170 | 170 | <span class="course-price"><?php echo $product->get_price_html(); ?></span> |
171 | 171 | <?php } // End If Statement |
172 | 172 | } // End If Statement |
@@ -180,11 +180,11 @@ discard block |
||
180 | 180 | * @param array $widget_args (default: array()) |
181 | 181 | * @return array |
182 | 182 | */ |
183 | - function sensei_recent_comments_widget_filter( $widget_args = array() ) { |
|
184 | - if ( ! isset( $widget_args['post_type'] ) ) $widget_args['post_type'] = array( 'post', 'page' ); |
|
183 | + function sensei_recent_comments_widget_filter($widget_args = array()) { |
|
184 | + if ( ! isset($widget_args['post_type'])) $widget_args['post_type'] = array('post', 'page'); |
|
185 | 185 | return $widget_args; |
186 | 186 | } // End sensei_recent_comments_widget_filter() |
187 | - add_filter( 'widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1 ); |
|
187 | + add_filter('widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1); |
|
188 | 188 | |
189 | 189 | /** |
190 | 190 | * sensei_course_archive_filter function. |
@@ -193,26 +193,26 @@ discard block |
||
193 | 193 | * @param WP_Query $query ( default: array ( ) ) |
194 | 194 | * @return void |
195 | 195 | */ |
196 | - function sensei_course_archive_filter( $query ) { |
|
196 | + function sensei_course_archive_filter($query) { |
|
197 | 197 | |
198 | 198 | |
199 | - if ( ! $query->is_main_query() ) |
|
199 | + if ( ! $query->is_main_query()) |
|
200 | 200 | return; |
201 | 201 | |
202 | 202 | // Apply Filter only if on frontend and when course archive is running |
203 | - $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
|
203 | + $course_page_id = intval(Sensei()->settings->settings['course_page']); |
|
204 | 204 | |
205 | - if ( ! is_admin() && 0 < $course_page_id && 0 < intval( $query->get( 'page_id' ) ) && $query->get( 'page_id' ) == $course_page_id ) { |
|
205 | + if ( ! is_admin() && 0 < $course_page_id && 0 < intval($query->get('page_id')) && $query->get('page_id') == $course_page_id) { |
|
206 | 206 | // Check for pagination settings |
207 | - if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) { |
|
208 | - $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); |
|
207 | + if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) { |
|
208 | + $amount = absint(Sensei()->settings->settings['course_archive_amount']); |
|
209 | 209 | } else { |
210 | - $amount = $query->get( 'posts_per_page' ); |
|
210 | + $amount = $query->get('posts_per_page'); |
|
211 | 211 | } // End If Statement |
212 | - $query->set( 'posts_per_page', $amount ); |
|
212 | + $query->set('posts_per_page', $amount); |
|
213 | 213 | } // End If Statement |
214 | 214 | } // End sensei_course_archive_filter() |
215 | - add_filter( 'pre_get_posts', 'sensei_course_archive_filter', 10, 1 ); |
|
215 | + add_filter('pre_get_posts', 'sensei_course_archive_filter', 10, 1); |
|
216 | 216 | |
217 | 217 | /** |
218 | 218 | * sensei_complete_lesson_button description |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | * @return html |
221 | 221 | */ |
222 | 222 | function sensei_complete_lesson_button() { |
223 | - do_action( 'sensei_complete_lesson_button' ); |
|
223 | + do_action('sensei_complete_lesson_button'); |
|
224 | 224 | } // End sensei_complete_lesson_button() |
225 | 225 | |
226 | 226 | /** |
@@ -229,7 +229,7 @@ discard block |
||
229 | 229 | * @return html |
230 | 230 | */ |
231 | 231 | function sensei_reset_lesson_button() { |
232 | - do_action( 'sensei_reset_lesson_button' ); |
|
232 | + do_action('sensei_reset_lesson_button'); |
|
233 | 233 | } // End sensei_reset_lesson_button() |
234 | 234 | |
235 | 235 | /** |
@@ -238,19 +238,19 @@ discard block |
||
238 | 238 | * @param integer $lesson_id |
239 | 239 | * @return array $return_values |
240 | 240 | */ |
241 | - function sensei_get_prev_next_lessons( $lesson_id = 0 ) { |
|
241 | + function sensei_get_prev_next_lessons($lesson_id = 0) { |
|
242 | 242 | |
243 | 243 | $return_values = array(); |
244 | 244 | $return_values['prev_lesson'] = 0; |
245 | 245 | $return_values['next_lesson'] = 0; |
246 | - if ( 0 < $lesson_id ) { |
|
246 | + if (0 < $lesson_id) { |
|
247 | 247 | // Get the List of Lessons in the Course |
248 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
248 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
249 | 249 | $all_lessons = array(); |
250 | 250 | |
251 | - $modules = Sensei()->modules->get_course_modules( intval( $lesson_course_id ) ); |
|
251 | + $modules = Sensei()->modules->get_course_modules(intval($lesson_course_id)); |
|
252 | 252 | |
253 | - foreach( (array) $modules as $module ) { |
|
253 | + foreach ((array) $modules as $module) { |
|
254 | 254 | |
255 | 255 | $args = array( |
256 | 256 | 'post_type' => 'lesson', |
@@ -259,7 +259,7 @@ discard block |
||
259 | 259 | 'meta_query' => array( |
260 | 260 | array( |
261 | 261 | 'key' => '_lesson_course', |
262 | - 'value' => intval( $lesson_course_id ), |
|
262 | + 'value' => intval($lesson_course_id), |
|
263 | 263 | 'compare' => '=' |
264 | 264 | ) |
265 | 265 | ), |
@@ -267,18 +267,18 @@ discard block |
||
267 | 267 | array( |
268 | 268 | 'taxonomy' => Sensei()->modules->taxonomy, |
269 | 269 | 'field' => 'id', |
270 | - 'terms' => intval( $module->term_id ) |
|
270 | + 'terms' => intval($module->term_id) |
|
271 | 271 | ) |
272 | 272 | ), |
273 | - 'meta_key' => '_order_module_' . $module->term_id, |
|
273 | + 'meta_key' => '_order_module_'.$module->term_id, |
|
274 | 274 | 'orderby' => 'meta_value_num date', |
275 | 275 | 'order' => 'ASC', |
276 | 276 | 'suppress_filters' => 0 |
277 | 277 | ); |
278 | 278 | |
279 | - $lessons = get_posts( $args ); |
|
280 | - if ( 0 < count( $lessons ) ) { |
|
281 | - foreach ($lessons as $lesson_item){ |
|
279 | + $lessons = get_posts($args); |
|
280 | + if (0 < count($lessons)) { |
|
281 | + foreach ($lessons as $lesson_item) { |
|
282 | 282 | $all_lessons[] = $lesson_item->ID; |
283 | 283 | } // End For Loop |
284 | 284 | } // End If Statement |
@@ -288,36 +288,36 @@ discard block |
||
288 | 288 | 'post_type' => 'lesson', |
289 | 289 | 'posts_per_page' => -1, |
290 | 290 | 'suppress_filters' => 0, |
291 | - 'meta_key' => '_order_' . $lesson_course_id, |
|
291 | + 'meta_key' => '_order_'.$lesson_course_id, |
|
292 | 292 | 'orderby' => 'meta_value_num date', |
293 | 293 | 'order' => 'ASC', |
294 | 294 | 'meta_query' => array( |
295 | 295 | array( |
296 | 296 | 'key' => '_lesson_course', |
297 | - 'value' => intval( $lesson_course_id ), |
|
297 | + 'value' => intval($lesson_course_id), |
|
298 | 298 | ), |
299 | 299 | ), |
300 | 300 | 'post__not_in' => $all_lessons, |
301 | 301 | ); |
302 | 302 | |
303 | - $other_lessons = get_posts( $args ); |
|
304 | - if ( 0 < count( $other_lessons ) ) { |
|
305 | - foreach ($other_lessons as $lesson_item){ |
|
303 | + $other_lessons = get_posts($args); |
|
304 | + if (0 < count($other_lessons)) { |
|
305 | + foreach ($other_lessons as $lesson_item) { |
|
306 | 306 | $all_lessons[] = $lesson_item->ID; |
307 | 307 | } // End For Loop |
308 | 308 | } // End If Statement |
309 | 309 | |
310 | - if ( 0 < count( $all_lessons ) ) { |
|
310 | + if (0 < count($all_lessons)) { |
|
311 | 311 | $found_index = false; |
312 | - foreach ( $all_lessons as $lesson ){ |
|
313 | - if ( $found_index && $return_values['next_lesson'] == 0 ) { |
|
312 | + foreach ($all_lessons as $lesson) { |
|
313 | + if ($found_index && $return_values['next_lesson'] == 0) { |
|
314 | 314 | $return_values['next_lesson'] = $lesson; |
315 | 315 | } // End If Statement |
316 | - if ( $lesson == $lesson_id ) { |
|
316 | + if ($lesson == $lesson_id) { |
|
317 | 317 | // Is the current post |
318 | 318 | $found_index = true; |
319 | 319 | } // End If Statement |
320 | - if ( !$found_index ) { |
|
320 | + if ( ! $found_index) { |
|
321 | 321 | $return_values['prev_lesson'] = $lesson; |
322 | 322 | } // End If Statement |
323 | 323 | } // End For Loop |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | * @param int|WP_Post $post_id Optional. Defaults to current post |
337 | 337 | * @return string $excerpt |
338 | 338 | */ |
339 | - function sensei_get_excerpt( $post_id = '' ) { |
|
339 | + function sensei_get_excerpt($post_id = '') { |
|
340 | 340 | |
341 | 341 | global $post; |
342 | 342 | _deprecated_function('sensei_get_excerpt', 'use the wordpress excerpt functionality.'); |
@@ -344,14 +344,14 @@ discard block |
||
344 | 344 | |
345 | 345 | } |
346 | 346 | |
347 | - function sensei_has_user_started_course( $post_id = 0, $user_id = 0 ) { |
|
348 | - _deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()" ); |
|
349 | - return Sensei_Utils::user_started_course( $post_id, $user_id ); |
|
347 | + function sensei_has_user_started_course($post_id = 0, $user_id = 0) { |
|
348 | + _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_started_course()"); |
|
349 | + return Sensei_Utils::user_started_course($post_id, $user_id); |
|
350 | 350 | } // End sensei_has_user_started_course() |
351 | 351 | |
352 | - function sensei_has_user_completed_lesson( $post_id = 0, $user_id = 0 ) { |
|
353 | - _deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()" ); |
|
354 | - return Sensei_Utils::user_completed_lesson( $post_id, $user_id ); |
|
352 | + function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0) { |
|
353 | + _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()"); |
|
354 | + return Sensei_Utils::user_completed_lesson($post_id, $user_id); |
|
355 | 355 | } // End sensei_has_user_completed_lesson() |
356 | 356 | |
357 | 357 | /** |
@@ -363,9 +363,9 @@ discard block |
||
363 | 363 | * @param int $user_id |
364 | 364 | * @return bool |
365 | 365 | */ |
366 | -function sensei_has_user_completed_prerequisite_lesson( $current_lesson_id, $user_id ) { |
|
366 | +function sensei_has_user_completed_prerequisite_lesson($current_lesson_id, $user_id) { |
|
367 | 367 | |
368 | - return WooThemes_Sensei_Lesson::is_pre_requisite_complete( $current_lesson_id, $user_id ); |
|
368 | + return WooThemes_Sensei_Lesson::is_pre_requisite_complete($current_lesson_id, $user_id); |
|
369 | 369 | |
370 | 370 | } // End sensei_has_user_completed_prerequisite_lesson() |
371 | 371 | |
@@ -388,7 +388,7 @@ discard block |
||
388 | 388 | * @return bool |
389 | 389 | * |
390 | 390 | */ |
391 | -function sensei_have_modules( $course_post_id = '' ){ |
|
391 | +function sensei_have_modules($course_post_id = '') { |
|
392 | 392 | |
393 | 393 | global $post, $wp_query, $sensei_modules_loop; |
394 | 394 | |
@@ -396,23 +396,23 @@ discard block |
||
396 | 396 | wp_reset_query(); |
397 | 397 | $post = $wp_query->post; |
398 | 398 | |
399 | - if( empty( $course_post_id ) ){ |
|
399 | + if (empty($course_post_id)) { |
|
400 | 400 | |
401 | 401 | $course_id = $post->ID; |
402 | 402 | |
403 | 403 | } |
404 | 404 | |
405 | 405 | // doesn't apply to none course post types |
406 | - if( ! sensei_is_a_course( $course_id ) ){ |
|
406 | + if ( ! sensei_is_a_course($course_id)) { |
|
407 | 407 | return false; |
408 | 408 | } |
409 | 409 | |
410 | 410 | // check the current item compared to the total number of modules |
411 | - if( $sensei_modules_loop[ 'current' ] + 1 > $sensei_modules_loop[ 'total' ] ){ |
|
411 | + if ($sensei_modules_loop['current'] + 1 > $sensei_modules_loop['total']) { |
|
412 | 412 | |
413 | 413 | return false; |
414 | 414 | |
415 | - }else{ |
|
415 | + } else { |
|
416 | 416 | |
417 | 417 | return true; |
418 | 418 | |
@@ -426,27 +426,27 @@ discard block |
||
426 | 426 | * |
427 | 427 | * @since 1.9.0 |
428 | 428 | */ |
429 | -function sensei_setup_module(){ |
|
429 | +function sensei_setup_module() { |
|
430 | 430 | |
431 | 431 | global $sensei_modules_loop, $wp_query; |
432 | 432 | |
433 | 433 | // increment the index |
434 | - $sensei_modules_loop[ 'current' ]++; |
|
435 | - $index = $sensei_modules_loop[ 'current' ]; |
|
436 | - if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { |
|
434 | + $sensei_modules_loop['current']++; |
|
435 | + $index = $sensei_modules_loop['current']; |
|
436 | + if (isset($sensei_modules_loop['modules'][$index])) { |
|
437 | 437 | |
438 | 438 | $sensei_modules_loop['current_module'] = $sensei_modules_loop['modules'][$index]; |
439 | 439 | // setup the query for the module lessons |
440 | 440 | $course_id = $sensei_modules_loop['course_id']; |
441 | 441 | $module_term_id = $sensei_modules_loop['current_module']->term_id; |
442 | - $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); |
|
442 | + $modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id); |
|
443 | 443 | |
444 | 444 | // setup the global wp-query only if the lessons |
445 | - if( $modules_query->have_posts() ){ |
|
445 | + if ($modules_query->have_posts()) { |
|
446 | 446 | |
447 | 447 | $wp_query = $modules_query; |
448 | 448 | |
449 | - }else{ |
|
449 | + } else { |
|
450 | 450 | |
451 | 451 | wp_reset_query(); |
452 | 452 | |
@@ -470,30 +470,30 @@ discard block |
||
470 | 470 | * |
471 | 471 | * @return bool |
472 | 472 | */ |
473 | -function sensei_module_has_lessons(){ |
|
473 | +function sensei_module_has_lessons() { |
|
474 | 474 | |
475 | 475 | global $wp_query, $sensei_modules_loop; |
476 | 476 | |
477 | - if( 'lesson' == $wp_query->get('post_type') ){ |
|
477 | + if ('lesson' == $wp_query->get('post_type')) { |
|
478 | 478 | |
479 | 479 | return have_posts(); |
480 | 480 | |
481 | - }else{ |
|
481 | + } else { |
|
482 | 482 | |
483 | 483 | // if the loop has not been initiated check the first module has lessons |
484 | - if( -1 == $sensei_modules_loop[ 'current' ] ){ |
|
484 | + if ( -1 == $sensei_modules_loop['current'] ) { |
|
485 | 485 | |
486 | 486 | $index = 0; |
487 | 487 | |
488 | - if( isset( $sensei_modules_loop['modules'][ $index ] ) ) { |
|
488 | + if (isset($sensei_modules_loop['modules'][$index])) { |
|
489 | 489 | // setup the query for the module lessons |
490 | 490 | $course_id = $sensei_modules_loop['course_id']; |
491 | 491 | |
492 | - $module_term_id = $sensei_modules_loop['modules'][ $index ] ->term_id; |
|
493 | - $modules_query = Sensei()->modules->get_lessons_query( $course_id , $module_term_id ); |
|
492 | + $module_term_id = $sensei_modules_loop['modules'][$index] ->term_id; |
|
493 | + $modules_query = Sensei()->modules->get_lessons_query($course_id, $module_term_id); |
|
494 | 494 | |
495 | 495 | // setup the global wp-query only if the lessons |
496 | - if( $modules_query->have_posts() ){ |
|
496 | + if ($modules_query->have_posts()) { |
|
497 | 497 | |
498 | 498 | return true; |
499 | 499 | |
@@ -517,9 +517,9 @@ discard block |
||
517 | 517 | * @uses sensei_the_module_title |
518 | 518 | * @return string |
519 | 519 | */ |
520 | -function sensei_the_module_title_attribute(){ |
|
520 | +function sensei_the_module_title_attribute() { |
|
521 | 521 | |
522 | - esc_attr_e( sensei_get_the_module_title() ); |
|
522 | + esc_attr_e(sensei_get_the_module_title()); |
|
523 | 523 | |
524 | 524 | } |
525 | 525 | |
@@ -530,11 +530,11 @@ discard block |
||
530 | 530 | * |
531 | 531 | * @return string |
532 | 532 | */ |
533 | -function sensei_the_module_permalink(){ |
|
533 | +function sensei_the_module_permalink() { |
|
534 | 534 | |
535 | 535 | global $sensei_modules_loop; |
536 | 536 | $course_id = $sensei_modules_loop['course_id']; |
537 | - $module_url = add_query_arg('course_id', $course_id, get_term_link( $sensei_modules_loop['current_module'], 'module' ) ); |
|
537 | + $module_url = add_query_arg('course_id', $course_id, get_term_link($sensei_modules_loop['current_module'], 'module')); |
|
538 | 538 | $module_term_id = $sensei_modules_loop['current_module']->term_id; |
539 | 539 | |
540 | 540 | /** |
@@ -546,7 +546,7 @@ discard block |
||
546 | 546 | * @param int $module_term_id |
547 | 547 | * @param string $course_id |
548 | 548 | */ |
549 | - echo esc_url_raw( apply_filters( 'sensei_the_module_permalink', $module_url, $module_term_id ,$course_id ) ); |
|
549 | + echo esc_url_raw(apply_filters('sensei_the_module_permalink', $module_url, $module_term_id, $course_id)); |
|
550 | 550 | |
551 | 551 | }// end sensei_the_module_permalink |
552 | 552 | |
@@ -558,7 +558,7 @@ discard block |
||
558 | 558 | * |
559 | 559 | * @return string |
560 | 560 | */ |
561 | -function sensei_get_the_module_title(){ |
|
561 | +function sensei_get_the_module_title() { |
|
562 | 562 | |
563 | 563 | global $sensei_modules_loop; |
564 | 564 | |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | * @param $module_term_id |
578 | 578 | * @param $course_id |
579 | 579 | */ |
580 | - return apply_filters( 'sensei_the_module_title', $module_title , $module_term_id, $course_id ); |
|
580 | + return apply_filters('sensei_the_module_title', $module_title, $module_term_id, $course_id); |
|
581 | 581 | |
582 | 582 | } |
583 | 583 | |
@@ -589,7 +589,7 @@ discard block |
||
589 | 589 | * @uses sensei_get_the_module_title |
590 | 590 | * @return string |
591 | 591 | */ |
592 | -function sensei_the_module_title(){ |
|
592 | +function sensei_the_module_title() { |
|
593 | 593 | |
594 | 594 | echo sensei_get_the_module_title(); |
595 | 595 | |
@@ -610,19 +610,19 @@ discard block |
||
610 | 610 | * |
611 | 611 | * @return bool |
612 | 612 | */ |
613 | -function sensei_quiz_has_questions(){ |
|
613 | +function sensei_quiz_has_questions() { |
|
614 | 614 | |
615 | 615 | global $sensei_question_loop; |
616 | 616 | |
617 | - if( !isset( $sensei_question_loop['total'] ) ){ |
|
617 | + if ( ! isset($sensei_question_loop['total'])) { |
|
618 | 618 | return false; |
619 | 619 | } |
620 | 620 | |
621 | - if( $sensei_question_loop['current'] + 1 < $sensei_question_loop['total'] ){ |
|
621 | + if ($sensei_question_loop['current'] + 1 < $sensei_question_loop['total']) { |
|
622 | 622 | |
623 | 623 | return true; |
624 | 624 | |
625 | - }else{ |
|
625 | + } else { |
|
626 | 626 | |
627 | 627 | return false; |
628 | 628 | |
@@ -639,13 +639,13 @@ discard block |
||
639 | 639 | * @since 1.9.0 |
640 | 640 | |
641 | 641 | */ |
642 | -function sensei_setup_the_question(){ |
|
642 | +function sensei_setup_the_question() { |
|
643 | 643 | |
644 | 644 | global $sensei_question_loop; |
645 | 645 | |
646 | 646 | $sensei_question_loop['current']++; |
647 | 647 | $index = $sensei_question_loop['current']; |
648 | - $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][ $index ] ; |
|
648 | + $sensei_question_loop['current_question'] = $sensei_question_loop['questions'][$index]; |
|
649 | 649 | |
650 | 650 | |
651 | 651 | }// end sensei_setup_the_question |
@@ -656,14 +656,14 @@ discard block |
||
656 | 656 | * This function gets the type and loads the template that will handle it. |
657 | 657 | * |
658 | 658 | */ |
659 | -function sensei_the_question_content(){ |
|
659 | +function sensei_the_question_content() { |
|
660 | 660 | |
661 | 661 | global $sensei_question_loop; |
662 | 662 | |
663 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); |
|
663 | + $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID); |
|
664 | 664 | |
665 | 665 | // load the template that displays the question information. |
666 | - WooThemes_Sensei_Question::load_question_template( $question_type ); |
|
666 | + WooThemes_Sensei_Question::load_question_template($question_type); |
|
667 | 667 | |
668 | 668 | }// end sensei_the_question_content |
669 | 669 | |
@@ -672,11 +672,11 @@ discard block |
||
672 | 672 | * |
673 | 673 | * @since 1.9.0 |
674 | 674 | */ |
675 | -function sensei_the_question_class(){ |
|
675 | +function sensei_the_question_class() { |
|
676 | 676 | |
677 | 677 | global $sensei_question_loop; |
678 | 678 | |
679 | - $question_type = Sensei()->question->get_question_type( $sensei_question_loop['current_question']->ID ); |
|
679 | + $question_type = Sensei()->question->get_question_type($sensei_question_loop['current_question']->ID); |
|
680 | 680 | |
681 | 681 | /** |
682 | 682 | * filter the sensei question class within |
@@ -684,16 +684,16 @@ discard block |
||
684 | 684 | * |
685 | 685 | * @since 1.9.0 |
686 | 686 | */ |
687 | - $classes = apply_filters( 'sensei_question_classes', array( $question_type ) ); |
|
687 | + $classes = apply_filters('sensei_question_classes', array($question_type)); |
|
688 | 688 | |
689 | 689 | $html_classes = ''; |
690 | - foreach( $classes as $class ){ |
|
690 | + foreach ($classes as $class) { |
|
691 | 691 | |
692 | - $html_classes .= $class . ' '; |
|
692 | + $html_classes .= $class.' '; |
|
693 | 693 | |
694 | 694 | }// end foreach |
695 | 695 | |
696 | - esc_attr_e( trim( $html_classes ) ); |
|
696 | + esc_attr_e(trim($html_classes)); |
|
697 | 697 | |
698 | 698 | } |
699 | 699 | |
@@ -702,10 +702,10 @@ discard block |
||
702 | 702 | * |
703 | 703 | * @since 1.9.0 |
704 | 704 | */ |
705 | -function sensei_get_the_question_id( ){ |
|
705 | +function sensei_get_the_question_id( ) { |
|
706 | 706 | |
707 | 707 | global $sensei_question_loop; |
708 | - if( isset( $sensei_question_loop['current_question']->ID ) ){ |
|
708 | + if (isset($sensei_question_loop['current_question']->ID)) { |
|
709 | 709 | |
710 | 710 | return $sensei_question_loop['current_question']->ID; |
711 | 711 | |
@@ -734,27 +734,27 @@ discard block |
||
734 | 734 | * @param string $lesson_id |
735 | 735 | * @return bool |
736 | 736 | */ |
737 | -function sensei_can_user_view_lesson( $lesson_id = '', $user_id = '' ){ |
|
737 | +function sensei_can_user_view_lesson($lesson_id = '', $user_id = '') { |
|
738 | 738 | |
739 | - if( empty( $lesson_id ) ){ |
|
739 | + if (empty($lesson_id)) { |
|
740 | 740 | |
741 | 741 | $lesson_id = get_the_ID(); |
742 | 742 | |
743 | 743 | } |
744 | 744 | |
745 | - if( empty( $user_id ) ){ |
|
745 | + if (empty($user_id)) { |
|
746 | 746 | |
747 | 747 | $user_id = get_current_user_id(); |
748 | 748 | |
749 | 749 | } |
750 | 750 | |
751 | 751 | // Check for prerequisite lesson completions |
752 | - $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete( $lesson_id, $user_id ); |
|
753 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course', true ); |
|
754 | - $user_taking_course = Sensei_Utils::user_started_course( $lesson_course_id, $user_id ); |
|
752 | + $pre_requisite_complete = WooThemes_Sensei_Lesson::is_prerequisite_complete($lesson_id, $user_id); |
|
753 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
754 | + $user_taking_course = Sensei_Utils::user_started_course($lesson_course_id, $user_id); |
|
755 | 755 | |
756 | 756 | $is_preview = false; |
757 | - if( Sensei_Utils::is_preview_lesson( $lesson_id ) ) { |
|
757 | + if (Sensei_Utils::is_preview_lesson($lesson_id)) { |
|
758 | 758 | |
759 | 759 | $is_preview = true; |
760 | 760 | $pre_requisite_complete = true; |
@@ -762,24 +762,24 @@ discard block |
||
762 | 762 | }; |
763 | 763 | |
764 | 764 | |
765 | - $user_can_access_lesson = false; |
|
765 | + $user_can_access_lesson = false; |
|
766 | 766 | |
767 | - if( is_user_logged_in() && $user_taking_course ){ |
|
767 | + if (is_user_logged_in() && $user_taking_course) { |
|
768 | 768 | |
769 | - $user_can_access_lesson = true; |
|
769 | + $user_can_access_lesson = true; |
|
770 | 770 | |
771 | 771 | } |
772 | 772 | |
773 | 773 | |
774 | 774 | $access_permission = false; |
775 | 775 | |
776 | - if ( ! Sensei()->settings->get('access_permission') || sensei_all_access() ) { |
|
776 | + if ( ! Sensei()->settings->get('access_permission') || sensei_all_access()) { |
|
777 | 777 | |
778 | 778 | $access_permission = true; |
779 | 779 | |
780 | 780 | } |
781 | 781 | |
782 | - $can_user_view_lesson = $access_permission || ( $user_can_access_lesson && $pre_requisite_complete ) || $is_preview; |
|
782 | + $can_user_view_lesson = $access_permission || ($user_can_access_lesson && $pre_requisite_complete) || $is_preview; |
|
783 | 783 | |
784 | 784 | /** |
785 | 785 | * Filter the can user view lesson function |
@@ -792,7 +792,7 @@ discard block |
||
792 | 792 | * @param string $lesson_id |
793 | 793 | * @param string $user_id |
794 | 794 | */ |
795 | - return apply_filters( 'sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id ); |
|
795 | + return apply_filters('sensei_can_user_view_lesson', $can_user_view_lesson, $lesson_id, $user_id); |
|
796 | 796 | |
797 | 797 | } // end sensei_can_current_user_view_lesson |
798 | 798 | |
@@ -802,54 +802,54 @@ discard block |
||
802 | 802 | * The function should only be called on the single lesson |
803 | 803 | * |
804 | 804 | */ |
805 | -function sensei_the_single_lesson_meta(){ |
|
805 | +function sensei_the_single_lesson_meta() { |
|
806 | 806 | |
807 | 807 | // if the lesson meta is included within theme load that instead of the function content |
808 | - $template = Sensei_Templates::locate_template( 'single-lesson/lesson-meta.php' ); |
|
809 | - if( ! empty( $template ) ){ |
|
808 | + $template = Sensei_Templates::locate_template('single-lesson/lesson-meta.php'); |
|
809 | + if ( ! empty($template)) { |
|
810 | 810 | |
811 | - Sensei_Templates::get_template( 'single-lesson/lesson-meta.php' ); |
|
811 | + Sensei_Templates::get_template('single-lesson/lesson-meta.php'); |
|
812 | 812 | return; |
813 | 813 | |
814 | 814 | } |
815 | 815 | |
816 | 816 | // Get the meta info |
817 | - $lesson_course_id = absint( get_post_meta( get_the_ID(), '_lesson_course', true ) ); |
|
818 | - $is_preview = Sensei_Utils::is_preview_lesson( get_the_ID() ); |
|
817 | + $lesson_course_id = absint(get_post_meta(get_the_ID(), '_lesson_course', true)); |
|
818 | + $is_preview = Sensei_Utils::is_preview_lesson(get_the_ID()); |
|
819 | 819 | |
820 | 820 | // Get User Meta |
821 | 821 | get_currentuserinfo(); |
822 | 822 | |
823 | 823 | // Complete Lesson Logic |
824 | - do_action( 'sensei_complete_lesson' ); |
|
824 | + do_action('sensei_complete_lesson'); |
|
825 | 825 | // Check that the course has been started |
826 | - if ( Sensei()->access_settings() |
|
827 | - || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) |
|
828 | - || $is_preview ) { |
|
826 | + if (Sensei()->access_settings() |
|
827 | + || Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id()) |
|
828 | + || $is_preview) { |
|
829 | 829 | ?> |
830 | 830 | <section class="lesson-meta"> |
831 | 831 | <?php |
832 | - if( apply_filters( 'sensei_video_position', 'top', get_the_ID() ) == 'bottom' ) { |
|
832 | + if (apply_filters('sensei_video_position', 'top', get_the_ID()) == 'bottom') { |
|
833 | 833 | |
834 | - do_action( 'sensei_lesson_video', get_the_ID() ); |
|
834 | + do_action('sensei_lesson_video', get_the_ID()); |
|
835 | 835 | |
836 | 836 | } |
837 | 837 | ?> |
838 | - <?php do_action( 'sensei_frontend_messages' ); ?> |
|
838 | + <?php do_action('sensei_frontend_messages'); ?> |
|
839 | 839 | |
840 | 840 | <?php if ( ! $is_preview |
841 | - || Sensei_Utils::user_started_course( $lesson_course_id, get_current_user_id()) ) { |
|
841 | + || Sensei_Utils::user_started_course($lesson_course_id, get_current_user_id())) { |
|
842 | 842 | |
843 | - sensei_do_deprecated_action( 'sensei_lesson_quiz_meta','1.9.0', 'sensei_single_lesson_content_inside_before' ,array( get_the_ID(), get_current_user_id() ) ); |
|
843 | + sensei_do_deprecated_action('sensei_lesson_quiz_meta', '1.9.0', 'sensei_single_lesson_content_inside_before', array(get_the_ID(), get_current_user_id())); |
|
844 | 844 | |
845 | 845 | } ?> |
846 | 846 | </section> |
847 | 847 | |
848 | - <?php do_action( 'sensei_lesson_back_link', $lesson_course_id ); ?> |
|
848 | + <?php do_action('sensei_lesson_back_link', $lesson_course_id); ?> |
|
849 | 849 | |
850 | 850 | <?php } |
851 | 851 | |
852 | - do_action( 'sensei_lesson_meta_extra', get_the_ID() ); |
|
852 | + do_action('sensei_lesson_meta_extra', get_the_ID()); |
|
853 | 853 | |
854 | 854 | } // end the_single_lesson_meta |
855 | 855 | |
@@ -863,9 +863,9 @@ discard block |
||
863 | 863 | * |
864 | 864 | * @since 1.9.0 |
865 | 865 | */ |
866 | -function get_sensei_header(){ |
|
866 | +function get_sensei_header() { |
|
867 | 867 | |
868 | - if ( ! defined( 'ABSPATH' ) ) exit; |
|
868 | + if ( ! defined('ABSPATH')) exit; |
|
869 | 869 | |
870 | 870 | get_header(); |
871 | 871 | |
@@ -874,7 +874,7 @@ discard block |
||
874 | 874 | * |
875 | 875 | * @hooked sensei_output_content_wrapper - 10 (outputs opening divs for the content) |
876 | 876 | */ |
877 | - do_action( 'sensei_before_main_content' ); |
|
877 | + do_action('sensei_before_main_content'); |
|
878 | 878 | |
879 | 879 | }// end get_sensei_header |
880 | 880 | |
@@ -888,28 +888,28 @@ discard block |
||
888 | 888 | * |
889 | 889 | * @since 1.9.0 |
890 | 890 | */ |
891 | -function get_sensei_footer(){ |
|
891 | +function get_sensei_footer() { |
|
892 | 892 | |
893 | 893 | /** |
894 | 894 | * sensei_pagination hook |
895 | 895 | * |
896 | 896 | * @hooked sensei_pagination - 10 (outputs pagination) |
897 | 897 | */ |
898 | - do_action( 'sensei_pagination' ); |
|
898 | + do_action('sensei_pagination'); |
|
899 | 899 | |
900 | 900 | /** |
901 | 901 | * sensei_after_main_content hook |
902 | 902 | * |
903 | 903 | * @hooked sensei_output_content_wrapper_end - 10 (outputs closing divs for the content) |
904 | 904 | */ |
905 | - do_action( 'sensei_after_main_content' ); |
|
905 | + do_action('sensei_after_main_content'); |
|
906 | 906 | |
907 | 907 | /** |
908 | 908 | * sensei_sidebar hook |
909 | 909 | * |
910 | 910 | * @hooked sensei_get_sidebar - 10 |
911 | 911 | */ |
912 | - do_action( 'sensei_sidebar' ); |
|
912 | + do_action('sensei_sidebar'); |
|
913 | 913 | |
914 | 914 | get_footer(); |
915 | 915 | |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | * |
922 | 922 | * @since 1.9.0 |
923 | 923 | */ |
924 | -function the_no_permissions_title(){ |
|
924 | +function the_no_permissions_title() { |
|
925 | 925 | |
926 | 926 | /** |
927 | 927 | * Filter the no permissions title just before it is echo'd on the |
@@ -930,7 +930,7 @@ discard block |
||
930 | 930 | * @since 1.9.0 |
931 | 931 | * @param $no_permissions_title |
932 | 932 | */ |
933 | - echo apply_filters( 'sensei_the_no_permissions_title', Sensei()->permissions_message['title'] ); |
|
933 | + echo apply_filters('sensei_the_no_permissions_title', Sensei()->permissions_message['title']); |
|
934 | 934 | |
935 | 935 | } |
936 | 936 | |
@@ -939,7 +939,7 @@ discard block |
||
939 | 939 | * |
940 | 940 | * @since 1.9.0 |
941 | 941 | */ |
942 | -function the_no_permissions_message( $post_id ){ |
|
942 | +function the_no_permissions_message($post_id) { |
|
943 | 943 | |
944 | 944 | /** |
945 | 945 | * Filter the no permissions message just before it is echo'd on the |
@@ -948,7 +948,7 @@ discard block |
||
948 | 948 | * @since 1.9.0 |
949 | 949 | * @param $no_permissions_message |
950 | 950 | */ |
951 | - echo apply_filters( 'sensei_the_no_permissions_message', Sensei()->permissions_message['message'] , $post_id ); |
|
951 | + echo apply_filters('sensei_the_no_permissions_message', Sensei()->permissions_message['message'], $post_id); |
|
952 | 952 | |
953 | 953 | } |
954 | 954 | |
@@ -957,10 +957,10 @@ discard block |
||
957 | 957 | * |
958 | 958 | * @since 1.9.0 |
959 | 959 | */ |
960 | -function sensei_the_excerpt( $post_id ){ |
|
960 | +function sensei_the_excerpt($post_id) { |
|
961 | 961 | |
962 | 962 | global $post; |
963 | - the_excerpt( $post ); |
|
963 | + the_excerpt($post); |
|
964 | 964 | |
965 | 965 | } |
966 | 966 | |
@@ -972,10 +972,10 @@ discard block |
||
972 | 972 | * @global WP $wp |
973 | 973 | * @return string $current_page_url |
974 | 974 | */ |
975 | - function sensei_get_current_page_url(){ |
|
975 | + function sensei_get_current_page_url() { |
|
976 | 976 | |
977 | 977 | global $wp; |
978 | - $current_page_url = home_url( $wp->request ); |
|
978 | + $current_page_url = home_url($wp->request); |
|
979 | 979 | return $current_page_url; |
980 | 980 | |
981 | 981 | } |
@@ -986,9 +986,9 @@ discard block |
||
986 | 986 | * |
987 | 987 | * @since 1.9.0 |
988 | 988 | */ |
989 | -function sensei_the_my_courses_content(){ |
|
989 | +function sensei_the_my_courses_content() { |
|
990 | 990 | |
991 | - echo Sensei()->course->load_user_courses_content( wp_get_current_user() ); |
|
991 | + echo Sensei()->course->load_user_courses_content(wp_get_current_user()); |
|
992 | 992 | |
993 | 993 | } // sensei_the_my_courses_content |
994 | 994 | |
@@ -1001,9 +1001,9 @@ discard block |
||
1001 | 1001 | * |
1002 | 1002 | * @since 1.9.0 |
1003 | 1003 | */ |
1004 | -function sensei_load_template( $template_name ){ |
|
1004 | +function sensei_load_template($template_name) { |
|
1005 | 1005 | |
1006 | - Sensei_Templates::get_template( $template_name ); |
|
1006 | + Sensei_Templates::get_template($template_name); |
|
1007 | 1007 | |
1008 | 1008 | } |
1009 | 1009 | |
@@ -1015,9 +1015,9 @@ discard block |
||
1015 | 1015 | * @param string $name the name of the template. |
1016 | 1016 | * @since 1.9.0 |
1017 | 1017 | */ |
1018 | -function sensei_load_template_part( $slug, $name ){ |
|
1018 | +function sensei_load_template_part($slug, $name) { |
|
1019 | 1019 | |
1020 | - Sensei_Templates::get_part( $slug, $name ); |
|
1020 | + Sensei_Templates::get_part($slug, $name); |
|
1021 | 1021 | |
1022 | 1022 | } |
1023 | 1023 | |
@@ -1034,19 +1034,19 @@ discard block |
||
1034 | 1034 | * @access public |
1035 | 1035 | * @param string $lesson_id |
1036 | 1036 | */ |
1037 | -function sensei_the_lesson_excerpt( $lesson_id = '' ) { |
|
1037 | +function sensei_the_lesson_excerpt($lesson_id = '') { |
|
1038 | 1038 | |
1039 | - if( empty( $lesson_id )){ |
|
1039 | + if (empty($lesson_id)) { |
|
1040 | 1040 | |
1041 | 1041 | $lesson_id = get_the_ID(); |
1042 | 1042 | |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - if( 'lesson' != get_post_type( $lesson_id ) ){ |
|
1045 | + if ('lesson' != get_post_type($lesson_id)) { |
|
1046 | 1046 | return; |
1047 | 1047 | } |
1048 | 1048 | |
1049 | - echo Sensei_Lesson::lesson_excerpt( get_post( $lesson_id ), false ); |
|
1049 | + echo Sensei_Lesson::lesson_excerpt(get_post($lesson_id), false); |
|
1050 | 1050 | |
1051 | 1051 | }// End lesson_excerpt() |
1052 | 1052 | |
@@ -1055,17 +1055,17 @@ discard block |
||
1055 | 1055 | * |
1056 | 1056 | * @since 1.9.0 |
1057 | 1057 | */ |
1058 | -function sensei_the_course_results_lessons(){ |
|
1058 | +function sensei_the_course_results_lessons() { |
|
1059 | 1059 | // load backwards compatible template name if it exists in the users theme |
1060 | - $located_template= locate_template( Sensei()->template_url . 'course-results/course-lessons.php' ); |
|
1061 | - if( $located_template ){ |
|
1060 | + $located_template = locate_template(Sensei()->template_url.'course-results/course-lessons.php'); |
|
1061 | + if ($located_template) { |
|
1062 | 1062 | |
1063 | - Sensei_Templates::get_template( 'course-results/course-lessons.php' ); |
|
1063 | + Sensei_Templates::get_template('course-results/course-lessons.php'); |
|
1064 | 1064 | return; |
1065 | 1065 | |
1066 | 1066 | } |
1067 | 1067 | |
1068 | - Sensei_Templates::get_template( 'course-results/lessons.php' ); |
|
1068 | + Sensei_Templates::get_template('course-results/lessons.php'); |
|
1069 | 1069 | } |
1070 | 1070 | |
1071 | 1071 | /** |
@@ -1075,7 +1075,7 @@ discard block |
||
1075 | 1075 | * @uses Sensei_Course::get_loop_number_of_columns |
1076 | 1076 | * @since 1.9.0 |
1077 | 1077 | */ |
1078 | -function sensei_courses_per_row(){ |
|
1078 | +function sensei_courses_per_row() { |
|
1079 | 1079 | |
1080 | 1080 | echo Sensei_Course::get_loop_number_of_columns(); |
1081 | 1081 | |
@@ -1089,8 +1089,8 @@ discard block |
||
1089 | 1089 | * @param $args |
1090 | 1090 | * @param $path |
1091 | 1091 | */ |
1092 | -function sensei_get_template( $template_name, $args, $path ){ |
|
1092 | +function sensei_get_template($template_name, $args, $path) { |
|
1093 | 1093 | |
1094 | - Sensei_Templates::get_template( $template_name, $args, $path ); |
|
1094 | + Sensei_Templates::get_template($template_name, $args, $path); |
|
1095 | 1095 | |
1096 | 1096 | } |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | ?> |
13 | 13 | |
14 | -<?php get_sensei_header(); ?> |
|
14 | +<?php get_sensei_header(); ?> |
|
15 | 15 | |
16 | 16 | <?php |
17 | 17 | /** |
@@ -21,10 +21,10 @@ discard block |
||
21 | 21 | * @since 1.9.0 |
22 | 22 | * @param $post_id |
23 | 23 | */ |
24 | -do_action('sensei_no_permissions_before_content', get_the_ID() ); |
|
24 | +do_action('sensei_no_permissions_before_content', get_the_ID()); |
|
25 | 25 | ?> |
26 | 26 | |
27 | -<article <?php post_class( 'no-permission' ) ?> > |
|
27 | +<article <?php post_class('no-permission') ?> > |
|
28 | 28 | |
29 | 29 | <header> |
30 | 30 | |
@@ -40,20 +40,20 @@ discard block |
||
40 | 40 | * @since 1.9.0 |
41 | 41 | * @param $post_id |
42 | 42 | */ |
43 | - do_action('sensei_no_permissions_inside_before_content', get_the_ID() ); |
|
43 | + do_action('sensei_no_permissions_inside_before_content', get_the_ID()); |
|
44 | 44 | ?> |
45 | 45 | |
46 | 46 | <section class="entry fix"> |
47 | 47 | |
48 | 48 | <div class="sensei-message alert"> |
49 | 49 | |
50 | - <?php the_no_permissions_message( get_the_ID() ); ?> |
|
50 | + <?php the_no_permissions_message(get_the_ID()); ?> |
|
51 | 51 | |
52 | 52 | </div> |
53 | 53 | |
54 | 54 | <p class="excerpt"> |
55 | 55 | |
56 | - <?php sensei_the_excerpt( get_the_ID() ); ?> |
|
56 | + <?php sensei_the_excerpt(get_the_ID()); ?> |
|
57 | 57 | |
58 | 58 | </p> |
59 | 59 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @since 1.9.0 |
68 | 68 | * @param $post_id |
69 | 69 | */ |
70 | - do_action('sensei_no_permissions_inside_after_content', get_the_ID() ); |
|
70 | + do_action('sensei_no_permissions_inside_after_content', get_the_ID()); |
|
71 | 71 | ?> |
72 | 72 | |
73 | 73 | </article><!-- .no-permissions --> |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @since 1.9.0 |
81 | 81 | * @param $post_id |
82 | 82 | */ |
83 | -do_action('sensei_no_permissions_after_content', get_the_ID() ); |
|
83 | +do_action('sensei_no_permissions_after_content', get_the_ID()); |
|
84 | 84 | ?> |
85 | 85 | |
86 | 86 | <?php get_sensei_footer(); ?> |
87 | 87 | \ No newline at end of file |
@@ -33,15 +33,15 @@ discard block |
||
33 | 33 | </header> |
34 | 34 | |
35 | 35 | <?php |
36 | - /** |
|
37 | - * This action fires inside the no-permissions.php file. It |
|
38 | - * is place just before the content. |
|
39 | - * |
|
40 | - * @since 1.9.0 |
|
41 | - * @param $post_id |
|
42 | - */ |
|
43 | - do_action('sensei_no_permissions_inside_before_content', get_the_ID() ); |
|
44 | - ?> |
|
36 | + /** |
|
37 | + * This action fires inside the no-permissions.php file. It |
|
38 | + * is place just before the content. |
|
39 | + * |
|
40 | + * @since 1.9.0 |
|
41 | + * @param $post_id |
|
42 | + */ |
|
43 | + do_action('sensei_no_permissions_inside_before_content', get_the_ID() ); |
|
44 | + ?> |
|
45 | 45 | |
46 | 46 | <section class="entry fix"> |
47 | 47 | |
@@ -60,26 +60,26 @@ discard block |
||
60 | 60 | </section> |
61 | 61 | |
62 | 62 | <?php |
63 | - /** |
|
64 | - * This action fires inside the no-permissions.php file. It |
|
65 | - * is place just after the content. |
|
66 | - * |
|
67 | - * @since 1.9.0 |
|
68 | - * @param $post_id |
|
69 | - */ |
|
70 | - do_action('sensei_no_permissions_inside_after_content', get_the_ID() ); |
|
71 | - ?> |
|
63 | + /** |
|
64 | + * This action fires inside the no-permissions.php file. It |
|
65 | + * is place just after the content. |
|
66 | + * |
|
67 | + * @since 1.9.0 |
|
68 | + * @param $post_id |
|
69 | + */ |
|
70 | + do_action('sensei_no_permissions_inside_after_content', get_the_ID() ); |
|
71 | + ?> |
|
72 | 72 | |
73 | 73 | </article><!-- .no-permissions --> |
74 | 74 | |
75 | 75 | <?php |
76 | 76 | /** |
77 | - * This action fires inside the no-permissions.php file. It |
|
78 | - * is placed outside after the content. |
|
79 | - * |
|
80 | - * @since 1.9.0 |
|
81 | - * @param $post_id |
|
82 | - */ |
|
77 | + * This action fires inside the no-permissions.php file. It |
|
78 | + * is placed outside after the content. |
|
79 | + * |
|
80 | + * @since 1.9.0 |
|
81 | + * @param $post_id |
|
82 | + */ |
|
83 | 83 | do_action('sensei_no_permissions_after_content', get_the_ID() ); |
84 | 84 | ?> |
85 | 85 |
@@ -1,5 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
5 | +// Exit if accessed directly |
|
3 | 6 | |
4 | 7 | /** |
5 | 8 | * Sensei Frontend Class |
@@ -668,7 +671,9 @@ discard block |
||
668 | 671 | public function sensei_breadcrumb( $id = 0 ) { |
669 | 672 | |
670 | 673 | // Only output on lesson, quiz and taxonomy (module) pages |
671 | - if( ! ( is_tax( 'module' ) || is_singular( 'lesson' ) || is_singular( 'quiz' ) ) ) return; |
|
674 | + if( ! ( is_tax( 'module' ) || is_singular( 'lesson' ) || is_singular( 'quiz' ) ) ) { |
|
675 | + return; |
|
676 | + } |
|
672 | 677 | |
673 | 678 | if( empty( $id ) ){ |
674 | 679 | |
@@ -1094,17 +1099,26 @@ discard block |
||
1094 | 1099 | |
1095 | 1100 | <p class="form-row form-row-wide"> |
1096 | 1101 | <label for="sensei_reg_username"><?php _e( 'Username', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
1097 | - <input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty( $_POST['sensei_reg_username'] ) ) esc_attr_e( $_POST['sensei_reg_username'] ); ?>" /> |
|
1102 | + <input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty( $_POST['sensei_reg_username'] ) ) { |
|
1103 | + esc_attr_e( $_POST['sensei_reg_username'] ); |
|
1104 | +} |
|
1105 | +?>" /> |
|
1098 | 1106 | </p> |
1099 | 1107 | |
1100 | 1108 | <p class="form-row form-row-wide"> |
1101 | 1109 | <label for="sensei_reg_email"><?php _e( 'Email address', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
1102 | - <input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty( $_POST['sensei_reg_email'] ) ) esc_attr_e( $_POST['sensei_reg_email'] ); ?>" /> |
|
1110 | + <input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty( $_POST['sensei_reg_email'] ) ) { |
|
1111 | + esc_attr_e( $_POST['sensei_reg_email'] ); |
|
1112 | +} |
|
1113 | +?>" /> |
|
1103 | 1114 | </p> |
1104 | 1115 | |
1105 | 1116 | <p class="form-row form-row-wide"> |
1106 | 1117 | <label for="sensei_reg_password"><?php _e( 'Password', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
1107 | - <input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty( $_POST['sensei_reg_password'] ) ) esc_attr_e( $_POST['sensei_reg_password'] ); ?>" /> |
|
1118 | + <input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty( $_POST['sensei_reg_password'] ) ) { |
|
1119 | + esc_attr_e( $_POST['sensei_reg_password'] ); |
|
1120 | +} |
|
1121 | +?>" /> |
|
1108 | 1122 | </p> |
1109 | 1123 | |
1110 | 1124 | <!-- Spam Trap --> |
@@ -1437,8 +1451,12 @@ discard block |
||
1437 | 1451 | |
1438 | 1452 | if( Sensei_WC::is_woocommerce_active() ) { |
1439 | 1453 | |
1440 | - if( ! is_user_logged_in() ) return; |
|
1441 | - if( ! isset( $post->ID ) ) return; |
|
1454 | + if( ! is_user_logged_in() ) { |
|
1455 | + return; |
|
1456 | + } |
|
1457 | + if( ! isset( $post->ID ) ) { |
|
1458 | + return; |
|
1459 | + } |
|
1442 | 1460 | |
1443 | 1461 | $user_id = $current_user->ID; |
1444 | 1462 | $course_id = $post->ID; |
@@ -1599,7 +1617,7 @@ discard block |
||
1599 | 1617 | //assigne the username to the creds array for further processing |
1600 | 1618 | $creds['user_login'] = $user->user_login ; |
1601 | 1619 | |
1602 | - }else{ |
|
1620 | + } else{ |
|
1603 | 1621 | |
1604 | 1622 | // process this as a default username login |
1605 | 1623 | $creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ; |
@@ -1616,7 +1634,7 @@ discard block |
||
1616 | 1634 | if ( is_wp_error($user) ){ // on login failure |
1617 | 1635 | wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
1618 | 1636 | exit; |
1619 | - }else{ // on login success |
|
1637 | + } else{ // on login success |
|
1620 | 1638 | |
1621 | 1639 | /** |
1622 | 1640 | * change the redirect url programatically |
@@ -1633,14 +1651,14 @@ discard block |
||
1633 | 1651 | |
1634 | 1652 | } // end is_wp_error($user) |
1635 | 1653 | |
1636 | - }else{ // if username or password is empty |
|
1654 | + } else{ // if username or password is empty |
|
1637 | 1655 | |
1638 | 1656 | wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) ); |
1639 | 1657 | exit; |
1640 | 1658 | |
1641 | 1659 | } // end if username $_REQUEST['log'] and password $_REQUEST['pwd'] is empty |
1642 | 1660 | |
1643 | - }elseif( ( isset( $_GET['login'] ) ) ) { |
|
1661 | + } elseif( ( isset( $_GET['login'] ) ) ) { |
|
1644 | 1662 | // else if this request is a redircect from a previously faile login request |
1645 | 1663 | $this->login_message_process(); |
1646 | 1664 | |
@@ -1762,7 +1780,7 @@ discard block |
||
1762 | 1780 | |
1763 | 1781 | $message = __('Incorrect login details', 'woothemes-sensei' ); |
1764 | 1782 | |
1765 | - }elseif( $_GET['login'] == 'emptyfields' ){ |
|
1783 | + } elseif( $_GET['login'] == 'emptyfields' ){ |
|
1766 | 1784 | |
1767 | 1785 | $message= __('Please enter your username and password', 'woothemes-sensei' ); |
1768 | 1786 | } |
@@ -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 Frontend Class |
@@ -21,78 +21,78 @@ discard block |
||
21 | 21 | * Constructor. |
22 | 22 | * @since 1.0.0 |
23 | 23 | */ |
24 | - public function __construct () { |
|
24 | + public function __construct() { |
|
25 | 25 | |
26 | 26 | // Template output actions |
27 | - add_action( 'sensei_before_main_content', array( $this, 'sensei_output_content_wrapper' ), 10 ); |
|
28 | - add_action( 'sensei_after_main_content', array( $this, 'sensei_output_content_wrapper_end' ), 10 ); |
|
29 | - add_action( 'sensei_lesson_archive_lesson_title', array( $this, 'sensei_lesson_archive_lesson_title' ), 10 ); |
|
27 | + add_action('sensei_before_main_content', array($this, 'sensei_output_content_wrapper'), 10); |
|
28 | + add_action('sensei_after_main_content', array($this, 'sensei_output_content_wrapper_end'), 10); |
|
29 | + add_action('sensei_lesson_archive_lesson_title', array($this, 'sensei_lesson_archive_lesson_title'), 10); |
|
30 | 30 | |
31 | 31 | // 1.2.1 |
32 | - add_action( 'sensei_complete_lesson', array( $this, 'sensei_complete_lesson' ) ); |
|
33 | - add_action( 'init', array( $this, 'sensei_complete_course' ), 5 ); |
|
34 | - add_action( 'sensei_frontend_messages', array( $this, 'sensei_frontend_messages' ) ); |
|
35 | - add_action( 'sensei_lesson_video', array( $this, 'sensei_lesson_video' ), 10, 1 ); |
|
36 | - add_action( 'sensei_complete_lesson_button', array( $this, 'sensei_complete_lesson_button' ) ); |
|
37 | - add_action( 'sensei_reset_lesson_button', array( $this, 'sensei_reset_lesson_button' ) ); |
|
32 | + add_action('sensei_complete_lesson', array($this, 'sensei_complete_lesson')); |
|
33 | + add_action('init', array($this, 'sensei_complete_course'), 5); |
|
34 | + add_action('sensei_frontend_messages', array($this, 'sensei_frontend_messages')); |
|
35 | + add_action('sensei_lesson_video', array($this, 'sensei_lesson_video'), 10, 1); |
|
36 | + add_action('sensei_complete_lesson_button', array($this, 'sensei_complete_lesson_button')); |
|
37 | + add_action('sensei_reset_lesson_button', array($this, 'sensei_reset_lesson_button')); |
|
38 | 38 | |
39 | - add_action( 'sensei_course_archive_meta', array( $this, 'sensei_course_archive_meta' ) ); |
|
39 | + add_action('sensei_course_archive_meta', array($this, 'sensei_course_archive_meta')); |
|
40 | 40 | |
41 | - add_action( 'sensei_lesson_tag_main_content', array( $this, 'sensei_lesson_archive_main_content' ), 10 ); |
|
42 | - add_action( 'sensei_no_permissions_main_content', array( $this, 'sensei_no_permissions_main_content' ), 10 ); |
|
41 | + add_action('sensei_lesson_tag_main_content', array($this, 'sensei_lesson_archive_main_content'), 10); |
|
42 | + add_action('sensei_no_permissions_main_content', array($this, 'sensei_no_permissions_main_content'), 10); |
|
43 | 43 | |
44 | - add_action( 'sensei_lesson_meta', array( $this, 'sensei_lesson_meta' ), 10 ); |
|
45 | - add_action( 'sensei_single_course_content_inside_before', array( $this, 'sensei_course_start' ), 10 ); |
|
44 | + add_action('sensei_lesson_meta', array($this, 'sensei_lesson_meta'), 10); |
|
45 | + add_action('sensei_single_course_content_inside_before', array($this, 'sensei_course_start'), 10); |
|
46 | 46 | |
47 | 47 | // add_filter( 'get_comments_number', array( $this, 'sensei_lesson_comment_count' ), 1 ); |
48 | - add_filter( 'the_title', array( $this, 'sensei_lesson_preview_title' ), 10, 2 ); |
|
48 | + add_filter('the_title', array($this, 'sensei_lesson_preview_title'), 10, 2); |
|
49 | 49 | |
50 | 50 | //1.6.2 |
51 | - add_filter( 'wp_login_failed', array( $this, 'sensei_login_fail_redirect' ), 10 ); |
|
52 | - add_filter( 'init', array( $this, 'sensei_handle_login_request' ), 10 ); |
|
51 | + add_filter('wp_login_failed', array($this, 'sensei_login_fail_redirect'), 10); |
|
52 | + add_filter('init', array($this, 'sensei_handle_login_request'), 10); |
|
53 | 53 | //1.6.3 |
54 | - add_action( 'init', array( $this, 'sensei_process_registration' ), 2 ); |
|
54 | + add_action('init', array($this, 'sensei_process_registration'), 2); |
|
55 | 55 | //1.7.0 |
56 | - add_action( 'sensei_pagination', array( $this, 'sensei_breadcrumb' ), 80, 1 ); |
|
56 | + add_action('sensei_pagination', array($this, 'sensei_breadcrumb'), 80, 1); |
|
57 | 57 | |
58 | 58 | // Fix pagination for course archive pages when filtering by course type |
59 | - add_filter( 'pre_get_posts', array( $this, 'sensei_course_archive_pagination' ) ); |
|
59 | + add_filter('pre_get_posts', array($this, 'sensei_course_archive_pagination')); |
|
60 | 60 | |
61 | 61 | // Scripts and Styles |
62 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_styles' ) ); |
|
63 | - add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ) ); |
|
62 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_styles')); |
|
63 | + add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts')); |
|
64 | 64 | |
65 | 65 | // Custom Menu Item filters |
66 | - add_filter( 'wp_setup_nav_menu_item', array( $this, 'sensei_setup_nav_menu_item' ) ); |
|
67 | - add_filter( 'wp_nav_menu_objects', array( $this, 'sensei_wp_nav_menu_objects' ) ); |
|
66 | + add_filter('wp_setup_nav_menu_item', array($this, 'sensei_setup_nav_menu_item')); |
|
67 | + add_filter('wp_nav_menu_objects', array($this, 'sensei_wp_nav_menu_objects')); |
|
68 | 68 | // Search Results filters |
69 | - add_filter( 'post_class', array( $this, 'sensei_search_results_classes' ), 10 ); |
|
69 | + add_filter('post_class', array($this, 'sensei_search_results_classes'), 10); |
|
70 | 70 | // Only show course & lesson excerpts in search results |
71 | - add_filter( 'the_content', array( $this, 'sensei_search_results_excerpt' ) ); |
|
71 | + add_filter('the_content', array($this, 'sensei_search_results_excerpt')); |
|
72 | 72 | |
73 | 73 | //Use WooCommerce filter to show admin bar to Teachers. |
74 | - add_action( 'init', array( $this, 'sensei_show_admin_bar') ); |
|
74 | + add_action('init', array($this, 'sensei_show_admin_bar')); |
|
75 | 75 | |
76 | 76 | // Remove course from active courses if an order is cancelled or refunded |
77 | - add_action( 'woocommerce_order_status_processing_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
|
78 | - add_action( 'woocommerce_order_status_completed_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
|
79 | - add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
|
80 | - add_action( 'woocommerce_order_status_processing_to_refunded', array( $this, 'remove_active_course' ), 10, 1 ); |
|
81 | - add_action( 'woocommerce_order_status_completed_to_refunded', array( $this, 'remove_active_course' ), 10, 1 ); |
|
82 | - add_action( 'woocommerce_order_status_on-hold_to_refunded', array( $this, 'remove_active_course' ), 10, 1 ); |
|
77 | + add_action('woocommerce_order_status_processing_to_cancelled', array($this, 'remove_active_course'), 10, 1); |
|
78 | + add_action('woocommerce_order_status_completed_to_cancelled', array($this, 'remove_active_course'), 10, 1); |
|
79 | + add_action('woocommerce_order_status_on-hold_to_cancelled', array($this, 'remove_active_course'), 10, 1); |
|
80 | + add_action('woocommerce_order_status_processing_to_refunded', array($this, 'remove_active_course'), 10, 1); |
|
81 | + add_action('woocommerce_order_status_completed_to_refunded', array($this, 'remove_active_course'), 10, 1); |
|
82 | + add_action('woocommerce_order_status_on-hold_to_refunded', array($this, 'remove_active_course'), 10, 1); |
|
83 | 83 | |
84 | 84 | // Make sure correct courses are marked as active for users |
85 | - add_action( 'sensei_before_my_courses', array( $this, 'activate_purchased_courses' ), 10, 1 ); |
|
86 | - add_action( 'sensei_single_course_content_inside_before', array( $this, 'activate_purchased_single_course' ), 10 ); |
|
85 | + add_action('sensei_before_my_courses', array($this, 'activate_purchased_courses'), 10, 1); |
|
86 | + add_action('sensei_single_course_content_inside_before', array($this, 'activate_purchased_single_course'), 10); |
|
87 | 87 | |
88 | 88 | // Lesson tags |
89 | - add_action( 'sensei_lesson_meta_extra', array( $this, 'lesson_tags_display' ), 10, 1 ); |
|
90 | - add_action( 'pre_get_posts', array( $this, 'lesson_tag_archive_filter' ), 10, 1 ); |
|
91 | - add_filter( 'sensei_lessons_archive_text', array( $this, 'lesson_tag_archive_header' ) ); |
|
92 | - add_action( 'sensei_loop_lesson_inside_before', array( $this, 'lesson_tag_archive_description' ), 11 ); |
|
89 | + add_action('sensei_lesson_meta_extra', array($this, 'lesson_tags_display'), 10, 1); |
|
90 | + add_action('pre_get_posts', array($this, 'lesson_tag_archive_filter'), 10, 1); |
|
91 | + add_filter('sensei_lessons_archive_text', array($this, 'lesson_tag_archive_header')); |
|
92 | + add_action('sensei_loop_lesson_inside_before', array($this, 'lesson_tag_archive_description'), 11); |
|
93 | 93 | |
94 | 94 | // Hide Sensei activity comments from lesson and course pages |
95 | - add_filter( 'wp_list_comments_args', array( $this, 'hide_sensei_activity' ) ); |
|
95 | + add_filter('wp_list_comments_args', array($this, 'hide_sensei_activity')); |
|
96 | 96 | } // End __construct() |
97 | 97 | |
98 | 98 | /** |
@@ -102,11 +102,11 @@ discard block |
||
102 | 102 | * @since 1.7.3 |
103 | 103 | * @return array|mixed |
104 | 104 | */ |
105 | - public function __get( $key ) { |
|
105 | + public function __get($key) { |
|
106 | 106 | |
107 | - if ( 'lesson' == $key || 'course' == $key ) { |
|
108 | - if ( WP_DEBUG ) { |
|
109 | - trigger_error( sprintf( 'Sensei()->frontend->%1$s has been <strong>deprecated</strong> since version %2$s! Please use Sensei()->%1$s to access the instance.', $key, '1.7.3' ) ); |
|
107 | + if ('lesson' == $key || 'course' == $key) { |
|
108 | + if (WP_DEBUG) { |
|
109 | + trigger_error(sprintf('Sensei()->frontend->%1$s has been <strong>deprecated</strong> since version %2$s! Please use Sensei()->%1$s to access the instance.', $key, '1.7.3')); |
|
110 | 110 | } |
111 | 111 | return Sensei()->$key; |
112 | 112 | } |
@@ -119,32 +119,32 @@ discard block |
||
119 | 119 | * @since 1.0.0 |
120 | 120 | * @return void |
121 | 121 | */ |
122 | - public function enqueue_scripts () { |
|
122 | + public function enqueue_scripts() { |
|
123 | 123 | |
124 | 124 | $disable_js = false; |
125 | - if ( isset( Sensei()->settings->settings[ 'js_disable' ] ) ) { |
|
126 | - $disable_js = Sensei()->settings->settings[ 'js_disable' ]; |
|
125 | + if (isset(Sensei()->settings->settings['js_disable'])) { |
|
126 | + $disable_js = Sensei()->settings->settings['js_disable']; |
|
127 | 127 | } // End If Statement |
128 | - if ( ! $disable_js ) { |
|
128 | + if ( ! $disable_js) { |
|
129 | 129 | |
130 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
130 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
131 | 131 | |
132 | 132 | // My Courses tabs script |
133 | - wp_register_script( Sensei()->token . '-user-dashboard', esc_url( Sensei()->plugin_url . 'assets/js/user-dashboard' . $suffix . '.js' ), array( 'jquery-ui-tabs' ), Sensei()->version, true ); |
|
134 | - wp_enqueue_script( Sensei()->token . '-user-dashboard' ); |
|
133 | + wp_register_script(Sensei()->token.'-user-dashboard', esc_url(Sensei()->plugin_url.'assets/js/user-dashboard'.$suffix.'.js'), array('jquery-ui-tabs'), Sensei()->version, true); |
|
134 | + wp_enqueue_script(Sensei()->token.'-user-dashboard'); |
|
135 | 135 | |
136 | 136 | |
137 | 137 | // Course Archive javascript |
138 | - if( is_post_type_archive( 'course' ) ){ |
|
138 | + if (is_post_type_archive('course')) { |
|
139 | 139 | |
140 | - wp_register_script( 'sensei-course-archive-js', esc_url( Sensei()->plugin_url . 'assets/js/frontend/course-archive' . $suffix . '.js' ), array( 'jquery' ), '1', true ); |
|
141 | - wp_enqueue_script( 'sensei-course-archive-js' ); |
|
140 | + wp_register_script('sensei-course-archive-js', esc_url(Sensei()->plugin_url.'assets/js/frontend/course-archive'.$suffix.'.js'), array('jquery'), '1', true); |
|
141 | + wp_enqueue_script('sensei-course-archive-js'); |
|
142 | 142 | |
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | 146 | // Allow additional scripts to be loaded |
147 | - do_action( 'sensei_additional_scripts' ); |
|
147 | + do_action('sensei_additional_scripts'); |
|
148 | 148 | |
149 | 149 | } // End If Statement |
150 | 150 | |
@@ -155,24 +155,24 @@ discard block |
||
155 | 155 | * @since 1.0.0 |
156 | 156 | * @return void |
157 | 157 | */ |
158 | - public function enqueue_styles () { |
|
158 | + public function enqueue_styles() { |
|
159 | 159 | |
160 | 160 | |
161 | 161 | $disable_styles = false; |
162 | - if ( isset( Sensei()->settings->settings[ 'styles_disable' ] ) ) { |
|
163 | - $disable_styles = Sensei()->settings->settings[ 'styles_disable' ]; |
|
162 | + if (isset(Sensei()->settings->settings['styles_disable'])) { |
|
163 | + $disable_styles = Sensei()->settings->settings['styles_disable']; |
|
164 | 164 | } // End If Statement |
165 | 165 | |
166 | 166 | // Add filter for theme overrides |
167 | - $disable_styles = apply_filters( 'sensei_disable_styles', $disable_styles ); |
|
167 | + $disable_styles = apply_filters('sensei_disable_styles', $disable_styles); |
|
168 | 168 | |
169 | - if ( ! $disable_styles ) { |
|
169 | + if ( ! $disable_styles) { |
|
170 | 170 | |
171 | - wp_register_style( Sensei()->token . '-frontend', Sensei()->plugin_url . 'assets/css/frontend/sensei.css', '', Sensei()->version, 'screen' ); |
|
172 | - wp_enqueue_style( Sensei()->token . '-frontend' ); |
|
171 | + wp_register_style(Sensei()->token.'-frontend', Sensei()->plugin_url.'assets/css/frontend/sensei.css', '', Sensei()->version, 'screen'); |
|
172 | + wp_enqueue_style(Sensei()->token.'-frontend'); |
|
173 | 173 | |
174 | 174 | // Allow additional stylesheets to be loaded |
175 | - do_action( 'sensei_additional_styles' ); |
|
175 | + do_action('sensei_additional_styles'); |
|
176 | 176 | |
177 | 177 | } // End If Statement |
178 | 178 | |
@@ -188,10 +188,10 @@ discard block |
||
188 | 188 | * @param string $name (default: '') |
189 | 189 | * @return void |
190 | 190 | */ |
191 | - function sensei_get_template_part( $slug, $name = '' ) { |
|
191 | + function sensei_get_template_part($slug, $name = '') { |
|
192 | 192 | |
193 | - _deprecated_function( 'class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part' ); |
|
194 | - Sensei_Templates::get_part( $slug, $name ); |
|
193 | + _deprecated_function('class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part'); |
|
194 | + Sensei_Templates::get_part($slug, $name); |
|
195 | 195 | |
196 | 196 | } // End sensei_get_template_part() |
197 | 197 | |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | * @param string $default_path (default: '') |
207 | 207 | * @return void |
208 | 208 | */ |
209 | - function sensei_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
209 | + function sensei_get_template($template_name, $args = array(), $template_path = '', $default_path = '') { |
|
210 | 210 | |
211 | - _deprecated_function( 'sensei_get_template', '1.9.0', 'Sensei_Templates::get_template' ); |
|
212 | - Sensei_Templates::get_template($template_name, $args, $template_path, $default_path ); |
|
211 | + _deprecated_function('sensei_get_template', '1.9.0', 'Sensei_Templates::get_template'); |
|
212 | + Sensei_Templates::get_template($template_name, $args, $template_path, $default_path); |
|
213 | 213 | |
214 | 214 | } // End sensei_get_template() |
215 | 215 | |
@@ -223,10 +223,10 @@ discard block |
||
223 | 223 | * @param string $default_path (default: '') |
224 | 224 | * @return void |
225 | 225 | */ |
226 | - function sensei_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
226 | + function sensei_locate_template($template_name, $template_path = '', $default_path = '') { |
|
227 | 227 | |
228 | - _deprecated_function( 'sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template' ); |
|
229 | - Sensei_Templates::locate_template( $template_name, $template_path, $default_path ); |
|
228 | + _deprecated_function('sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template'); |
|
229 | + Sensei_Templates::locate_template($template_name, $template_path, $default_path); |
|
230 | 230 | |
231 | 231 | } // End sensei_locate_template() |
232 | 232 | |
@@ -240,20 +240,20 @@ discard block |
||
240 | 240 | function sensei_output_content_wrapper() { |
241 | 241 | |
242 | 242 | // backwards compatibility check for old location under the wrappers directory of the active theme |
243 | - $backwards_compatible_wrapper_location = array( |
|
244 | - Sensei()->template_url . 'wrappers/wrapper-start.php', |
|
243 | + $backwards_compatible_wrapper_location = array( |
|
244 | + Sensei()->template_url.'wrappers/wrapper-start.php', |
|
245 | 245 | 'wrappers/wrapper-start.php' |
246 | 246 | ); |
247 | 247 | |
248 | - $template = locate_template( $backwards_compatible_wrapper_location ); |
|
249 | - if( !empty( $template ) ){ |
|
248 | + $template = locate_template($backwards_compatible_wrapper_location); |
|
249 | + if ( ! empty($template)) { |
|
250 | 250 | |
251 | - Sensei_Templates::get_template( 'wrappers/wrapper-start.php' ); |
|
251 | + Sensei_Templates::get_template('wrappers/wrapper-start.php'); |
|
252 | 252 | return; |
253 | 253 | |
254 | 254 | } |
255 | 255 | |
256 | - Sensei_Templates::get_template( 'globals/wrapper-start.php' ); |
|
256 | + Sensei_Templates::get_template('globals/wrapper-start.php'); |
|
257 | 257 | |
258 | 258 | } // End sensei_output_content_wrapper() |
259 | 259 | |
@@ -267,21 +267,21 @@ discard block |
||
267 | 267 | function sensei_output_content_wrapper_end() { |
268 | 268 | |
269 | 269 | // backwards compatibility check for old location under the wrappers directory of the active theme |
270 | - $backwards_compatible_wrapper_location = array( |
|
271 | - Sensei()->template_url . 'wrappers/wrapper-end.php', |
|
270 | + $backwards_compatible_wrapper_location = array( |
|
271 | + Sensei()->template_url.'wrappers/wrapper-end.php', |
|
272 | 272 | 'wrappers/wrapper-end.php' |
273 | 273 | ); |
274 | 274 | |
275 | - $backwards_compatible_template = locate_template( $backwards_compatible_wrapper_location ); |
|
276 | - if( !empty( $backwards_compatible_template ) ){ |
|
275 | + $backwards_compatible_template = locate_template($backwards_compatible_wrapper_location); |
|
276 | + if ( ! empty($backwards_compatible_template)) { |
|
277 | 277 | |
278 | - Sensei_Templates::get_template( 'wrappers/wrapper-end.php' ); |
|
278 | + Sensei_Templates::get_template('wrappers/wrapper-end.php'); |
|
279 | 279 | return; |
280 | 280 | |
281 | 281 | } |
282 | 282 | |
283 | 283 | |
284 | - Sensei_Templates::get_template( 'globals/wrapper-end.php' ); |
|
284 | + Sensei_Templates::get_template('globals/wrapper-end.php'); |
|
285 | 285 | |
286 | 286 | } // End sensei_output_content_wrapper_end() |
287 | 287 | |
@@ -294,57 +294,57 @@ discard block |
||
294 | 294 | */ |
295 | 295 | public static function load_content_pagination() { |
296 | 296 | |
297 | - if( is_singular('course') ) { |
|
297 | + if (is_singular('course')) { |
|
298 | 298 | |
299 | 299 | // backwards compatibility check for old location under the wrappers directory of the active theme |
300 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-posts.php' ) ); |
|
301 | - if( !empty( $template ) ){ |
|
300 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-posts.php')); |
|
301 | + if ( ! empty($template)) { |
|
302 | 302 | |
303 | - Sensei_Templates::get_template( 'wrappers/pagination-posts.php' ); |
|
303 | + Sensei_Templates::get_template('wrappers/pagination-posts.php'); |
|
304 | 304 | return; |
305 | 305 | |
306 | 306 | } |
307 | 307 | |
308 | - Sensei_Templates::get_template( 'globals/pagination-posts.php' ); |
|
308 | + Sensei_Templates::get_template('globals/pagination-posts.php'); |
|
309 | 309 | |
310 | - } elseif( is_singular('lesson') ) { |
|
310 | + } elseif (is_singular('lesson')) { |
|
311 | 311 | |
312 | 312 | // backwards compatibility check for old location under the wrappers directory of the active theme |
313 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-lesson.php' ) ); |
|
314 | - if( !empty( $template ) ){ |
|
313 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-lesson.php')); |
|
314 | + if ( ! empty($template)) { |
|
315 | 315 | |
316 | - Sensei_Templates::get_template( 'wrappers/pagination-lesson.php' ); |
|
316 | + Sensei_Templates::get_template('wrappers/pagination-lesson.php'); |
|
317 | 317 | return; |
318 | 318 | |
319 | 319 | } |
320 | 320 | |
321 | - Sensei_Templates::get_template( 'globals/pagination-lesson.php' ); |
|
321 | + Sensei_Templates::get_template('globals/pagination-lesson.php'); |
|
322 | 322 | |
323 | - } elseif( is_singular('quiz') ) { |
|
323 | + } elseif (is_singular('quiz')) { |
|
324 | 324 | |
325 | 325 | // backwards compatibility check for old location under the wrappers directory of the active theme |
326 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-quiz.php' ) ); |
|
327 | - if( !empty( $template ) ){ |
|
326 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination-quiz.php')); |
|
327 | + if ( ! empty($template)) { |
|
328 | 328 | |
329 | - Sensei_Templates::get_template( 'wrappers/pagination-quiz.php' ); |
|
329 | + Sensei_Templates::get_template('wrappers/pagination-quiz.php'); |
|
330 | 330 | return; |
331 | 331 | |
332 | 332 | } |
333 | 333 | |
334 | - Sensei_Templates::get_template( 'globals/pagination-quiz.php' ); |
|
334 | + Sensei_Templates::get_template('globals/pagination-quiz.php'); |
|
335 | 335 | |
336 | 336 | } else { |
337 | 337 | |
338 | 338 | // backwards compatibility check for old location under the wrappers directory of the active theme |
339 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination.php' ) ); |
|
340 | - if( !empty( $template ) ){ |
|
339 | + $template = locate_template(array(Sensei()->template_url.'wrappers/pagination.php')); |
|
340 | + if ( ! empty($template)) { |
|
341 | 341 | |
342 | - Sensei_Templates::get_template( 'wrappers/pagination.php' ); |
|
342 | + Sensei_Templates::get_template('wrappers/pagination.php'); |
|
343 | 343 | return; |
344 | 344 | |
345 | 345 | } |
346 | 346 | |
347 | - Sensei_Templates::get_template( 'globals/pagination.php' ); |
|
347 | + Sensei_Templates::get_template('globals/pagination.php'); |
|
348 | 348 | |
349 | 349 | } // End If Statement |
350 | 350 | |
@@ -370,21 +370,21 @@ discard block |
||
370 | 370 | * @param object $item |
371 | 371 | * @return object $item |
372 | 372 | */ |
373 | - public function sensei_setup_nav_menu_item( $item ) { |
|
373 | + public function sensei_setup_nav_menu_item($item) { |
|
374 | 374 | global $pagenow, $wp_rewrite; |
375 | 375 | |
376 | - if( 'nav-menus.php' != $pagenow && !defined('DOING_AJAX') && isset( $item->url ) && 'custom' == $item->type ) { |
|
376 | + if ('nav-menus.php' != $pagenow && ! defined('DOING_AJAX') && isset($item->url) && 'custom' == $item->type) { |
|
377 | 377 | |
378 | 378 | // Set up Sensei menu links |
379 | - $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
|
380 | - $my_account_page_id = intval( Sensei()->settings->settings[ 'my_course_page' ] ); |
|
379 | + $course_page_id = intval(Sensei()->settings->settings['course_page']); |
|
380 | + $my_account_page_id = intval(Sensei()->settings->settings['my_course_page']); |
|
381 | 381 | |
382 | 382 | $course_page_url = Sensei_Course::get_courses_page_url(); |
383 | - $lesson_archive_url = get_post_type_archive_link( 'lesson' ); |
|
384 | - $my_courses_url = get_permalink( $my_account_page_id ); |
|
385 | - $my_messages_url = get_post_type_archive_link( 'sensei_message' ); |
|
383 | + $lesson_archive_url = get_post_type_archive_link('lesson'); |
|
384 | + $my_courses_url = get_permalink($my_account_page_id); |
|
385 | + $my_messages_url = get_post_type_archive_link('sensei_message'); |
|
386 | 386 | |
387 | - switch ( $item->url ) { |
|
387 | + switch ($item->url) { |
|
388 | 388 | case '#senseicourses': |
389 | 389 | $item->url = $course_page_url; |
390 | 390 | break; |
@@ -401,7 +401,7 @@ discard block |
||
401 | 401 | $item->url = $my_messages_url; |
402 | 402 | // if no archive link exist for sensei_message |
403 | 403 | // set it back to the place holder |
404 | - if( ! $item->url ){ |
|
404 | + if ( ! $item->url) { |
|
405 | 405 | |
406 | 406 | $item->url = '#senseimymessages'; |
407 | 407 | |
@@ -409,21 +409,21 @@ discard block |
||
409 | 409 | break; |
410 | 410 | |
411 | 411 | case '#senseilearnerprofile': |
412 | - $item->url = esc_url( Sensei()->learner_profiles->get_permalink() ); |
|
412 | + $item->url = esc_url(Sensei()->learner_profiles->get_permalink()); |
|
413 | 413 | break; |
414 | 414 | |
415 | 415 | case '#senseiloginlogout': |
416 | - $logout_url = wp_logout_url( home_url() ); |
|
416 | + $logout_url = wp_logout_url(home_url()); |
|
417 | 417 | // Login link links to the My Courses page, to avoid the WP dashboard. |
418 | 418 | $login_url = $my_courses_url; |
419 | 419 | |
420 | - $item->url = ( is_user_logged_in() ? $logout_url : $login_url ); |
|
420 | + $item->url = (is_user_logged_in() ? $logout_url : $login_url); |
|
421 | 421 | |
422 | 422 | // determine the menu title login or logout |
423 | - if ( is_user_logged_in() ) { |
|
424 | - $menu_title = __( 'Logout' ,'woothemes-sensei'); |
|
423 | + if (is_user_logged_in()) { |
|
424 | + $menu_title = __('Logout', 'woothemes-sensei'); |
|
425 | 425 | } else { |
426 | - $menu_title = __( 'Login' ,'woothemes-sensei'); |
|
426 | + $menu_title = __('Login', 'woothemes-sensei'); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
@@ -433,7 +433,7 @@ discard block |
||
433 | 433 | * |
434 | 434 | * @param $menu_title |
435 | 435 | */ |
436 | - $item->title = apply_filters( 'sensei_login_logout_menu_title', $menu_title ); |
|
436 | + $item->title = apply_filters('sensei_login_logout_menu_title', $menu_title); |
|
437 | 437 | |
438 | 438 | break; |
439 | 439 | |
@@ -441,12 +441,12 @@ discard block |
||
441 | 441 | break; |
442 | 442 | } |
443 | 443 | |
444 | - $_root_relative_current = untrailingslashit( $_SERVER['REQUEST_URI'] ); |
|
445 | - $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_root_relative_current ); |
|
446 | - $item_url = untrailingslashit( $item->url ); |
|
447 | - $_indexless_current = untrailingslashit( preg_replace( '/' . preg_quote( $wp_rewrite->index, '/' ) . '$/', '', $current_url ) ); |
|
444 | + $_root_relative_current = untrailingslashit($_SERVER['REQUEST_URI']); |
|
445 | + $current_url = set_url_scheme('http://'.$_SERVER['HTTP_HOST'].$_root_relative_current); |
|
446 | + $item_url = untrailingslashit($item->url); |
|
447 | + $_indexless_current = untrailingslashit(preg_replace('/'.preg_quote($wp_rewrite->index, '/').'$/', '', $current_url)); |
|
448 | 448 | // Highlight current menu item |
449 | - if ( $item_url && in_array( $item_url, array( $current_url, $_indexless_current, $_root_relative_current ) ) ) { |
|
449 | + if ($item_url && in_array($item_url, array($current_url, $_indexless_current, $_root_relative_current))) { |
|
450 | 450 | $item->classes[] = 'current-menu-item current_page_item'; |
451 | 451 | } |
452 | 452 | |
@@ -465,26 +465,26 @@ discard block |
||
465 | 465 | * @param object $sorted_menu_items |
466 | 466 | * @return object $sorted_menu_items |
467 | 467 | */ |
468 | - public function sensei_wp_nav_menu_objects( $sorted_menu_items ) { |
|
468 | + public function sensei_wp_nav_menu_objects($sorted_menu_items) { |
|
469 | 469 | |
470 | - foreach( $sorted_menu_items as $k=>$item ) { |
|
470 | + foreach ($sorted_menu_items as $k=>$item) { |
|
471 | 471 | |
472 | 472 | // Remove the My Messages link for logged out users or if Private Messages are disabled |
473 | - if( ! get_post_type_archive_link( 'sensei_message' ) |
|
474 | - && '#senseimymessages' == $item->url ) { |
|
473 | + if ( ! get_post_type_archive_link('sensei_message') |
|
474 | + && '#senseimymessages' == $item->url) { |
|
475 | 475 | |
476 | - if ( !is_user_logged_in() || ( isset( Sensei()->settings->settings['messages_disable'] ) && Sensei()->settings->settings['messages_disable'] ) ) { |
|
476 | + if ( ! is_user_logged_in() || (isset(Sensei()->settings->settings['messages_disable']) && Sensei()->settings->settings['messages_disable'])) { |
|
477 | 477 | |
478 | - unset( $sorted_menu_items[$k] ); |
|
478 | + unset($sorted_menu_items[$k]); |
|
479 | 479 | |
480 | 480 | } |
481 | 481 | } |
482 | 482 | // Remove the My Profile link for logged out users. |
483 | - if( Sensei()->learner_profiles->get_permalink() == $item->url ) { |
|
483 | + if (Sensei()->learner_profiles->get_permalink() == $item->url) { |
|
484 | 484 | |
485 | - if ( !is_user_logged_in() || ! ( isset( Sensei()->settings->settings[ 'learner_profile_enable' ] ) && Sensei()->settings->settings[ 'learner_profile_enable' ] ) ) { |
|
485 | + if ( ! is_user_logged_in() || ! (isset(Sensei()->settings->settings['learner_profile_enable']) && Sensei()->settings->settings['learner_profile_enable'])) { |
|
486 | 486 | |
487 | - unset( $sorted_menu_items[$k] ); |
|
487 | + unset($sorted_menu_items[$k]); |
|
488 | 488 | |
489 | 489 | } |
490 | 490 | } |
@@ -496,7 +496,7 @@ discard block |
||
496 | 496 | function sensei_search_results_classes($classes) { |
497 | 497 | global $post; |
498 | 498 | // Handle Search Classes for Courses, Lessons, and WC Products |
499 | - if ( isset( $post->post_type ) && ( ( 'course' == $post->post_type ) || ( 'lesson' == $post->post_type ) || ( 'product' == $post->post_type ) ) ) { |
|
499 | + if (isset($post->post_type) && (('course' == $post->post_type) || ('lesson' == $post->post_type) || ('product' == $post->post_type))) { |
|
500 | 500 | $classes[] = 'post'; |
501 | 501 | } // End If Statement |
502 | 502 | return $classes; |
@@ -524,16 +524,16 @@ discard block |
||
524 | 524 | * @param bool|false $return |
525 | 525 | * @return string|void |
526 | 526 | */ |
527 | - function sensei_course_image( $course_id, $width = '100', $height = '100', $return = false ) { |
|
527 | + function sensei_course_image($course_id, $width = '100', $height = '100', $return = false) { |
|
528 | 528 | |
529 | - if ( ! $return ) { |
|
529 | + if ( ! $return) { |
|
530 | 530 | |
531 | - echo Sensei()->course->course_image( $course_id, $width, $height ); |
|
531 | + echo Sensei()->course->course_image($course_id, $width, $height); |
|
532 | 532 | return ''; |
533 | 533 | |
534 | 534 | } // End If Statement |
535 | 535 | |
536 | - return Sensei()->course->course_image( $course_id, $width, $height ); |
|
536 | + return Sensei()->course->course_image($course_id, $width, $height); |
|
537 | 537 | |
538 | 538 | } // End sensei_course_image() |
539 | 539 | |
@@ -548,15 +548,15 @@ discard block |
||
548 | 548 | * @param bool|false $widget |
549 | 549 | * @return string |
550 | 550 | */ |
551 | - function sensei_lesson_image( $lesson_id, $width = '100', $height = '100', $return = false, $widget = false ) { |
|
551 | + function sensei_lesson_image($lesson_id, $width = '100', $height = '100', $return = false, $widget = false) { |
|
552 | 552 | |
553 | - if( ! $return ){ |
|
553 | + if ( ! $return) { |
|
554 | 554 | |
555 | - echo Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget ); |
|
555 | + echo Sensei()->lesson->lesson_image($lesson_id, $width, $height, $widget); |
|
556 | 556 | return ''; |
557 | 557 | } |
558 | 558 | |
559 | - return Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget ); |
|
559 | + return Sensei()->lesson->lesson_image($lesson_id, $width, $height, $widget); |
|
560 | 560 | |
561 | 561 | } // End sensei_lesson_image() |
562 | 562 | |
@@ -564,20 +564,20 @@ discard block |
||
564 | 564 | * @since 1.0.0 |
565 | 565 | * @param WP_Query $query |
566 | 566 | */ |
567 | - function sensei_course_archive_pagination( $query ) { |
|
567 | + function sensei_course_archive_pagination($query) { |
|
568 | 568 | |
569 | - if( ! is_admin() && $query->is_main_query() && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'newcourses', 'featuredcourses', 'freecourses', 'paidcourses' ) ) ) { |
|
569 | + if ( ! is_admin() && $query->is_main_query() && isset($_GET['action']) && in_array($_GET['action'], array('newcourses', 'featuredcourses', 'freecourses', 'paidcourses'))) { |
|
570 | 570 | |
571 | 571 | $amount = 0; |
572 | - if ( isset( Sensei()->settings->settings[ 'course_archive_amount' ] ) && ( 0 < absint( Sensei()->settings->settings[ 'course_archive_amount' ] ) ) ) { |
|
573 | - $amount = absint( Sensei()->settings->settings[ 'course_archive_amount' ] ); |
|
572 | + if (isset(Sensei()->settings->settings['course_archive_amount']) && (0 < absint(Sensei()->settings->settings['course_archive_amount']))) { |
|
573 | + $amount = absint(Sensei()->settings->settings['course_archive_amount']); |
|
574 | 574 | } |
575 | 575 | |
576 | - if( $amount ) { |
|
577 | - $query->set( 'posts_per_page', $amount ); |
|
576 | + if ($amount) { |
|
577 | + $query->set('posts_per_page', $amount); |
|
578 | 578 | } |
579 | 579 | |
580 | - $query->set( 'orderby', 'menu_order date' ); |
|
580 | + $query->set('orderby', 'menu_order date'); |
|
581 | 581 | |
582 | 582 | } |
583 | 583 | } |
@@ -593,7 +593,7 @@ discard block |
||
593 | 593 | function sensei_course_archive_header( ) { |
594 | 594 | |
595 | 595 | trigger_error('This function sensei_course_archive_header has been depricated. Please use: WooThemes_Sensei_Course::course_archive_header '); |
596 | - WooThemes_Sensei_Course::archive_header( '', '<header class="archive-header"><h1>', '</h1></header>' ); |
|
596 | + WooThemes_Sensei_Course::archive_header('', '<header class="archive-header"><h1>', '</h1></header>'); |
|
597 | 597 | |
598 | 598 | } // sensei_course_archive_header() |
599 | 599 | |
@@ -606,15 +606,15 @@ discard block |
||
606 | 606 | * @return void |
607 | 607 | */ |
608 | 608 | public function sensei_lesson_archive_header( ) { |
609 | - _deprecated_function( 'WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header' ); |
|
609 | + _deprecated_function('WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header'); |
|
610 | 610 | Sensei()->lesson->the_archive_header(); |
611 | 611 | } // sensei_course_archive_header() |
612 | 612 | |
613 | 613 | /** |
614 | 614 | * @deprecated since 1.9.0 |
615 | 615 | */ |
616 | - public function sensei_message_archive_header( ){ |
|
617 | - _deprecated_function('Sensei_Frontend::sensei_message_archive_header','Please use: Sense'); |
|
616 | + public function sensei_message_archive_header( ) { |
|
617 | + _deprecated_function('Sensei_Frontend::sensei_message_archive_header', 'Please use: Sense'); |
|
618 | 618 | Sensei_Messages::the_archive_header(); |
619 | 619 | } // sensei_message_archive_header() |
620 | 620 | |
@@ -624,15 +624,15 @@ discard block |
||
624 | 624 | * @param WP_Post $post_item |
625 | 625 | * @return void |
626 | 626 | */ |
627 | - function sensei_course_archive_course_title( $post_item ) { |
|
628 | - if ( isset( $post_item->ID ) && ( 0 < $post_item->ID ) ) { |
|
629 | - $post_id = absint( $post_item->ID ); |
|
627 | + function sensei_course_archive_course_title($post_item) { |
|
628 | + if (isset($post_item->ID) && (0 < $post_item->ID)) { |
|
629 | + $post_id = absint($post_item->ID); |
|
630 | 630 | $post_title = $post_item->post_title; |
631 | 631 | } else { |
632 | 632 | $post_id = get_the_ID(); |
633 | 633 | $post_title = get_the_title(); |
634 | 634 | } // End If Statement |
635 | - ?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
635 | + ?><header><h2><a href="<?php echo get_permalink($post_id); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
636 | 636 | } // End sensei_course_archive_course_title() |
637 | 637 | |
638 | 638 | /** |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | public function sensei_lesson_archive_lesson_title() { |
644 | 644 | $post_id = get_the_ID(); |
645 | 645 | $post_title = get_the_title(); |
646 | - ?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
646 | + ?><header><h2><a href="<?php echo get_permalink($post_id); ?>" title="<?php echo esc_attr($post_title); ?>"><?php echo $post_title; ?></a></h2></header><?php |
|
647 | 647 | } // End sensei_lesson_archive_lesson_title() |
648 | 648 | |
649 | 649 | /** |
@@ -652,40 +652,40 @@ discard block |
||
652 | 652 | * @param integer $id course, lesson or quiz id |
653 | 653 | * @return void |
654 | 654 | */ |
655 | - public function sensei_breadcrumb( $id = 0 ) { |
|
655 | + public function sensei_breadcrumb($id = 0) { |
|
656 | 656 | |
657 | 657 | // Only output on lesson, quiz and taxonomy (module) pages |
658 | - if( ! ( is_tax( 'module' ) || is_singular( 'lesson' ) || is_singular( 'quiz' ) ) ) return; |
|
658 | + if ( ! (is_tax('module') || is_singular('lesson') || is_singular('quiz'))) return; |
|
659 | 659 | |
660 | - if( empty( $id ) ){ |
|
660 | + if (empty($id)) { |
|
661 | 661 | |
662 | 662 | $id = get_the_ID(); |
663 | 663 | |
664 | 664 | } |
665 | 665 | |
666 | - $sensei_breadcrumb_prefix = __( 'Back to: ', 'woothemes-sensei' ); |
|
667 | - $separator = apply_filters( 'sensei_breadcrumb_separator', '>' ); |
|
666 | + $sensei_breadcrumb_prefix = __('Back to: ', 'woothemes-sensei'); |
|
667 | + $separator = apply_filters('sensei_breadcrumb_separator', '>'); |
|
668 | 668 | |
669 | - $html = '<section class="sensei-breadcrumb">' . $sensei_breadcrumb_prefix; |
|
669 | + $html = '<section class="sensei-breadcrumb">'.$sensei_breadcrumb_prefix; |
|
670 | 670 | // Lesson |
671 | - if ( is_singular( 'lesson' ) && 0 < intval( $id ) ) { |
|
672 | - $course_id = intval( get_post_meta( $id, '_lesson_course', true ) ); |
|
673 | - if( ! $course_id ) { |
|
671 | + if (is_singular('lesson') && 0 < intval($id)) { |
|
672 | + $course_id = intval(get_post_meta($id, '_lesson_course', true)); |
|
673 | + if ( ! $course_id) { |
|
674 | 674 | return; |
675 | 675 | } |
676 | - $html .= '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Back to the course', 'woothemes-sensei' ) . '">' . get_the_title( $course_id ) . '</a>'; |
|
676 | + $html .= '<a href="'.esc_url(get_permalink($course_id)).'" title="'.__('Back to the course', 'woothemes-sensei').'">'.get_the_title($course_id).'</a>'; |
|
677 | 677 | } // End If Statement |
678 | 678 | // Quiz |
679 | - if ( is_singular( 'quiz' ) && 0 < intval( $id ) ) { |
|
680 | - $lesson_id = intval( get_post_meta( $id, '_quiz_lesson', true ) ); |
|
681 | - if( ! $lesson_id ) { |
|
679 | + if (is_singular('quiz') && 0 < intval($id)) { |
|
680 | + $lesson_id = intval(get_post_meta($id, '_quiz_lesson', true)); |
|
681 | + if ( ! $lesson_id) { |
|
682 | 682 | return; |
683 | 683 | } |
684 | - $html .= '<a href="' . esc_url( get_permalink( $lesson_id ) ) . '" title="' . __( 'Back to the lesson', 'woothemes-sensei' ) . '">' . get_the_title( $lesson_id ) . '</a>'; |
|
684 | + $html .= '<a href="'.esc_url(get_permalink($lesson_id)).'" title="'.__('Back to the lesson', 'woothemes-sensei').'">'.get_the_title($lesson_id).'</a>'; |
|
685 | 685 | } // End If Statement |
686 | 686 | |
687 | 687 | // Allow other plugins to filter html |
688 | - $html = apply_filters ( 'sensei_breadcrumb_output', $html, $separator ); |
|
688 | + $html = apply_filters('sensei_breadcrumb_output', $html, $separator); |
|
689 | 689 | $html .= '</section>'; |
690 | 690 | |
691 | 691 | echo $html; |
@@ -697,25 +697,25 @@ discard block |
||
697 | 697 | */ |
698 | 698 | public function sensei_lesson_course_signup_link( ) { |
699 | 699 | |
700 | - _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link' ); |
|
700 | + _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link'); |
|
701 | 701 | WooThemes_Sensei_Lesson::course_signup_link(); |
702 | 702 | } |
703 | 703 | |
704 | - public function lesson_tags_display( $lesson_id = 0 ) { |
|
705 | - if( $lesson_id ) { |
|
706 | - $tags = wp_get_post_terms( $lesson_id, 'lesson-tag' ); |
|
707 | - if( $tags && count( $tags ) > 0 ) { |
|
704 | + public function lesson_tags_display($lesson_id = 0) { |
|
705 | + if ($lesson_id) { |
|
706 | + $tags = wp_get_post_terms($lesson_id, 'lesson-tag'); |
|
707 | + if ($tags && count($tags) > 0) { |
|
708 | 708 | $tag_list = ''; |
709 | - foreach( $tags as $tag ) { |
|
710 | - $tag_link = get_term_link( $tag, 'lesson-tag' ); |
|
711 | - if( ! is_wp_error( $tag_link ) ) { |
|
712 | - if( $tag_list ) { $tag_list .= ', '; } |
|
713 | - $tag_list .= '<a href="' . $tag_link . '">' . $tag->name . '</a>'; |
|
709 | + foreach ($tags as $tag) { |
|
710 | + $tag_link = get_term_link($tag, 'lesson-tag'); |
|
711 | + if ( ! is_wp_error($tag_link)) { |
|
712 | + if ($tag_list) { $tag_list .= ', '; } |
|
713 | + $tag_list .= '<a href="'.$tag_link.'">'.$tag->name.'</a>'; |
|
714 | 714 | } |
715 | 715 | } |
716 | - if( $tag_list ) { |
|
716 | + if ($tag_list) { |
|
717 | 717 | ?><section class="lesson-tags"> |
718 | - <?php printf( __( 'Lesson tags: %1$s', 'woothemes-sensei' ), $tag_list ); ?> |
|
718 | + <?php printf(__('Lesson tags: %1$s', 'woothemes-sensei'), $tag_list); ?> |
|
719 | 719 | </section><?php |
720 | 720 | } |
721 | 721 | } |
@@ -725,51 +725,51 @@ discard block |
||
725 | 725 | /** |
726 | 726 | * @param WP_Query $query |
727 | 727 | */ |
728 | - public function lesson_tag_archive_filter( $query ) { |
|
729 | - if( is_tax( 'lesson-tag' ) && $query->is_main_query() ) { |
|
728 | + public function lesson_tag_archive_filter($query) { |
|
729 | + if (is_tax('lesson-tag') && $query->is_main_query()) { |
|
730 | 730 | // Limit to lessons only |
731 | - $query->set( 'post_type', 'lesson' ); |
|
731 | + $query->set('post_type', 'lesson'); |
|
732 | 732 | |
733 | 733 | // Set order of lessons |
734 | - $query->set( 'orderby', 'menu_order' ); |
|
735 | - $query->set( 'order', 'ASC' ); |
|
734 | + $query->set('orderby', 'menu_order'); |
|
735 | + $query->set('order', 'ASC'); |
|
736 | 736 | |
737 | 737 | } |
738 | 738 | } |
739 | 739 | |
740 | - public function lesson_tag_archive_header( $title ) { |
|
741 | - if( is_tax( 'lesson-tag' ) ) { |
|
742 | - $title = sprintf( __( 'Lesson tag: %1$s', 'woothemes-sensei' ), apply_filters( 'sensei_lesson_tag_archive_title', get_queried_object()->name ) ); |
|
740 | + public function lesson_tag_archive_header($title) { |
|
741 | + if (is_tax('lesson-tag')) { |
|
742 | + $title = sprintf(__('Lesson tag: %1$s', 'woothemes-sensei'), apply_filters('sensei_lesson_tag_archive_title', get_queried_object()->name)); |
|
743 | 743 | } |
744 | 744 | return $title; |
745 | 745 | } |
746 | 746 | |
747 | 747 | public function lesson_tag_archive_description() { |
748 | - if( is_tax( 'lesson-tag' ) ) { |
|
748 | + if (is_tax('lesson-tag')) { |
|
749 | 749 | $tag = get_queried_object(); |
750 | - echo '<p class="archive-description lesson-description">' . apply_filters( 'sensei_lesson_tag_archive_description', nl2br( $tag->description ), $tag->term_id ) . '</p>'; |
|
750 | + echo '<p class="archive-description lesson-description">'.apply_filters('sensei_lesson_tag_archive_description', nl2br($tag->description), $tag->term_id).'</p>'; |
|
751 | 751 | } |
752 | 752 | } |
753 | 753 | |
754 | 754 | public function sensei_complete_lesson() { |
755 | - global $post, $current_user; |
|
755 | + global $post, $current_user; |
|
756 | 756 | // Handle Quiz Completion |
757 | - if ( isset( $_POST['quiz_action'] ) && wp_verify_nonce( $_POST[ 'woothemes_sensei_complete_lesson_noonce' ], 'woothemes_sensei_complete_lesson_noonce' ) ) { |
|
757 | + if (isset($_POST['quiz_action']) && wp_verify_nonce($_POST['woothemes_sensei_complete_lesson_noonce'], 'woothemes_sensei_complete_lesson_noonce')) { |
|
758 | 758 | |
759 | - $sanitized_submit = esc_html( $_POST['quiz_action'] ); |
|
759 | + $sanitized_submit = esc_html($_POST['quiz_action']); |
|
760 | 760 | |
761 | 761 | switch ($sanitized_submit) { |
762 | 762 | case 'lesson-complete': |
763 | 763 | |
764 | - Sensei_Utils::sensei_start_lesson( $post->ID, $current_user->ID, $complete = true ); |
|
764 | + Sensei_Utils::sensei_start_lesson($post->ID, $current_user->ID, $complete = true); |
|
765 | 765 | |
766 | 766 | break; |
767 | 767 | |
768 | 768 | case 'lesson-reset': |
769 | 769 | |
770 | - Sensei_Utils::sensei_remove_user_from_lesson( $post->ID, $current_user->ID ); |
|
770 | + Sensei_Utils::sensei_remove_user_from_lesson($post->ID, $current_user->ID); |
|
771 | 771 | |
772 | - $this->messages = '<div class="sensei-message note">' . __( 'Lesson Reset Successfully.', 'woothemes-sensei' ) . '</div>'; |
|
772 | + $this->messages = '<div class="sensei-message note">'.__('Lesson Reset Successfully.', 'woothemes-sensei').'</div>'; |
|
773 | 773 | break; |
774 | 774 | |
775 | 775 | default: |
@@ -783,14 +783,14 @@ discard block |
||
783 | 783 | } // End sensei_complete_lesson() |
784 | 784 | |
785 | 785 | public function sensei_complete_course() { |
786 | - global $post, $current_user, $wp_query; |
|
787 | - if ( isset( $_POST['course_complete'] ) && wp_verify_nonce( $_POST[ 'woothemes_sensei_complete_course_noonce' ], 'woothemes_sensei_complete_course_noonce' ) ) { |
|
786 | + global $post, $current_user, $wp_query; |
|
787 | + if (isset($_POST['course_complete']) && wp_verify_nonce($_POST['woothemes_sensei_complete_course_noonce'], 'woothemes_sensei_complete_course_noonce')) { |
|
788 | 788 | |
789 | - $sanitized_submit = esc_html( $_POST['course_complete'] ); |
|
790 | - $sanitized_course_id = absint( esc_html( $_POST['course_complete_id'] ) ); |
|
789 | + $sanitized_submit = esc_html($_POST['course_complete']); |
|
790 | + $sanitized_course_id = absint(esc_html($_POST['course_complete_id'])); |
|
791 | 791 | // Handle submit data |
792 | 792 | switch ($sanitized_submit) { |
793 | - case __( 'Mark as Complete', 'woothemes-sensei' ): |
|
793 | + case __('Mark as Complete', 'woothemes-sensei'): |
|
794 | 794 | |
795 | 795 | // Add user to course |
796 | 796 | $course_metadata = array( |
@@ -798,15 +798,15 @@ discard block |
||
798 | 798 | 'percent' => 0, // No completed lessons yet |
799 | 799 | 'complete' => 0, |
800 | 800 | ); |
801 | - $activity_logged = Sensei_Utils::update_course_status( $current_user->ID, $sanitized_course_id, 'in-progress', $course_metadata ); |
|
801 | + $activity_logged = Sensei_Utils::update_course_status($current_user->ID, $sanitized_course_id, 'in-progress', $course_metadata); |
|
802 | 802 | |
803 | - if ( $activity_logged ) { |
|
803 | + if ($activity_logged) { |
|
804 | 804 | // Get all course lessons |
805 | - $course_lesson_ids = Sensei()->course->course_lessons( $sanitized_course_id, 'any', 'ids' ); |
|
805 | + $course_lesson_ids = Sensei()->course->course_lessons($sanitized_course_id, 'any', 'ids'); |
|
806 | 806 | // Mark all quiz user meta lessons as complete |
807 | - foreach ( $course_lesson_ids as $lesson_item_id ){ |
|
807 | + foreach ($course_lesson_ids as $lesson_item_id) { |
|
808 | 808 | // Mark lesson as complete |
809 | - $activity_logged = Sensei_Utils::sensei_start_lesson( $lesson_item_id, $current_user->ID, $complete = true ); |
|
809 | + $activity_logged = Sensei_Utils::sensei_start_lesson($lesson_item_id, $current_user->ID, $complete = true); |
|
810 | 810 | } // End For Loop |
811 | 811 | |
812 | 812 | // Update with final stats |
@@ -814,22 +814,22 @@ discard block |
||
814 | 814 | 'percent' => 100, |
815 | 815 | 'complete' => count($course_lesson_ids), |
816 | 816 | ); |
817 | - $activity_logged = Sensei_Utils::update_course_status( $current_user->ID, $sanitized_course_id, 'complete', $course_metadata ); |
|
817 | + $activity_logged = Sensei_Utils::update_course_status($current_user->ID, $sanitized_course_id, 'complete', $course_metadata); |
|
818 | 818 | |
819 | - do_action( 'sensei_user_course_end', $current_user->ID, $sanitized_course_id ); |
|
819 | + do_action('sensei_user_course_end', $current_user->ID, $sanitized_course_id); |
|
820 | 820 | |
821 | 821 | // Success message |
822 | - $this->messages = '<header class="archive-header"><div class="sensei-message tick">' . sprintf( __( '%1$s marked as complete.', 'woothemes-sensei' ), get_the_title( $sanitized_course_id ) ) . '</div></header>'; |
|
822 | + $this->messages = '<header class="archive-header"><div class="sensei-message tick">'.sprintf(__('%1$s marked as complete.', 'woothemes-sensei'), get_the_title($sanitized_course_id)).'</div></header>'; |
|
823 | 823 | } // End If Statement |
824 | 824 | |
825 | 825 | break; |
826 | 826 | |
827 | - case __( 'Delete Course', 'woothemes-sensei' ): |
|
827 | + case __('Delete Course', 'woothemes-sensei'): |
|
828 | 828 | |
829 | - Sensei_Utils::sensei_remove_user_from_course( $sanitized_course_id, $current_user->ID ); |
|
829 | + Sensei_Utils::sensei_remove_user_from_course($sanitized_course_id, $current_user->ID); |
|
830 | 830 | |
831 | 831 | // Success message |
832 | - $this->messages = '<header class="archive-header"><div class="sensei-message tick">' . sprintf( __( '%1$s deleted.', 'woothemes-sensei' ), get_the_title( $sanitized_course_id ) ) . '</div></header>'; |
|
832 | + $this->messages = '<header class="archive-header"><div class="sensei-message tick">'.sprintf(__('%1$s deleted.', 'woothemes-sensei'), get_the_title($sanitized_course_id)).'</div></header>'; |
|
833 | 833 | break; |
834 | 834 | |
835 | 835 | default: |
@@ -845,25 +845,25 @@ discard block |
||
845 | 845 | * @param int $lesson_id |
846 | 846 | * @return array |
847 | 847 | */ |
848 | - public function sensei_get_user_quiz_answers( $lesson_id = 0 ) { |
|
848 | + public function sensei_get_user_quiz_answers($lesson_id = 0) { |
|
849 | 849 | global $current_user; |
850 | 850 | |
851 | 851 | $user_answers = array(); |
852 | 852 | |
853 | - if ( 0 < intval( $lesson_id ) ) { |
|
854 | - $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $lesson_id ); |
|
855 | - foreach( $lesson_quiz_questions as $question ) { |
|
856 | - $answer = maybe_unserialize( base64_decode( Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content' ) ) ) ); |
|
857 | - $user_answers[ $question->ID ] = $answer; |
|
853 | + if (0 < intval($lesson_id)) { |
|
854 | + $lesson_quiz_questions = Sensei()->lesson->lesson_quiz_questions($lesson_id); |
|
855 | + foreach ($lesson_quiz_questions as $question) { |
|
856 | + $answer = maybe_unserialize(base64_decode(Sensei_Utils::sensei_get_activity_value(array('post_id' => $question->ID, 'user_id' => $current_user->ID, 'type' => 'sensei_user_answer', 'field' => 'comment_content')))); |
|
857 | + $user_answers[$question->ID] = $answer; |
|
858 | 858 | } |
859 | 859 | } |
860 | 860 | |
861 | 861 | return $user_answers; |
862 | 862 | } // End sensei_get_user_quiz_answers() |
863 | 863 | |
864 | - public function sensei_has_user_completed_lesson( $post_id = 0, $user_id = 0 ) { |
|
865 | - _deprecated_function( __FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()" ); |
|
866 | - return Sensei_Utils::user_completed_lesson( $post_id, $user_id ); |
|
864 | + public function sensei_has_user_completed_lesson($post_id = 0, $user_id = 0) { |
|
865 | + _deprecated_function(__FUNCTION__, '1.7', "WooThemes_Sensei_Utils::user_completed_lesson()"); |
|
866 | + return Sensei_Utils::user_completed_lesson($post_id, $user_id); |
|
867 | 867 | } // End sensei_has_user_completed_lesson() |
868 | 868 | |
869 | 869 | /** |
@@ -873,14 +873,14 @@ discard block |
||
873 | 873 | Sensei()->notices->print_notices(); |
874 | 874 | } // End sensei_frontend_messages() |
875 | 875 | |
876 | - public function sensei_lesson_video( $post_id = 0 ) { |
|
877 | - if ( 0 < intval( $post_id ) ) { |
|
878 | - $lesson_video_embed = get_post_meta( $post_id, '_lesson_video_embed', true ); |
|
879 | - if ( 'http' == substr( $lesson_video_embed, 0, 4) ) { |
|
876 | + public function sensei_lesson_video($post_id = 0) { |
|
877 | + if (0 < intval($post_id)) { |
|
878 | + $lesson_video_embed = get_post_meta($post_id, '_lesson_video_embed', true); |
|
879 | + if ('http' == substr($lesson_video_embed, 0, 4)) { |
|
880 | 880 | // V2 - make width and height a setting for video embed |
881 | - $lesson_video_embed = wp_oembed_get( esc_url( $lesson_video_embed )/*, array( 'width' => 100 , 'height' => 100)*/ ); |
|
881 | + $lesson_video_embed = wp_oembed_get(esc_url($lesson_video_embed)/*, array( 'width' => 100 , 'height' => 100)*/); |
|
882 | 882 | } // End If Statement |
883 | - if ( '' != $lesson_video_embed ) { |
|
883 | + if ('' != $lesson_video_embed) { |
|
884 | 884 | ?><div class="video"><?php echo html_entity_decode($lesson_video_embed); ?></div><?php |
885 | 885 | } // End If Statement |
886 | 886 | } // End If Statement |
@@ -892,19 +892,19 @@ discard block |
||
892 | 892 | $quiz_id = 0; |
893 | 893 | |
894 | 894 | // Lesson quizzes |
895 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $post->ID ); |
|
895 | + $quiz_id = Sensei()->lesson->lesson_quizzes($post->ID); |
|
896 | 896 | $pass_required = true; |
897 | - if( $quiz_id ) { |
|
897 | + if ($quiz_id) { |
|
898 | 898 | // Get quiz pass setting |
899 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); |
|
899 | + $pass_required = get_post_meta($quiz_id, '_pass_required', true); |
|
900 | 900 | } |
901 | - if( ! $quiz_id || ( $quiz_id && ! $pass_required ) ) { |
|
901 | + if ( ! $quiz_id || ($quiz_id && ! $pass_required)) { |
|
902 | 902 | ?> |
903 | - <form class="lesson_button_form" method="POST" action="<?php echo esc_url( get_permalink() ); ?>"> |
|
903 | + <form class="lesson_button_form" method="POST" action="<?php echo esc_url(get_permalink()); ?>"> |
|
904 | 904 | <input type="hidden" |
905 | 905 | name="woothemes_sensei_complete_lesson_noonce" |
906 | 906 | id="woothemes_sensei_complete_lesson_noonce" |
907 | - value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_complete_lesson_noonce' ) ); ?>" |
|
907 | + value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_lesson_noonce')); ?>" |
|
908 | 908 | /> |
909 | 909 | |
910 | 910 | <input type="hidden" name="quiz_action" value="lesson-complete" /> |
@@ -912,7 +912,7 @@ discard block |
||
912 | 912 | <input type="submit" |
913 | 913 | name="quiz_complete" |
914 | 914 | class="quiz-submit complete" |
915 | - value="<?php _e( 'Complete Lesson', 'woothemes-sensei' ); ?>"/> |
|
915 | + value="<?php _e('Complete Lesson', 'woothemes-sensei'); ?>"/> |
|
916 | 916 | |
917 | 917 | </form> |
918 | 918 | <?php |
@@ -925,25 +925,25 @@ discard block |
||
925 | 925 | $quiz_id = 0; |
926 | 926 | |
927 | 927 | // Lesson quizzes |
928 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $post->ID ); |
|
928 | + $quiz_id = Sensei()->lesson->lesson_quizzes($post->ID); |
|
929 | 929 | $reset_allowed = true; |
930 | - if( $quiz_id ) { |
|
930 | + if ($quiz_id) { |
|
931 | 931 | // Get quiz pass setting |
932 | - $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true ); |
|
932 | + $reset_allowed = get_post_meta($quiz_id, '_enable_quiz_reset', true); |
|
933 | 933 | } |
934 | - if ( ! $quiz_id || !empty($reset_allowed) ) { |
|
934 | + if ( ! $quiz_id || ! empty($reset_allowed)) { |
|
935 | 935 | ?> |
936 | - <form method="POST" action="<?php echo esc_url( get_permalink() ); ?>"> |
|
936 | + <form method="POST" action="<?php echo esc_url(get_permalink()); ?>"> |
|
937 | 937 | |
938 | 938 | <input |
939 | 939 | type="hidden" |
940 | - name="<?php echo esc_attr( 'woothemes_sensei_complete_lesson_noonce' ); ?>" |
|
941 | - id="<?php echo esc_attr( 'woothemes_sensei_complete_lesson_noonce' ); ?>" |
|
942 | - value="<?php echo esc_attr( wp_create_nonce( 'woothemes_sensei_complete_lesson_noonce' ) ); ?>" /> |
|
940 | + name="<?php echo esc_attr('woothemes_sensei_complete_lesson_noonce'); ?>" |
|
941 | + id="<?php echo esc_attr('woothemes_sensei_complete_lesson_noonce'); ?>" |
|
942 | + value="<?php echo esc_attr(wp_create_nonce('woothemes_sensei_complete_lesson_noonce')); ?>" /> |
|
943 | 943 | |
944 | 944 | <input type="hidden" name="quiz_action" value="lesson-reset" /> |
945 | 945 | |
946 | - <input type="submit" name="quiz_complete" class="quiz-submit reset" value="<?php _e( 'Reset Lesson', 'woothemes-sensei' ); ?>"/> |
|
946 | + <input type="submit" name="quiz_complete" class="quiz-submit reset" value="<?php _e('Reset Lesson', 'woothemes-sensei'); ?>"/> |
|
947 | 947 | |
948 | 948 | </form> |
949 | 949 | <?php |
@@ -966,23 +966,23 @@ discard block |
||
966 | 966 | $post_title = get_the_title(); |
967 | 967 | $author_display_name = get_the_author(); |
968 | 968 | $author_id = get_the_author_meta('ID'); |
969 | - $category_output = get_the_term_list( $post_id, 'course-category', '', ', ', '' ); |
|
970 | - $free_lesson_count = intval( Sensei()->course->course_lesson_preview_count( $post_id ) ); |
|
969 | + $category_output = get_the_term_list($post_id, 'course-category', '', ', ', ''); |
|
970 | + $free_lesson_count = intval(Sensei()->course->course_lesson_preview_count($post_id)); |
|
971 | 971 | ?><section class="entry"> |
972 | 972 | <p class="sensei-course-meta"> |
973 | - <?php if ( isset( Sensei()->settings->settings[ 'course_author' ] ) && ( Sensei()->settings->settings[ 'course_author' ] ) ) { ?> |
|
974 | - <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><?php the_author_link(); ?></span> |
|
973 | + <?php if (isset(Sensei()->settings->settings['course_author']) && (Sensei()->settings->settings['course_author'])) { ?> |
|
974 | + <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><?php the_author_link(); ?></span> |
|
975 | 975 | <?php } // End If Statement ?> |
976 | - <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count( $post_id ) . ' ' . __( 'Lessons', 'woothemes-sensei' ); ?></span> |
|
977 | - <?php if ( '' != $category_output ) { ?> |
|
978 | - <span class="course-category"><?php echo sprintf( __( 'in %s', 'woothemes-sensei' ), $category_output ); ?></span> |
|
976 | + <span class="course-lesson-count"><?php echo Sensei()->course->course_lesson_count($post_id).' '.__('Lessons', 'woothemes-sensei'); ?></span> |
|
977 | + <?php if ('' != $category_output) { ?> |
|
978 | + <span class="course-category"><?php echo sprintf(__('in %s', 'woothemes-sensei'), $category_output); ?></span> |
|
979 | 979 | <?php } // End If Statement ?> |
980 | - <?php sensei_simple_course_price( $post_id ); ?> |
|
980 | + <?php sensei_simple_course_price($post_id); ?> |
|
981 | 981 | </p> |
982 | 982 | <p class="course-excerpt"><?php the_excerpt(); ?></p> |
983 | - <?php if ( 0 < $free_lesson_count ) { |
|
984 | - $free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes-sensei' ), $free_lesson_count ); ?> |
|
985 | - <p class="sensei-free-lessons"><a href="<?php echo get_permalink( $post_id ); ?>"><?php _e( 'Preview this course', 'woothemes-sensei' ) ?></a> - <?php echo $free_lessons; ?></p> |
|
983 | + <?php if (0 < $free_lesson_count) { |
|
984 | + $free_lessons = sprintf(__('You can access %d of this course\'s lessons for free', 'woothemes-sensei'), $free_lesson_count); ?> |
|
985 | + <p class="sensei-free-lessons"><a href="<?php echo get_permalink($post_id); ?>"><?php _e('Preview this course', 'woothemes-sensei') ?></a> - <?php echo $free_lessons; ?></p> |
|
986 | 986 | <?php } ?> |
987 | 987 | </section><?php |
988 | 988 | } // End sensei_course_archive_meta() |
@@ -1005,33 +1005,33 @@ discard block |
||
1005 | 1005 | * @deprecated since 1.9.0 |
1006 | 1006 | */ |
1007 | 1007 | public function sensei_message_archive_main_content() { |
1008 | - _deprecated_function( 'Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed' ); |
|
1008 | + _deprecated_function('Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed'); |
|
1009 | 1009 | } // End sensei_lesson_archive_main_content() |
1010 | 1010 | |
1011 | 1011 | /** |
1012 | 1012 | * @deprecated since 1.9.0 |
1013 | 1013 | */ |
1014 | 1014 | public function sensei_no_permissions_main_content() { |
1015 | - _deprecated_function( 'Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed' ); |
|
1015 | + _deprecated_function('Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed'); |
|
1016 | 1016 | } // End sensei_no_permissions_main_content() |
1017 | 1017 | |
1018 | 1018 | public function sensei_course_category_main_content() { |
1019 | 1019 | global $post; |
1020 | - if ( have_posts() ) { ?> |
|
1020 | + if (have_posts()) { ?> |
|
1021 | 1021 | |
1022 | 1022 | <section id="main-course" class="course-container"> |
1023 | 1023 | |
1024 | - <?php do_action( 'sensei_course_archive_header' ); ?> |
|
1024 | + <?php do_action('sensei_course_archive_header'); ?> |
|
1025 | 1025 | |
1026 | - <?php while ( have_posts() ) { the_post(); ?> |
|
1026 | + <?php while (have_posts()) { the_post(); ?> |
|
1027 | 1027 | |
1028 | - <article class="<?php echo join( ' ', get_post_class( array( 'course', 'post' ), get_the_ID() ) ); ?>"> |
|
1028 | + <article class="<?php echo join(' ', get_post_class(array('course', 'post'), get_the_ID())); ?>"> |
|
1029 | 1029 | |
1030 | - <?php sensei_do_deprecated_action('sensei_course_image','1.9.0', 'sensei_single_course_content_inside_before', get_the_ID() ); ?> |
|
1030 | + <?php sensei_do_deprecated_action('sensei_course_image', '1.9.0', 'sensei_single_course_content_inside_before', get_the_ID()); ?> |
|
1031 | 1031 | |
1032 | - <?php sensei_do_deprecated_action( 'sensei_course_archive_course_title','1.9.0','sensei_course_content_inside_before', $post ); ?> |
|
1032 | + <?php sensei_do_deprecated_action('sensei_course_archive_course_title', '1.9.0', 'sensei_course_content_inside_before', $post); ?> |
|
1033 | 1033 | |
1034 | - <?php do_action( 'sensei_course_archive_meta' ); ?> |
|
1034 | + <?php do_action('sensei_course_archive_meta'); ?> |
|
1035 | 1035 | |
1036 | 1036 | </article> |
1037 | 1037 | |
@@ -1043,7 +1043,7 @@ discard block |
||
1043 | 1043 | |
1044 | 1044 | <p> |
1045 | 1045 | |
1046 | - <?php _e( 'No courses found that match your selection.', 'woothemes-sensei' ); ?> |
|
1046 | + <?php _e('No courses found that match your selection.', 'woothemes-sensei'); ?> |
|
1047 | 1047 | |
1048 | 1048 | </p> |
1049 | 1049 | |
@@ -1060,12 +1060,12 @@ discard block |
||
1060 | 1060 | <div class="col-1"> |
1061 | 1061 | <?php |
1062 | 1062 | // output the actual form markup |
1063 | - Sensei_Templates::get_template( 'user/login-form.php'); |
|
1063 | + Sensei_Templates::get_template('user/login-form.php'); |
|
1064 | 1064 | ?> |
1065 | 1065 | </div> |
1066 | 1066 | |
1067 | 1067 | <?php |
1068 | - if ( get_option('users_can_register') ) { |
|
1068 | + if (get_option('users_can_register')) { |
|
1069 | 1069 | |
1070 | 1070 | // get current url |
1071 | 1071 | $action_url = get_permalink(); |
@@ -1073,38 +1073,38 @@ discard block |
||
1073 | 1073 | ?> |
1074 | 1074 | |
1075 | 1075 | <div class="col-2"> |
1076 | - <h2><?php _e( 'Register', 'woothemes-sensei' ); ?></h2> |
|
1076 | + <h2><?php _e('Register', 'woothemes-sensei'); ?></h2> |
|
1077 | 1077 | |
1078 | - <form method="post" class="register" action="<?php echo esc_url( $action_url ); ?>" > |
|
1078 | + <form method="post" class="register" action="<?php echo esc_url($action_url); ?>" > |
|
1079 | 1079 | |
1080 | - <?php do_action( 'sensei_register_form_start' ); ?> |
|
1080 | + <?php do_action('sensei_register_form_start'); ?> |
|
1081 | 1081 | |
1082 | 1082 | <p class="form-row form-row-wide"> |
1083 | - <label for="sensei_reg_username"><?php _e( 'Username', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
|
1084 | - <input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty( $_POST['sensei_reg_username'] ) ) esc_attr_e( $_POST['sensei_reg_username'] ); ?>" /> |
|
1083 | + <label for="sensei_reg_username"><?php _e('Username', 'woothemes-sensei'); ?> <span class="required">*</span></label> |
|
1084 | + <input type="text" class="input-text" name="sensei_reg_username" id="sensei_reg_username" value="<?php if ( ! empty($_POST['sensei_reg_username'])) esc_attr_e($_POST['sensei_reg_username']); ?>" /> |
|
1085 | 1085 | </p> |
1086 | 1086 | |
1087 | 1087 | <p class="form-row form-row-wide"> |
1088 | - <label for="sensei_reg_email"><?php _e( 'Email address', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
|
1089 | - <input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty( $_POST['sensei_reg_email'] ) ) esc_attr_e( $_POST['sensei_reg_email'] ); ?>" /> |
|
1088 | + <label for="sensei_reg_email"><?php _e('Email address', 'woothemes-sensei'); ?> <span class="required">*</span></label> |
|
1089 | + <input type="email" class="input-text" name="sensei_reg_email" id="sensei_reg_email" value="<?php if ( ! empty($_POST['sensei_reg_email'])) esc_attr_e($_POST['sensei_reg_email']); ?>" /> |
|
1090 | 1090 | </p> |
1091 | 1091 | |
1092 | 1092 | <p class="form-row form-row-wide"> |
1093 | - <label for="sensei_reg_password"><?php _e( 'Password', 'woothemes-sensei' ); ?> <span class="required">*</span></label> |
|
1094 | - <input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty( $_POST['sensei_reg_password'] ) ) esc_attr_e( $_POST['sensei_reg_password'] ); ?>" /> |
|
1093 | + <label for="sensei_reg_password"><?php _e('Password', 'woothemes-sensei'); ?> <span class="required">*</span></label> |
|
1094 | + <input type="password" class="input-text" name="sensei_reg_password" id="sensei_reg_password" value="<?php if ( ! empty($_POST['sensei_reg_password'])) esc_attr_e($_POST['sensei_reg_password']); ?>" /> |
|
1095 | 1095 | </p> |
1096 | 1096 | |
1097 | 1097 | <!-- Spam Trap --> |
1098 | - <div style="left:-999em; position:absolute;"><label for="trap"><?php _e( 'Anti-spam', 'woothemes-sensei' ); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div> |
|
1098 | + <div style="left:-999em; position:absolute;"><label for="trap"><?php _e('Anti-spam', 'woothemes-sensei'); ?></label><input type="text" name="email_2" id="trap" tabindex="-1" /></div> |
|
1099 | 1099 | |
1100 | - <?php do_action( 'sensei_register_form_fields' ); ?> |
|
1101 | - <?php do_action( 'register_form' ); ?> |
|
1100 | + <?php do_action('sensei_register_form_fields'); ?> |
|
1101 | + <?php do_action('register_form'); ?> |
|
1102 | 1102 | |
1103 | 1103 | <p class="form-row"> |
1104 | - <input type="submit" class="button" name="register" value="<?php _e( 'Register', 'woothemes-sensei' ); ?>" /> |
|
1104 | + <input type="submit" class="button" name="register" value="<?php _e('Register', 'woothemes-sensei'); ?>" /> |
|
1105 | 1105 | </p> |
1106 | 1106 | |
1107 | - <?php do_action( 'sensei_register_form_end' ); ?> |
|
1107 | + <?php do_action('sensei_register_form_end'); ?> |
|
1108 | 1108 | |
1109 | 1109 | </form> |
1110 | 1110 | </div> |
@@ -1117,17 +1117,17 @@ discard block |
||
1117 | 1117 | <?php |
1118 | 1118 | } // End sensei_login_form() |
1119 | 1119 | |
1120 | - public function sensei_lesson_meta( $post_id = 0 ) { |
|
1120 | + public function sensei_lesson_meta($post_id = 0) { |
|
1121 | 1121 | global $post; |
1122 | - if ( 0 < intval( $post_id ) ) { |
|
1123 | - $lesson_course_id = absint( get_post_meta( $post_id, '_lesson_course', true ) ); |
|
1122 | + if (0 < intval($post_id)) { |
|
1123 | + $lesson_course_id = absint(get_post_meta($post_id, '_lesson_course', true)); |
|
1124 | 1124 | ?><section class="entry"> |
1125 | 1125 | <p class="sensei-course-meta"> |
1126 | - <?php if ( isset( Sensei()->settings->settings[ 'lesson_author' ] ) && ( Sensei()->settings->settings[ 'lesson_author' ] ) ) { ?> |
|
1127 | - <span class="course-author"><?php _e( 'by ', 'woothemes-sensei' ); ?><?php the_author_link(); ?></span> |
|
1126 | + <?php if (isset(Sensei()->settings->settings['lesson_author']) && (Sensei()->settings->settings['lesson_author'])) { ?> |
|
1127 | + <span class="course-author"><?php _e('by ', 'woothemes-sensei'); ?><?php the_author_link(); ?></span> |
|
1128 | 1128 | <?php } ?> |
1129 | - <?php if ( 0 < intval( $lesson_course_id ) ) { ?> |
|
1130 | - <span class="lesson-course"><?php echo ' ' . sprintf( __( 'Part of: %s', 'woothemes-sensei' ), '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '" title="' . __( 'View course', 'woothemes-sensei' ) . '"><em>' . get_the_title( $lesson_course_id ) . '</em></a>' ); ?></span> |
|
1129 | + <?php if (0 < intval($lesson_course_id)) { ?> |
|
1130 | + <span class="lesson-course"><?php echo ' '.sprintf(__('Part of: %s', 'woothemes-sensei'), '<a href="'.esc_url(get_permalink($lesson_course_id)).'" title="'.__('View course', 'woothemes-sensei').'"><em>'.get_the_title($lesson_course_id).'</em></a>'); ?></span> |
|
1131 | 1131 | <?php } ?> |
1132 | 1132 | </p> |
1133 | 1133 | <p class="lesson-excerpt"><?php the_excerpt( ); ?></p> |
@@ -1135,36 +1135,36 @@ discard block |
||
1135 | 1135 | } // End If Statement |
1136 | 1136 | } // sensei_lesson_meta() |
1137 | 1137 | |
1138 | - public function sensei_lesson_preview_title_text( $course_id ) { |
|
1138 | + public function sensei_lesson_preview_title_text($course_id) { |
|
1139 | 1139 | |
1140 | - $preview_text = __( ' (Preview)', 'woothemes-sensei' ); |
|
1140 | + $preview_text = __(' (Preview)', 'woothemes-sensei'); |
|
1141 | 1141 | |
1142 | 1142 | //if this is a paid course |
1143 | - if ( Sensei_WC::is_woocommerce_active() ) { |
|
1144 | - $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
1145 | - if ( 0 < $wc_post_id ) { |
|
1146 | - $preview_text = __( ' (Free Preview)', 'woothemes-sensei' ); |
|
1143 | + if (Sensei_WC::is_woocommerce_active()) { |
|
1144 | + $wc_post_id = get_post_meta($course_id, '_course_woocommerce_product', true); |
|
1145 | + if (0 < $wc_post_id) { |
|
1146 | + $preview_text = __(' (Free Preview)', 'woothemes-sensei'); |
|
1147 | 1147 | } // End If Statement |
1148 | 1148 | } |
1149 | 1149 | return $preview_text; |
1150 | 1150 | } |
1151 | 1151 | |
1152 | - public function sensei_lesson_preview_title( $title = '', $id = 0 ) { |
|
1152 | + public function sensei_lesson_preview_title($title = '', $id = 0) { |
|
1153 | 1153 | global $post, $current_user; |
1154 | 1154 | |
1155 | 1155 | // Limit to lessons and check if lesson ID matches filtered post ID |
1156 | 1156 | // @see https://github.com/woothemes/sensei/issues/574 |
1157 | - if( isset( $post->ID ) && $id == $post->ID && 'lesson' == get_post_type( $post ) ) { |
|
1157 | + if (isset($post->ID) && $id == $post->ID && 'lesson' == get_post_type($post)) { |
|
1158 | 1158 | |
1159 | 1159 | // Limit to main query only |
1160 | - if( is_main_query() ) { |
|
1160 | + if (is_main_query()) { |
|
1161 | 1161 | |
1162 | 1162 | // Get the course ID |
1163 | - $course_id = get_post_meta( $post->ID, '_lesson_course', true ); |
|
1163 | + $course_id = get_post_meta($post->ID, '_lesson_course', true); |
|
1164 | 1164 | |
1165 | 1165 | // Check if the user is taking the course |
1166 | - if( is_singular( 'lesson' ) && Sensei_Utils::is_preview_lesson( $post->ID ) && ! Sensei_Utils::user_started_course( $course_id, $current_user->ID ) && $post->ID == $id ) { |
|
1167 | - $title .= ' ' . $this->sensei_lesson_preview_title_text( $course_id ); |
|
1166 | + if (is_singular('lesson') && Sensei_Utils::is_preview_lesson($post->ID) && ! Sensei_Utils::user_started_course($course_id, $current_user->ID) && $post->ID == $id) { |
|
1167 | + $title .= ' '.$this->sensei_lesson_preview_title_text($course_id); |
|
1168 | 1168 | } |
1169 | 1169 | } |
1170 | 1170 | } |
@@ -1175,23 +1175,23 @@ discard block |
||
1175 | 1175 | global $post, $current_user; |
1176 | 1176 | |
1177 | 1177 | // Check if the user is taking the course |
1178 | - $is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID ); |
|
1178 | + $is_user_taking_course = Sensei_Utils::user_started_course($post->ID, $current_user->ID); |
|
1179 | 1179 | // Handle user starting the course |
1180 | - if ( isset( $_POST['course_start'] ) |
|
1181 | - && wp_verify_nonce( $_POST[ 'woothemes_sensei_start_course_noonce' ], 'woothemes_sensei_start_course_noonce' ) |
|
1182 | - && !$is_user_taking_course ) { |
|
1180 | + if (isset($_POST['course_start']) |
|
1181 | + && wp_verify_nonce($_POST['woothemes_sensei_start_course_noonce'], 'woothemes_sensei_start_course_noonce') |
|
1182 | + && ! $is_user_taking_course) { |
|
1183 | 1183 | |
1184 | 1184 | // Start the course |
1185 | - $activity_logged = Sensei_Utils::user_start_course( $current_user->ID, $post->ID ); |
|
1185 | + $activity_logged = Sensei_Utils::user_start_course($current_user->ID, $post->ID); |
|
1186 | 1186 | $this->data = new stdClass(); |
1187 | 1187 | $this->data->is_user_taking_course = false; |
1188 | - if ( $activity_logged ) { |
|
1188 | + if ($activity_logged) { |
|
1189 | 1189 | $this->data->is_user_taking_course = true; |
1190 | 1190 | |
1191 | 1191 | // Refresh page to avoid re-posting |
1192 | 1192 | ?> |
1193 | 1193 | |
1194 | - <script type="text/javascript"> window.location = '<?php echo get_permalink( $post->ID ); ?>'; </script> |
|
1194 | + <script type="text/javascript"> window.location = '<?php echo get_permalink($post->ID); ?>'; </script> |
|
1195 | 1195 | |
1196 | 1196 | <?php |
1197 | 1197 | } // End If Statement |
@@ -1202,15 +1202,15 @@ discard block |
||
1202 | 1202 | * @deprecated since 1.9.0 |
1203 | 1203 | */ |
1204 | 1204 | public function sensei_course_meta() { |
1205 | - _deprecated_function( 'Sensei_Frontend::sensei_course_meta', '1.9.0' , 'Sensei_Course::the_course_meta()' ); |
|
1206 | - Sensei()->course->the_course_meta( get_post() ); |
|
1205 | + _deprecated_function('Sensei_Frontend::sensei_course_meta', '1.9.0', 'Sensei_Course::the_course_meta()'); |
|
1206 | + Sensei()->course->the_course_meta(get_post()); |
|
1207 | 1207 | } // End sensei_course_meta() |
1208 | 1208 | |
1209 | 1209 | /** |
1210 | 1210 | * @deprecated since 1.9.0 |
1211 | 1211 | */ |
1212 | 1212 | public function sensei_course_meta_video() { |
1213 | - _deprecated_function( 'Sensei_Frontend::sensei_course_meta_video', '1.9.0' , 'Sensei_Course::the_course_video()' ); |
|
1213 | + _deprecated_function('Sensei_Frontend::sensei_course_meta_video', '1.9.0', 'Sensei_Course::the_course_video()'); |
|
1214 | 1214 | Sensei_Course::the_course_video(); |
1215 | 1215 | } // End sensei_course_meta_video() |
1216 | 1216 | |
@@ -1225,12 +1225,12 @@ discard block |
||
1225 | 1225 | public function sensei_woocommerce_in_cart_message() { |
1226 | 1226 | global $post, $woocommerce; |
1227 | 1227 | |
1228 | - $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
|
1229 | - $user_course_status_id = Sensei_Utils::user_started_course($post->ID , get_current_user_id() ); |
|
1230 | - if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) { |
|
1228 | + $wc_post_id = absint(get_post_meta($post->ID, '_course_woocommerce_product', true)); |
|
1229 | + $user_course_status_id = Sensei_Utils::user_started_course($post->ID, get_current_user_id()); |
|
1230 | + if (0 < intval($wc_post_id) && ! $user_course_status_id) { |
|
1231 | 1231 | |
1232 | - if ( Sensei_WC::is_product_in_cart( $wc_post_id ) ) { |
|
1233 | - echo '<div class="sensei-message info">' . sprintf( __('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei') . '</div>', '<a class="cart-complete" href="' . $woocommerce->cart->get_checkout_url() . '" title="' . __('complete the purchase', 'woothemes-sensei') . '">' . __('complete the purchase', 'woothemes-sensei') . '</a>' ); |
|
1232 | + if (Sensei_WC::is_product_in_cart($wc_post_id)) { |
|
1233 | + echo '<div class="sensei-message info">'.sprintf(__('You have already added this Course to your cart. Please %1$s to access the course.', 'woothemes-sensei').'</div>', '<a class="cart-complete" href="'.$woocommerce->cart->get_checkout_url().'" title="'.__('complete the purchase', 'woothemes-sensei').'">'.__('complete the purchase', 'woothemes-sensei').'</a>'); |
|
1234 | 1234 | } // End If Statement |
1235 | 1235 | |
1236 | 1236 | } // End If Statement |
@@ -1238,7 +1238,7 @@ discard block |
||
1238 | 1238 | } // End sensei_woocommerce_in_cart_message() |
1239 | 1239 | |
1240 | 1240 | // Deprecated |
1241 | - public function sensei_lesson_comment_count( $count ) { |
|
1241 | + public function sensei_lesson_comment_count($count) { |
|
1242 | 1242 | return $count; |
1243 | 1243 | } // End sensei_lesson_comment_count() |
1244 | 1244 | |
@@ -1247,11 +1247,11 @@ discard block |
||
1247 | 1247 | * @param string $content Original content |
1248 | 1248 | * @return string Modified content |
1249 | 1249 | */ |
1250 | - public function sensei_search_results_excerpt( $content ) { |
|
1250 | + public function sensei_search_results_excerpt($content) { |
|
1251 | 1251 | global $post; |
1252 | 1252 | |
1253 | - if( is_search() && in_array( $post->post_type, array( 'course', 'lesson' ) ) ) { |
|
1254 | - $content = '<p class="course-excerpt">' . the_excerpt( ) . '</p>'; |
|
1253 | + if (is_search() && in_array($post->post_type, array('course', 'lesson'))) { |
|
1254 | + $content = '<p class="course-excerpt">'.the_excerpt( ).'</p>'; |
|
1255 | 1255 | } |
1256 | 1256 | |
1257 | 1257 | return $content; |
@@ -1262,11 +1262,11 @@ discard block |
||
1262 | 1262 | * @param integer $order_id ID of order |
1263 | 1263 | * @return void |
1264 | 1264 | */ |
1265 | - public function remove_active_course( $order_id ) { |
|
1266 | - $order = new WC_Order( $order_id ); |
|
1265 | + public function remove_active_course($order_id) { |
|
1266 | + $order = new WC_Order($order_id); |
|
1267 | 1267 | |
1268 | - foreach ( $order->get_items() as $item ) { |
|
1269 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
1268 | + foreach ($order->get_items() as $item) { |
|
1269 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
1270 | 1270 | // If item has variation_id then its a variation of the product |
1271 | 1271 | $item_id = $item['variation_id']; |
1272 | 1272 | } else { |
@@ -1274,11 +1274,11 @@ discard block |
||
1274 | 1274 | $item_id = $item['product_id']; |
1275 | 1275 | } |
1276 | 1276 | |
1277 | - if ( $item_id > 0 ) { |
|
1277 | + if ($item_id > 0) { |
|
1278 | 1278 | |
1279 | - $user_id = get_post_meta( $order_id, '_customer_user', true ); |
|
1279 | + $user_id = get_post_meta($order_id, '_customer_user', true); |
|
1280 | 1280 | |
1281 | - if( $user_id ) { |
|
1281 | + if ($user_id) { |
|
1282 | 1282 | |
1283 | 1283 | // Get all courses for product |
1284 | 1284 | $args = array( |
@@ -1294,13 +1294,13 @@ discard block |
||
1294 | 1294 | 'order' => 'ASC', |
1295 | 1295 | 'fields' => 'ids', |
1296 | 1296 | ); |
1297 | - $course_ids = get_posts( $args ); |
|
1297 | + $course_ids = get_posts($args); |
|
1298 | 1298 | |
1299 | - if( $course_ids && count( $course_ids ) > 0 ) { |
|
1300 | - foreach( $course_ids as $course_id ) { |
|
1299 | + if ($course_ids && count($course_ids) > 0) { |
|
1300 | + foreach ($course_ids as $course_id) { |
|
1301 | 1301 | |
1302 | 1302 | // Remove all course user meta |
1303 | - Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id ); |
|
1303 | + Sensei_Utils::sensei_remove_user_from_course($course_id, $user_id); |
|
1304 | 1304 | |
1305 | 1305 | } // End For Loop |
1306 | 1306 | } // End If Statement |
@@ -1316,16 +1316,16 @@ discard block |
||
1316 | 1316 | * @param integer $user_id User ID |
1317 | 1317 | * @return void |
1318 | 1318 | */ |
1319 | - public function activate_purchased_courses( $user_id = 0 ) { |
|
1319 | + public function activate_purchased_courses($user_id = 0) { |
|
1320 | 1320 | |
1321 | - if( $user_id ) { |
|
1321 | + if ($user_id) { |
|
1322 | 1322 | |
1323 | - if( Sensei_WC::is_woocommerce_active() ) { |
|
1323 | + if (Sensei_WC::is_woocommerce_active()) { |
|
1324 | 1324 | |
1325 | 1325 | // Get all user's orders |
1326 | 1326 | $order_args = array( |
1327 | 1327 | 'post_type' => 'shop_order', |
1328 | - 'post_status' => array( 'wc-processing', 'wc-completed' ), |
|
1328 | + 'post_status' => array('wc-processing', 'wc-completed'), |
|
1329 | 1329 | 'posts_per_page' => -1, |
1330 | 1330 | 'meta_query' => array( |
1331 | 1331 | array( |
@@ -1335,25 +1335,25 @@ discard block |
||
1335 | 1335 | ), |
1336 | 1336 | ); |
1337 | 1337 | |
1338 | - $orders = get_posts( $order_args ); |
|
1338 | + $orders = get_posts($order_args); |
|
1339 | 1339 | |
1340 | 1340 | $product_ids = array(); |
1341 | 1341 | $order_ids = array(); |
1342 | 1342 | |
1343 | - foreach( $orders as $post_id ) { |
|
1343 | + foreach ($orders as $post_id) { |
|
1344 | 1344 | |
1345 | 1345 | // Only process each order once |
1346 | - $processed = get_post_meta( $post_id, 'sensei_products_processed', true ); |
|
1346 | + $processed = get_post_meta($post_id, 'sensei_products_processed', true); |
|
1347 | 1347 | |
1348 | - if( $processed && $processed == 'processed' ) { |
|
1348 | + if ($processed && $processed == 'processed') { |
|
1349 | 1349 | continue; |
1350 | 1350 | } |
1351 | 1351 | |
1352 | 1352 | // Get course product IDs from order |
1353 | - $order = new WC_Order( $post_id ); |
|
1353 | + $order = new WC_Order($post_id); |
|
1354 | 1354 | |
1355 | 1355 | $items = $order->get_items(); |
1356 | - foreach( $items as $item ) { |
|
1356 | + foreach ($items as $item) { |
|
1357 | 1357 | if (isset($item['variation_id']) && $item['variation_id'] > 0) { |
1358 | 1358 | $item_id = $item['variation_id']; |
1359 | 1359 | $product_type = 'variation'; |
@@ -1367,7 +1367,7 @@ discard block |
||
1367 | 1367 | $order_ids[] = $post_id; |
1368 | 1368 | } |
1369 | 1369 | |
1370 | - if( count( $product_ids ) > 0 ) { |
|
1370 | + if (count($product_ids) > 0) { |
|
1371 | 1371 | |
1372 | 1372 | // Get all courses from user's orders |
1373 | 1373 | $course_args = array( |
@@ -1384,31 +1384,31 @@ discard block |
||
1384 | 1384 | 'order' => 'ASC', |
1385 | 1385 | 'fields' => 'ids', |
1386 | 1386 | ); |
1387 | - $course_ids = get_posts( $course_args ); |
|
1387 | + $course_ids = get_posts($course_args); |
|
1388 | 1388 | |
1389 | - foreach( $course_ids as $course_id ) { |
|
1389 | + foreach ($course_ids as $course_id) { |
|
1390 | 1390 | |
1391 | - $user_course_status = Sensei_Utils::user_course_status( intval($course_id), $user_id ); |
|
1391 | + $user_course_status = Sensei_Utils::user_course_status(intval($course_id), $user_id); |
|
1392 | 1392 | |
1393 | 1393 | // Ignore course if already completed |
1394 | - if( Sensei_Utils::user_completed_course( $user_course_status ) ) { |
|
1394 | + if (Sensei_Utils::user_completed_course($user_course_status)) { |
|
1395 | 1395 | continue; |
1396 | 1396 | } |
1397 | 1397 | |
1398 | 1398 | // Ignore course if already started |
1399 | - if( $user_course_status ) { |
|
1399 | + if ($user_course_status) { |
|
1400 | 1400 | continue; |
1401 | 1401 | } |
1402 | 1402 | |
1403 | 1403 | // Mark course as started by user |
1404 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
1404 | + Sensei_Utils::user_start_course($user_id, $course_id); |
|
1405 | 1405 | } |
1406 | 1406 | } |
1407 | 1407 | |
1408 | - if( count( $order_ids ) > 0 ) { |
|
1409 | - foreach( $order_ids as $order_id ) { |
|
1408 | + if (count($order_ids) > 0) { |
|
1409 | + foreach ($order_ids as $order_id) { |
|
1410 | 1410 | // Mark order as processed |
1411 | - update_post_meta( $order_id, 'sensei_products_processed', 'processed' ); |
|
1411 | + update_post_meta($order_id, 'sensei_products_processed', 'processed'); |
|
1412 | 1412 | } |
1413 | 1413 | } |
1414 | 1414 | } |
@@ -1422,28 +1422,28 @@ discard block |
||
1422 | 1422 | public function activate_purchased_single_course() { |
1423 | 1423 | global $post, $current_user; |
1424 | 1424 | |
1425 | - if( Sensei_WC::is_woocommerce_active() ) { |
|
1425 | + if (Sensei_WC::is_woocommerce_active()) { |
|
1426 | 1426 | |
1427 | - if( ! is_user_logged_in() ) return; |
|
1428 | - if( ! isset( $post->ID ) ) return; |
|
1427 | + if ( ! is_user_logged_in()) return; |
|
1428 | + if ( ! isset($post->ID)) return; |
|
1429 | 1429 | |
1430 | 1430 | $user_id = $current_user->ID; |
1431 | 1431 | $course_id = $post->ID; |
1432 | - $course_product_id = (int) get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
1433 | - if( ! $course_product_id ) { |
|
1432 | + $course_product_id = (int) get_post_meta($course_id, '_course_woocommerce_product', true); |
|
1433 | + if ( ! $course_product_id) { |
|
1434 | 1434 | return; |
1435 | 1435 | } |
1436 | 1436 | |
1437 | - $user_course_status = Sensei_Utils::user_course_status( intval($course_id), $user_id ); |
|
1437 | + $user_course_status = Sensei_Utils::user_course_status(intval($course_id), $user_id); |
|
1438 | 1438 | |
1439 | 1439 | // Ignore course if already completed |
1440 | - if( Sensei_Utils::user_completed_course( $user_course_status ) ) { |
|
1440 | + if (Sensei_Utils::user_completed_course($user_course_status)) { |
|
1441 | 1441 | |
1442 | 1442 | return; |
1443 | 1443 | } |
1444 | 1444 | |
1445 | 1445 | // Ignore course if already started |
1446 | - if( $user_course_status ) { |
|
1446 | + if ($user_course_status) { |
|
1447 | 1447 | return; |
1448 | 1448 | } |
1449 | 1449 | |
@@ -1451,7 +1451,7 @@ discard block |
||
1451 | 1451 | $order_args = array( |
1452 | 1452 | 'post_type' => 'shop_order', |
1453 | 1453 | 'posts_per_page' => -1, |
1454 | - 'post_status' => array( 'wc-processing', 'wc-completed' ), |
|
1454 | + 'post_status' => array('wc-processing', 'wc-completed'), |
|
1455 | 1455 | 'meta_query' => array( |
1456 | 1456 | array( |
1457 | 1457 | 'key' => '_customer_user', |
@@ -1460,27 +1460,27 @@ discard block |
||
1460 | 1460 | ), |
1461 | 1461 | 'fields' => 'ids', |
1462 | 1462 | ); |
1463 | - $orders = get_posts( $order_args ); |
|
1463 | + $orders = get_posts($order_args); |
|
1464 | 1464 | |
1465 | - foreach( $orders as $order_post_id ) { |
|
1465 | + foreach ($orders as $order_post_id) { |
|
1466 | 1466 | |
1467 | 1467 | // Get course product IDs from order |
1468 | - $order = new WC_Order( $order_post_id ); |
|
1468 | + $order = new WC_Order($order_post_id); |
|
1469 | 1469 | |
1470 | 1470 | $items = $order->get_items(); |
1471 | - foreach( $items as $item ) { |
|
1472 | - $product = wc_get_product( $item['product_id'] ); |
|
1471 | + foreach ($items as $item) { |
|
1472 | + $product = wc_get_product($item['product_id']); |
|
1473 | 1473 | |
1474 | 1474 | // handle product bundles |
1475 | - if( $product->is_type('bundle') ){ |
|
1475 | + if ($product->is_type('bundle')) { |
|
1476 | 1476 | |
1477 | - $bundled_product = new WC_Product_Bundle( $product->id ); |
|
1477 | + $bundled_product = new WC_Product_Bundle($product->id); |
|
1478 | 1478 | $bundled_items = $bundled_product->get_bundled_items(); |
1479 | 1479 | |
1480 | - foreach( $bundled_items as $bundled_item ){ |
|
1480 | + foreach ($bundled_items as $bundled_item) { |
|
1481 | 1481 | |
1482 | - if( $bundled_item->product_id == $course_product_id ) { |
|
1483 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
1482 | + if ($bundled_item->product_id == $course_product_id) { |
|
1483 | + Sensei_Utils::user_start_course($user_id, $course_id); |
|
1484 | 1484 | return; |
1485 | 1485 | } |
1486 | 1486 | |
@@ -1489,8 +1489,8 @@ discard block |
||
1489 | 1489 | } else { |
1490 | 1490 | |
1491 | 1491 | // handle regular products |
1492 | - if( $item['product_id'] == $course_product_id ) { |
|
1493 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
1492 | + if ($item['product_id'] == $course_product_id) { |
|
1493 | + Sensei_Utils::user_start_course($user_id, $course_id); |
|
1494 | 1494 | return; |
1495 | 1495 | } |
1496 | 1496 | |
@@ -1506,9 +1506,9 @@ discard block |
||
1506 | 1506 | * @param array $args Default arguments |
1507 | 1507 | * @return array Modified arguments |
1508 | 1508 | */ |
1509 | - public function hide_sensei_activity( $args = array() ) { |
|
1509 | + public function hide_sensei_activity($args = array()) { |
|
1510 | 1510 | |
1511 | - if( is_singular( 'lesson' ) || is_singular( 'course' ) ) { |
|
1511 | + if (is_singular('lesson') || is_singular('course')) { |
|
1512 | 1512 | $args['type'] = 'comment'; |
1513 | 1513 | } |
1514 | 1514 | |
@@ -1525,9 +1525,9 @@ discard block |
||
1525 | 1525 | |
1526 | 1526 | //if not posted from the sensei login form let |
1527 | 1527 | // WordPress or any other party handle the failed request |
1528 | - if( ! isset( $_REQUEST['form'] ) || 'sensei-login' != $_REQUEST['form'] ){ |
|
1528 | + if ( ! isset($_REQUEST['form']) || 'sensei-login' != $_REQUEST['form']) { |
|
1529 | 1529 | |
1530 | - return ; |
|
1530 | + return; |
|
1531 | 1531 | |
1532 | 1532 | } |
1533 | 1533 | |
@@ -1535,9 +1535,9 @@ discard block |
||
1535 | 1535 | $referrer = add_query_arg('login', false, $_SERVER['HTTP_REFERER']); |
1536 | 1536 | |
1537 | 1537 | // if there's a valid referrer, and it's not the default log-in screen |
1538 | - if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){ |
|
1538 | + if ( ! empty($referrer) && ! strstr($referrer, 'wp-login') && ! strstr($referrer, 'wp-admin')) { |
|
1539 | 1539 | // let's append some information (login=failed) to the URL for the theme to use |
1540 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1540 | + wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer))); |
|
1541 | 1541 | exit; |
1542 | 1542 | } |
1543 | 1543 | }// End sensei_login_fail_redirect_to_front_end_login |
@@ -1551,10 +1551,10 @@ discard block |
||
1551 | 1551 | |
1552 | 1552 | |
1553 | 1553 | // Check that it is a sensei login request and if it has a valid nonce |
1554 | - if( isset( $_REQUEST['form'] ) && 'sensei-login' == $_REQUEST['form'] ) { |
|
1554 | + if (isset($_REQUEST['form']) && 'sensei-login' == $_REQUEST['form']) { |
|
1555 | 1555 | |
1556 | 1556 | // Validate the login request nonce |
1557 | - if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){ |
|
1557 | + if ( ! wp_verify_nonce($_REQUEST['_wpnonce'], 'sensei-login')) { |
|
1558 | 1558 | return; |
1559 | 1559 | } |
1560 | 1560 | |
@@ -1563,47 +1563,47 @@ discard block |
||
1563 | 1563 | $referrer = $_REQUEST['_wp_http_referer']; |
1564 | 1564 | //$redirect = $_REQUEST['_sensei_redirect']; |
1565 | 1565 | |
1566 | - if ( ( isset( $_REQUEST['log'] ) && !empty( $_REQUEST['log'] ) ) |
|
1567 | - && ( isset( $_REQUEST['pwd'] ) && !empty( $_REQUEST['pwd'] ) ) ){ |
|
1566 | + if ((isset($_REQUEST['log']) && ! empty($_REQUEST['log'])) |
|
1567 | + && (isset($_REQUEST['pwd']) && ! empty($_REQUEST['pwd']))) { |
|
1568 | 1568 | |
1569 | 1569 | // when the user has entered a password or username do the sensei login |
1570 | 1570 | $creds = array(); |
1571 | 1571 | |
1572 | 1572 | // check if the requests login is an email address |
1573 | - if( is_email( trim( $_REQUEST['log'] ) ) ){ |
|
1573 | + if (is_email(trim($_REQUEST['log']))) { |
|
1574 | 1574 | // query wordpress for the users details |
1575 | - $user = get_user_by( 'email', sanitize_email( $_REQUEST['log'] ) ); |
|
1575 | + $user = get_user_by('email', sanitize_email($_REQUEST['log'])); |
|
1576 | 1576 | |
1577 | 1577 | // validate the user object |
1578 | - if( !$user ){ |
|
1578 | + if ( ! $user) { |
|
1579 | 1579 | |
1580 | 1580 | // the email doesnt exist |
1581 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1581 | + wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer))); |
|
1582 | 1582 | exit; |
1583 | 1583 | |
1584 | 1584 | } |
1585 | 1585 | |
1586 | 1586 | //assigne the username to the creds array for further processing |
1587 | - $creds['user_login'] = $user->user_login ; |
|
1587 | + $creds['user_login'] = $user->user_login; |
|
1588 | 1588 | |
1589 | - }else{ |
|
1589 | + } else { |
|
1590 | 1590 | |
1591 | 1591 | // process this as a default username login |
1592 | - $creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ; |
|
1592 | + $creds['user_login'] = sanitize_text_field($_REQUEST['log']); |
|
1593 | 1593 | |
1594 | 1594 | } |
1595 | 1595 | |
1596 | 1596 | // get setup the rest of the creds array |
1597 | - $creds['user_password'] = sanitize_text_field( $_REQUEST['pwd'] ); |
|
1598 | - $creds['remember'] = isset( $_REQUEST['rememberme'] ) ? true : false ; |
|
1597 | + $creds['user_password'] = sanitize_text_field($_REQUEST['pwd']); |
|
1598 | + $creds['remember'] = isset($_REQUEST['rememberme']) ? true : false; |
|
1599 | 1599 | |
1600 | 1600 | //attempt logging in with the given details |
1601 | - $user = wp_signon( $creds, false ); |
|
1601 | + $user = wp_signon($creds, false); |
|
1602 | 1602 | |
1603 | - if ( is_wp_error($user) ){ // on login failure |
|
1604 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1603 | + if (is_wp_error($user)) { // on login failure |
|
1604 | + wp_redirect(esc_url_raw(add_query_arg('login', 'failed', $referrer))); |
|
1605 | 1605 | exit; |
1606 | - }else{ // on login success |
|
1606 | + } else { // on login success |
|
1607 | 1607 | |
1608 | 1608 | /** |
1609 | 1609 | * change the redirect url programatically |
@@ -1613,21 +1613,21 @@ discard block |
||
1613 | 1613 | * @param string $referrer the page where the current url wheresensei login form was posted from |
1614 | 1614 | */ |
1615 | 1615 | |
1616 | - $success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg( 'login', $referrer ) ); |
|
1616 | + $success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg('login', $referrer)); |
|
1617 | 1617 | |
1618 | - wp_redirect( esc_url_raw( $success_redirect_url ) ); |
|
1618 | + wp_redirect(esc_url_raw($success_redirect_url)); |
|
1619 | 1619 | exit; |
1620 | 1620 | |
1621 | 1621 | } // end is_wp_error($user) |
1622 | 1622 | |
1623 | - }else{ // if username or password is empty |
|
1623 | + } else { // if username or password is empty |
|
1624 | 1624 | |
1625 | - wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) ); |
|
1625 | + wp_redirect(esc_url_raw(add_query_arg('login', 'emptyfields', $referrer))); |
|
1626 | 1626 | exit; |
1627 | 1627 | |
1628 | 1628 | } // end if username $_REQUEST['log'] and password $_REQUEST['pwd'] is empty |
1629 | 1629 | |
1630 | - }elseif( ( isset( $_GET['login'] ) ) ) { |
|
1630 | + }elseif ((isset($_GET['login']))) { |
|
1631 | 1631 | // else if this request is a redircect from a previously faile login request |
1632 | 1632 | $this->login_message_process(); |
1633 | 1633 | |
@@ -1646,87 +1646,87 @@ discard block |
||
1646 | 1646 | * @return void redirect |
1647 | 1647 | * |
1648 | 1648 | */ |
1649 | - public function sensei_process_registration(){ |
|
1649 | + public function sensei_process_registration() { |
|
1650 | 1650 | global $current_user; |
1651 | 1651 | // check the for the sensei specific registration requests |
1652 | - if( !isset( $_POST['sensei_reg_username'] ) && ! isset( $_POST['sensei_reg_email'] ) && !isset( $_POST['sensei_reg_password'] )){ |
|
1652 | + if ( ! isset($_POST['sensei_reg_username']) && ! isset($_POST['sensei_reg_email']) && ! isset($_POST['sensei_reg_password'])) { |
|
1653 | 1653 | // exit functionas this is not a sensei registration request |
1654 | - return ; |
|
1654 | + return; |
|
1655 | 1655 | } |
1656 | 1656 | // check for spam throw cheating huh |
1657 | - if( isset( $_POST['email_2'] ) && '' !== $_POST['email_2'] ){ |
|
1657 | + if (isset($_POST['email_2']) && '' !== $_POST['email_2']) { |
|
1658 | 1658 | $message = 'Error: The spam field should be empty'; |
1659 | - Sensei()->notices->add_notice( $message, 'alert'); |
|
1659 | + Sensei()->notices->add_notice($message, 'alert'); |
|
1660 | 1660 | return; |
1661 | 1661 | } |
1662 | 1662 | |
1663 | 1663 | // retreive form variables |
1664 | - $new_user_name = sanitize_user( $_POST['sensei_reg_username'] ); |
|
1665 | - $new_user_email = $_POST['sensei_reg_email']; |
|
1666 | - $new_user_password = $_POST['sensei_reg_password']; |
|
1664 | + $new_user_name = sanitize_user($_POST['sensei_reg_username']); |
|
1665 | + $new_user_email = $_POST['sensei_reg_email']; |
|
1666 | + $new_user_password = $_POST['sensei_reg_password']; |
|
1667 | 1667 | |
1668 | 1668 | // Check the username |
1669 | 1669 | $username_error_notice = ''; |
1670 | - if ( $new_user_name == '' ) { |
|
1671 | - $username_error_notice = __( '<strong>ERROR</strong>: Please enter a username.' ); |
|
1672 | - } elseif ( ! validate_username( $new_user_name ) ) { |
|
1673 | - $username_error_notice = __( '<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.' ); |
|
1674 | - } elseif ( username_exists( $new_user_name ) ) { |
|
1675 | - $username_error_notice = __( '<strong>ERROR</strong>: This username is already registered. Please choose another one.' ); |
|
1670 | + if ($new_user_name == '') { |
|
1671 | + $username_error_notice = __('<strong>ERROR</strong>: Please enter a username.'); |
|
1672 | + } elseif ( ! validate_username($new_user_name)) { |
|
1673 | + $username_error_notice = __('<strong>ERROR</strong>: This username is invalid because it uses illegal characters. Please enter a valid username.'); |
|
1674 | + } elseif (username_exists($new_user_name)) { |
|
1675 | + $username_error_notice = __('<strong>ERROR</strong>: This username is already registered. Please choose another one.'); |
|
1676 | 1676 | } |
1677 | 1677 | |
1678 | 1678 | // exit on username error |
1679 | - if( '' !== $username_error_notice ){ |
|
1680 | - Sensei()->notices->add_notice( $username_error_notice , 'alert'); |
|
1679 | + if ('' !== $username_error_notice) { |
|
1680 | + Sensei()->notices->add_notice($username_error_notice, 'alert'); |
|
1681 | 1681 | return; |
1682 | 1682 | } |
1683 | 1683 | |
1684 | 1684 | // Check the e-mail address |
1685 | 1685 | $email_error_notice = ''; |
1686 | - if ( $new_user_email == '' ) { |
|
1687 | - $email_error_notice = __( '<strong>ERROR</strong>: Please type your e-mail address.' ); |
|
1688 | - } elseif ( ! is_email( $new_user_email ) ) { |
|
1689 | - $email_error_notice = __( '<strong>ERROR</strong>: The email address isn’t correct.' ); |
|
1690 | - } elseif ( email_exists( $new_user_email ) ) { |
|
1691 | - $email_error_notice = __( '<strong>ERROR</strong>: This email is already registered, please choose another one.' ); |
|
1686 | + if ($new_user_email == '') { |
|
1687 | + $email_error_notice = __('<strong>ERROR</strong>: Please type your e-mail address.'); |
|
1688 | + } elseif ( ! is_email($new_user_email)) { |
|
1689 | + $email_error_notice = __('<strong>ERROR</strong>: The email address isn’t correct.'); |
|
1690 | + } elseif (email_exists($new_user_email)) { |
|
1691 | + $email_error_notice = __('<strong>ERROR</strong>: This email is already registered, please choose another one.'); |
|
1692 | 1692 | } |
1693 | 1693 | |
1694 | 1694 | // exit on email address error |
1695 | - if( '' !== $email_error_notice ){ |
|
1696 | - Sensei()->notices->add_notice( $email_error_notice , 'alert'); |
|
1695 | + if ('' !== $email_error_notice) { |
|
1696 | + Sensei()->notices->add_notice($email_error_notice, 'alert'); |
|
1697 | 1697 | return; |
1698 | 1698 | } |
1699 | 1699 | |
1700 | 1700 | //check user password |
1701 | 1701 | |
1702 | 1702 | // exit on email address error |
1703 | - if( empty( $new_user_password ) ){ |
|
1704 | - Sensei()->notices->add_notice( __( '<strong>ERROR</strong>: The password field may not be empty, please enter a secure password.' ) , 'alert'); |
|
1703 | + if (empty($new_user_password)) { |
|
1704 | + Sensei()->notices->add_notice(__('<strong>ERROR</strong>: The password field may not be empty, please enter a secure password.'), 'alert'); |
|
1705 | 1705 | return; |
1706 | 1706 | } |
1707 | 1707 | |
1708 | 1708 | // register user |
1709 | - $user_id = wp_create_user( $new_user_name, $new_user_password, $new_user_email ); |
|
1710 | - if ( ! $user_id || is_wp_error( $user_id ) ) { |
|
1711 | - Sensei()->notices->add_notice( sprintf( __( '<strong>ERROR</strong>: Couldn\'t register you… please contact the <a href="mailto:%s">webmaster</a> !' ), get_option( 'admin_email' ) ), 'alert'); |
|
1709 | + $user_id = wp_create_user($new_user_name, $new_user_password, $new_user_email); |
|
1710 | + if ( ! $user_id || is_wp_error($user_id)) { |
|
1711 | + Sensei()->notices->add_notice(sprintf(__('<strong>ERROR</strong>: Couldn\'t register you… please contact the <a href="mailto:%s">webmaster</a> !'), get_option('admin_email')), 'alert'); |
|
1712 | 1712 | } |
1713 | 1713 | |
1714 | 1714 | // notify the user |
1715 | - wp_new_user_notification( $user_id, $new_user_password ); |
|
1715 | + wp_new_user_notification($user_id, $new_user_password); |
|
1716 | 1716 | |
1717 | 1717 | // set global current user aka log the user in |
1718 | - $current_user = get_user_by( 'id', $user_id ); |
|
1719 | - wp_set_auth_cookie( $user_id, true ); |
|
1718 | + $current_user = get_user_by('id', $user_id); |
|
1719 | + wp_set_auth_cookie($user_id, true); |
|
1720 | 1720 | |
1721 | 1721 | // Redirect |
1722 | 1722 | global $wp; |
1723 | - if ( wp_get_referer() ) { |
|
1724 | - $redirect = esc_url( wp_get_referer() ); |
|
1723 | + if (wp_get_referer()) { |
|
1724 | + $redirect = esc_url(wp_get_referer()); |
|
1725 | 1725 | } else { |
1726 | - $redirect = esc_url( home_url( $wp->request ) ); |
|
1726 | + $redirect = esc_url(home_url($wp->request)); |
|
1727 | 1727 | } |
1728 | 1728 | |
1729 | - wp_redirect( apply_filters( 'sensei_registration_redirect', $redirect ) ); |
|
1729 | + wp_redirect(apply_filters('sensei_registration_redirect', $redirect)); |
|
1730 | 1730 | exit; |
1731 | 1731 | |
1732 | 1732 | } // end sensei_process_registration)() |
@@ -1737,7 +1737,7 @@ discard block |
||
1737 | 1737 | * @return void redirect |
1738 | 1738 | * @since 1.7.0 |
1739 | 1739 | */ |
1740 | - public function login_message_process(){ |
|
1740 | + public function login_message_process() { |
|
1741 | 1741 | |
1742 | 1742 | |
1743 | 1743 | // setup the message variables |
@@ -1745,16 +1745,16 @@ discard block |
||
1745 | 1745 | |
1746 | 1746 | //only output message if the url contains login=failed and login=emptyfields |
1747 | 1747 | |
1748 | - if( $_GET['login'] == 'failed' ){ |
|
1748 | + if ($_GET['login'] == 'failed') { |
|
1749 | 1749 | |
1750 | - $message = __('Incorrect login details', 'woothemes-sensei' ); |
|
1750 | + $message = __('Incorrect login details', 'woothemes-sensei'); |
|
1751 | 1751 | |
1752 | - }elseif( $_GET['login'] == 'emptyfields' ){ |
|
1752 | + }elseif ($_GET['login'] == 'emptyfields') { |
|
1753 | 1753 | |
1754 | - $message= __('Please enter your username and password', 'woothemes-sensei' ); |
|
1754 | + $message = __('Please enter your username and password', 'woothemes-sensei'); |
|
1755 | 1755 | } |
1756 | 1756 | |
1757 | - Sensei()->notices->add_notice( $message, 'alert'); |
|
1757 | + Sensei()->notices->add_notice($message, 'alert'); |
|
1758 | 1758 | |
1759 | 1759 | }// end login_message_process |
1760 | 1760 | |
@@ -1766,11 +1766,11 @@ discard block |
||
1766 | 1766 | * @return void redirect |
1767 | 1767 | * |
1768 | 1768 | */ |
1769 | - public function sensei_show_admin_bar () { |
|
1769 | + public function sensei_show_admin_bar() { |
|
1770 | 1770 | |
1771 | 1771 | if (current_user_can('edit_courses')) { |
1772 | 1772 | |
1773 | - add_filter( 'woocommerce_disable_admin_bar', '__return_false', 10, 1); |
|
1773 | + add_filter('woocommerce_disable_admin_bar', '__return_false', 10, 1); |
|
1774 | 1774 | |
1775 | 1775 | } |
1776 | 1776 | |
@@ -1783,4 +1783,4 @@ discard block |
||
1783 | 1783 | * for backward compatibility |
1784 | 1784 | * @since 1.9.0 |
1785 | 1785 | */ |
1786 | -class WooThemes_Sensei_Frontend extends Sensei_Frontend{} |
|
1786 | +class WooThemes_Sensei_Frontend extends Sensei_Frontend {} |
@@ -69,10 +69,10 @@ discard block |
||
69 | 69 | // Only show course & lesson excerpts in search results |
70 | 70 | add_filter( 'the_content', array( $this, 'sensei_search_results_excerpt' ) ); |
71 | 71 | |
72 | - //Use WooCommerce filter to show admin bar to Teachers. |
|
73 | - add_action( 'init', array( $this, 'sensei_show_admin_bar') ); |
|
72 | + //Use WooCommerce filter to show admin bar to Teachers. |
|
73 | + add_action( 'init', array( $this, 'sensei_show_admin_bar') ); |
|
74 | 74 | |
75 | - // Remove course from active courses if an order is cancelled or refunded |
|
75 | + // Remove course from active courses if an order is cancelled or refunded |
|
76 | 76 | add_action( 'woocommerce_order_status_processing_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
77 | 77 | add_action( 'woocommerce_order_status_completed_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
78 | 78 | add_action( 'woocommerce_order_status_on-hold_to_cancelled', array( $this, 'remove_active_course' ), 10, 1 ); |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | wp_enqueue_script( Sensei()->token . '-user-dashboard' ); |
134 | 134 | |
135 | 135 | |
136 | - // Course Archive javascript |
|
137 | - if( is_post_type_archive( 'course' ) ){ |
|
136 | + // Course Archive javascript |
|
137 | + if( is_post_type_archive( 'course' ) ){ |
|
138 | 138 | |
139 | - wp_register_script( 'sensei-course-archive-js', esc_url( Sensei()->plugin_url . 'assets/js/frontend/course-archive' . $suffix . '.js' ), array( 'jquery' ), '1', true ); |
|
140 | - wp_enqueue_script( 'sensei-course-archive-js' ); |
|
139 | + wp_register_script( 'sensei-course-archive-js', esc_url( Sensei()->plugin_url . 'assets/js/frontend/course-archive' . $suffix . '.js' ), array( 'jquery' ), '1', true ); |
|
140 | + wp_enqueue_script( 'sensei-course-archive-js' ); |
|
141 | 141 | |
142 | - } |
|
142 | + } |
|
143 | 143 | |
144 | 144 | |
145 | 145 | // Allow additional scripts to be loaded |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | /** |
181 | 181 | * sensei_get_template_part function. |
182 | 182 | * |
183 | - * @deprecated sine 1.9.0 |
|
183 | + * @deprecated sine 1.9.0 |
|
184 | 184 | * @access public |
185 | 185 | * @param mixed $slug |
186 | 186 | * @param string $name (default: '') |
@@ -188,15 +188,15 @@ discard block |
||
188 | 188 | */ |
189 | 189 | function sensei_get_template_part( $slug, $name = '' ) { |
190 | 190 | |
191 | - _deprecated_function( 'class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part' ); |
|
192 | - Sensei_Templates::get_part( $slug, $name ); |
|
191 | + _deprecated_function( 'class-woothemes-sensei-frontend.php', '1.9.0', 'Sensei_Templates::get_part' ); |
|
192 | + Sensei_Templates::get_part( $slug, $name ); |
|
193 | 193 | |
194 | 194 | } // End sensei_get_template_part() |
195 | 195 | |
196 | 196 | /** |
197 | 197 | * sensei_get_template function. |
198 | 198 | * |
199 | - * @deprecated since 1.9.0 |
|
199 | + * @deprecated since 1.9.0 |
|
200 | 200 | * @access public |
201 | 201 | * @param mixed $template_name |
202 | 202 | * @param array $args (default: array()) |
@@ -206,8 +206,8 @@ discard block |
||
206 | 206 | */ |
207 | 207 | function sensei_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
208 | 208 | |
209 | - _deprecated_function( 'sensei_get_template', '1.9.0', 'Sensei_Templates::get_template' ); |
|
210 | - Sensei_Templates::get_template($template_name, $args, $template_path, $default_path ); |
|
209 | + _deprecated_function( 'sensei_get_template', '1.9.0', 'Sensei_Templates::get_template' ); |
|
210 | + Sensei_Templates::get_template($template_name, $args, $template_path, $default_path ); |
|
211 | 211 | |
212 | 212 | } // End sensei_get_template() |
213 | 213 | |
@@ -223,33 +223,33 @@ discard block |
||
223 | 223 | */ |
224 | 224 | function sensei_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
225 | 225 | |
226 | - _deprecated_function( 'sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template' ); |
|
227 | - Sensei_Templates::locate_template( $template_name, $template_path, $default_path ); |
|
226 | + _deprecated_function( 'sensei_locate_template', '1.9.0', 'Sensei_Templates::locate_template' ); |
|
227 | + Sensei_Templates::locate_template( $template_name, $template_path, $default_path ); |
|
228 | 228 | |
229 | 229 | } // End sensei_locate_template() |
230 | 230 | |
231 | 231 | |
232 | 232 | /** |
233 | 233 | * sensei_output_content_wrapper function. |
234 | - * |
|
234 | + * |
|
235 | 235 | * @access public |
236 | 236 | * @return void |
237 | 237 | */ |
238 | 238 | function sensei_output_content_wrapper() { |
239 | 239 | |
240 | - // backwards compatibility check for old location under the wrappers directory of the active theme |
|
241 | - $backwards_compatible_wrapper_location = array( |
|
242 | - Sensei()->template_url . 'wrappers/wrapper-start.php', |
|
243 | - 'wrappers/wrapper-start.php' |
|
244 | - ); |
|
240 | + // backwards compatibility check for old location under the wrappers directory of the active theme |
|
241 | + $backwards_compatible_wrapper_location = array( |
|
242 | + Sensei()->template_url . 'wrappers/wrapper-start.php', |
|
243 | + 'wrappers/wrapper-start.php' |
|
244 | + ); |
|
245 | 245 | |
246 | - $template = locate_template( $backwards_compatible_wrapper_location ); |
|
247 | - if( !empty( $template ) ){ |
|
246 | + $template = locate_template( $backwards_compatible_wrapper_location ); |
|
247 | + if( !empty( $template ) ){ |
|
248 | 248 | |
249 | - Sensei_Templates::get_template( 'wrappers/wrapper-start.php' ); |
|
250 | - return; |
|
249 | + Sensei_Templates::get_template( 'wrappers/wrapper-start.php' ); |
|
250 | + return; |
|
251 | 251 | |
252 | - } |
|
252 | + } |
|
253 | 253 | |
254 | 254 | Sensei_Templates::get_template( 'globals/wrapper-start.php' ); |
255 | 255 | |
@@ -258,25 +258,25 @@ discard block |
||
258 | 258 | |
259 | 259 | /** |
260 | 260 | * sensei_output_content_wrapper_end function. |
261 | - * |
|
261 | + * |
|
262 | 262 | * @access public |
263 | 263 | * @return void |
264 | 264 | */ |
265 | 265 | function sensei_output_content_wrapper_end() { |
266 | 266 | |
267 | - // backwards compatibility check for old location under the wrappers directory of the active theme |
|
268 | - $backwards_compatible_wrapper_location = array( |
|
269 | - Sensei()->template_url . 'wrappers/wrapper-end.php', |
|
270 | - 'wrappers/wrapper-end.php' |
|
271 | - ); |
|
267 | + // backwards compatibility check for old location under the wrappers directory of the active theme |
|
268 | + $backwards_compatible_wrapper_location = array( |
|
269 | + Sensei()->template_url . 'wrappers/wrapper-end.php', |
|
270 | + 'wrappers/wrapper-end.php' |
|
271 | + ); |
|
272 | 272 | |
273 | - $backwards_compatible_template = locate_template( $backwards_compatible_wrapper_location ); |
|
274 | - if( !empty( $backwards_compatible_template ) ){ |
|
273 | + $backwards_compatible_template = locate_template( $backwards_compatible_wrapper_location ); |
|
274 | + if( !empty( $backwards_compatible_template ) ){ |
|
275 | 275 | |
276 | - Sensei_Templates::get_template( 'wrappers/wrapper-end.php' ); |
|
277 | - return; |
|
276 | + Sensei_Templates::get_template( 'wrappers/wrapper-end.php' ); |
|
277 | + return; |
|
278 | 278 | |
279 | - } |
|
279 | + } |
|
280 | 280 | |
281 | 281 | |
282 | 282 | Sensei_Templates::get_template( 'globals/wrapper-end.php' ); |
@@ -292,55 +292,55 @@ discard block |
||
292 | 292 | */ |
293 | 293 | public static function load_content_pagination() { |
294 | 294 | |
295 | - if( is_singular('course') ) { |
|
295 | + if( is_singular('course') ) { |
|
296 | 296 | |
297 | - // backwards compatibility check for old location under the wrappers directory of the active theme |
|
298 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-posts.php' ) ); |
|
299 | - if( !empty( $template ) ){ |
|
297 | + // backwards compatibility check for old location under the wrappers directory of the active theme |
|
298 | + $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-posts.php' ) ); |
|
299 | + if( !empty( $template ) ){ |
|
300 | 300 | |
301 | - Sensei_Templates::get_template( 'wrappers/pagination-posts.php' ); |
|
302 | - return; |
|
301 | + Sensei_Templates::get_template( 'wrappers/pagination-posts.php' ); |
|
302 | + return; |
|
303 | 303 | |
304 | - } |
|
304 | + } |
|
305 | 305 | |
306 | 306 | Sensei_Templates::get_template( 'globals/pagination-posts.php' ); |
307 | 307 | |
308 | 308 | } elseif( is_singular('lesson') ) { |
309 | 309 | |
310 | - // backwards compatibility check for old location under the wrappers directory of the active theme |
|
311 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-lesson.php' ) ); |
|
312 | - if( !empty( $template ) ){ |
|
310 | + // backwards compatibility check for old location under the wrappers directory of the active theme |
|
311 | + $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-lesson.php' ) ); |
|
312 | + if( !empty( $template ) ){ |
|
313 | 313 | |
314 | - Sensei_Templates::get_template( 'wrappers/pagination-lesson.php' ); |
|
315 | - return; |
|
314 | + Sensei_Templates::get_template( 'wrappers/pagination-lesson.php' ); |
|
315 | + return; |
|
316 | 316 | |
317 | - } |
|
317 | + } |
|
318 | 318 | |
319 | 319 | Sensei_Templates::get_template( 'globals/pagination-lesson.php' ); |
320 | 320 | |
321 | 321 | } elseif( is_singular('quiz') ) { |
322 | 322 | |
323 | - // backwards compatibility check for old location under the wrappers directory of the active theme |
|
324 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-quiz.php' ) ); |
|
325 | - if( !empty( $template ) ){ |
|
323 | + // backwards compatibility check for old location under the wrappers directory of the active theme |
|
324 | + $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination-quiz.php' ) ); |
|
325 | + if( !empty( $template ) ){ |
|
326 | 326 | |
327 | - Sensei_Templates::get_template( 'wrappers/pagination-quiz.php' ); |
|
328 | - return; |
|
327 | + Sensei_Templates::get_template( 'wrappers/pagination-quiz.php' ); |
|
328 | + return; |
|
329 | 329 | |
330 | - } |
|
330 | + } |
|
331 | 331 | |
332 | 332 | Sensei_Templates::get_template( 'globals/pagination-quiz.php' ); |
333 | 333 | |
334 | 334 | } else { |
335 | 335 | |
336 | - // backwards compatibility check for old location under the wrappers directory of the active theme |
|
337 | - $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination.php' ) ); |
|
338 | - if( !empty( $template ) ){ |
|
336 | + // backwards compatibility check for old location under the wrappers directory of the active theme |
|
337 | + $template = locate_template( array( Sensei()->template_url . 'wrappers/pagination.php' ) ); |
|
338 | + if( !empty( $template ) ){ |
|
339 | 339 | |
340 | - Sensei_Templates::get_template( 'wrappers/pagination.php' ); |
|
341 | - return; |
|
340 | + Sensei_Templates::get_template( 'wrappers/pagination.php' ); |
|
341 | + return; |
|
342 | 342 | |
343 | - } |
|
343 | + } |
|
344 | 344 | |
345 | 345 | Sensei_Templates::get_template( 'globals/pagination.php' ); |
346 | 346 | |
@@ -397,13 +397,13 @@ discard block |
||
397 | 397 | |
398 | 398 | case '#senseimymessages': |
399 | 399 | $item->url = $my_messages_url; |
400 | - // if no archive link exist for sensei_message |
|
401 | - // set it back to the place holder |
|
402 | - if( ! $item->url ){ |
|
400 | + // if no archive link exist for sensei_message |
|
401 | + // set it back to the place holder |
|
402 | + if( ! $item->url ){ |
|
403 | 403 | |
404 | - $item->url = '#senseimymessages'; |
|
404 | + $item->url = '#senseimymessages'; |
|
405 | 405 | |
406 | - } |
|
406 | + } |
|
407 | 407 | break; |
408 | 408 | |
409 | 409 | case '#senseilearnerprofile': |
@@ -469,7 +469,7 @@ discard block |
||
469 | 469 | |
470 | 470 | // Remove the My Messages link for logged out users or if Private Messages are disabled |
471 | 471 | if( ! get_post_type_archive_link( 'sensei_message' ) |
472 | - && '#senseimymessages' == $item->url ) { |
|
472 | + && '#senseimymessages' == $item->url ) { |
|
473 | 473 | |
474 | 474 | if ( !is_user_logged_in() || ( isset( Sensei()->settings->settings['messages_disable'] ) && Sensei()->settings->settings['messages_disable'] ) ) { |
475 | 475 | |
@@ -492,42 +492,42 @@ discard block |
||
492 | 492 | |
493 | 493 | // add category nicenames in body and post class |
494 | 494 | function sensei_search_results_classes($classes) { |
495 | - global $post; |
|
496 | - // Handle Search Classes for Courses, Lessons, and WC Products |
|
497 | - if ( isset( $post->post_type ) && ( ( 'course' == $post->post_type ) || ( 'lesson' == $post->post_type ) || ( 'product' == $post->post_type ) ) ) { |
|
498 | - $classes[] = 'post'; |
|
495 | + global $post; |
|
496 | + // Handle Search Classes for Courses, Lessons, and WC Products |
|
497 | + if ( isset( $post->post_type ) && ( ( 'course' == $post->post_type ) || ( 'lesson' == $post->post_type ) || ( 'product' == $post->post_type ) ) ) { |
|
498 | + $classes[] = 'post'; |
|
499 | 499 | } // End If Statement |
500 | - return $classes; |
|
500 | + return $classes; |
|
501 | 501 | } // End sensei_search_results_classes() |
502 | 502 | |
503 | - /** |
|
504 | - * sensei_single_title output for single page title |
|
505 | - * @since 1.1.0 |
|
506 | - * @return void |
|
507 | - * @deprecated |
|
508 | - */ |
|
509 | - function the_single_title() { |
|
503 | + /** |
|
504 | + * sensei_single_title output for single page title |
|
505 | + * @since 1.1.0 |
|
506 | + * @return void |
|
507 | + * @deprecated |
|
508 | + */ |
|
509 | + function the_single_title() { |
|
510 | 510 | |
511 | - _deprecated_function(' WooThemes_Sensei_Frontend::the_single_title', '1.9.0'); |
|
511 | + _deprecated_function(' WooThemes_Sensei_Frontend::the_single_title', '1.9.0'); |
|
512 | 512 | |
513 | - } // End sensei_single_title() |
|
513 | + } // End sensei_single_title() |
|
514 | 514 | |
515 | 515 | /** |
516 | 516 | * sensei_course_image output for course image Please use Sensei()->course->course_image instead. |
517 | - * |
|
518 | - * @deprecated since 1.9.0 |
|
519 | - * @param $course_id |
|
520 | - * @param string $width |
|
521 | - * @param string $height |
|
522 | - * @param bool|false $return |
|
523 | - * @return string|void |
|
517 | + * |
|
518 | + * @deprecated since 1.9.0 |
|
519 | + * @param $course_id |
|
520 | + * @param string $width |
|
521 | + * @param string $height |
|
522 | + * @param bool|false $return |
|
523 | + * @return string|void |
|
524 | 524 | */ |
525 | 525 | function sensei_course_image( $course_id, $width = '100', $height = '100', $return = false ) { |
526 | 526 | |
527 | - if ( ! $return ) { |
|
527 | + if ( ! $return ) { |
|
528 | 528 | |
529 | 529 | echo Sensei()->course->course_image( $course_id, $width, $height ); |
530 | - return ''; |
|
530 | + return ''; |
|
531 | 531 | |
532 | 532 | } // End If Statement |
533 | 533 | |
@@ -538,31 +538,31 @@ discard block |
||
538 | 538 | /** |
539 | 539 | * sensei_lesson_image output for lesson image |
540 | 540 | * @since 1.2.0 |
541 | - * @deprecated since 1.9.0 |
|
542 | - * @param $lesson_id |
|
543 | - * @param string $width |
|
544 | - * @param string $height |
|
545 | - * @param bool|false $return |
|
546 | - * @param bool|false $widget |
|
547 | - * @return string |
|
541 | + * @deprecated since 1.9.0 |
|
542 | + * @param $lesson_id |
|
543 | + * @param string $width |
|
544 | + * @param string $height |
|
545 | + * @param bool|false $return |
|
546 | + * @param bool|false $widget |
|
547 | + * @return string |
|
548 | 548 | */ |
549 | 549 | function sensei_lesson_image( $lesson_id, $width = '100', $height = '100', $return = false, $widget = false ) { |
550 | 550 | |
551 | - if( ! $return ){ |
|
551 | + if( ! $return ){ |
|
552 | 552 | |
553 | - echo Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget ); |
|
554 | - return ''; |
|
555 | - } |
|
553 | + echo Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget ); |
|
554 | + return ''; |
|
555 | + } |
|
556 | 556 | |
557 | - return Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget ); |
|
557 | + return Sensei()->lesson->lesson_image( $lesson_id, $width, $height, $widget ); |
|
558 | 558 | |
559 | 559 | } // End sensei_lesson_image() |
560 | 560 | |
561 | - /** |
|
562 | - * @since 1.0.0 |
|
563 | - * @param WP_Query $query |
|
564 | - */ |
|
565 | - function sensei_course_archive_pagination( $query ) { |
|
561 | + /** |
|
562 | + * @since 1.0.0 |
|
563 | + * @param WP_Query $query |
|
564 | + */ |
|
565 | + function sensei_course_archive_pagination( $query ) { |
|
566 | 566 | |
567 | 567 | if( ! is_admin() && $query->is_main_query() && isset( $_GET['action'] ) && in_array( $_GET['action'], array( 'newcourses', 'featuredcourses', 'freecourses', 'paidcourses' ) ) ) { |
568 | 568 | |
@@ -585,50 +585,50 @@ discard block |
||
585 | 585 | * |
586 | 586 | * @access public |
587 | 587 | * @since 1.2.0 |
588 | - * @deprecated since 1.9.0 use WooThemes_Sensei_Course::archive_header |
|
588 | + * @deprecated since 1.9.0 use WooThemes_Sensei_Course::archive_header |
|
589 | 589 | * @return void |
590 | 590 | */ |
591 | 591 | function sensei_course_archive_header( ) { |
592 | 592 | |
593 | - trigger_error('This function sensei_course_archive_header has been depricated. Please use: WooThemes_Sensei_Course::course_archive_header '); |
|
594 | - WooThemes_Sensei_Course::archive_header( '', '<header class="archive-header"><h1>', '</h1></header>' ); |
|
593 | + trigger_error('This function sensei_course_archive_header has been depricated. Please use: WooThemes_Sensei_Course::course_archive_header '); |
|
594 | + WooThemes_Sensei_Course::archive_header( '', '<header class="archive-header"><h1>', '</h1></header>' ); |
|
595 | 595 | |
596 | 596 | } // sensei_course_archive_header() |
597 | 597 | |
598 | 598 | /** |
599 | 599 | * sensei_lesson_archive_header function. |
600 | 600 | * |
601 | - * @deprecated since 1.9.0 |
|
601 | + * @deprecated since 1.9.0 |
|
602 | 602 | * @access public |
603 | 603 | * @since 1.2.1 |
604 | 604 | * @return void |
605 | 605 | */ |
606 | 606 | public function sensei_lesson_archive_header( ) { |
607 | - _deprecated_function( 'WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header' ); |
|
608 | - Sensei()->lesson->the_archive_header(); |
|
607 | + _deprecated_function( 'WooThemes_Sensei_Frontend::sensei_lesson_archive_header', '1.9.0', 'WooThemes_Sensei_Lesson::the_archive_header' ); |
|
608 | + Sensei()->lesson->the_archive_header(); |
|
609 | 609 | } // sensei_course_archive_header() |
610 | 610 | |
611 | - /** |
|
612 | - * @deprecated since 1.9.0 |
|
613 | - */ |
|
611 | + /** |
|
612 | + * @deprecated since 1.9.0 |
|
613 | + */ |
|
614 | 614 | public function sensei_message_archive_header( ){ |
615 | - _deprecated_function('Sensei_Frontend::sensei_message_archive_header','Please use: Sense'); |
|
616 | - Sensei_Messages::the_archive_header(); |
|
615 | + _deprecated_function('Sensei_Frontend::sensei_message_archive_header','Please use: Sense'); |
|
616 | + Sensei_Messages::the_archive_header(); |
|
617 | 617 | } // sensei_message_archive_header() |
618 | 618 | |
619 | 619 | /** |
620 | 620 | * sensei_course_archive_course_title output for course archive page individual course title |
621 | 621 | * @since 1.2.0 |
622 | - * @param WP_Post $post_item |
|
622 | + * @param WP_Post $post_item |
|
623 | 623 | * @return void |
624 | 624 | */ |
625 | 625 | function sensei_course_archive_course_title( $post_item ) { |
626 | 626 | if ( isset( $post_item->ID ) && ( 0 < $post_item->ID ) ) { |
627 | 627 | $post_id = absint( $post_item->ID ); |
628 | - $post_title = $post_item->post_title; |
|
628 | + $post_title = $post_item->post_title; |
|
629 | 629 | } else { |
630 | 630 | $post_id = get_the_ID(); |
631 | - $post_title = get_the_title(); |
|
631 | + $post_title = get_the_title(); |
|
632 | 632 | } // End If Statement |
633 | 633 | ?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php |
634 | 634 | } // End sensei_course_archive_course_title() |
@@ -640,7 +640,7 @@ discard block |
||
640 | 640 | */ |
641 | 641 | public function sensei_lesson_archive_lesson_title() { |
642 | 642 | $post_id = get_the_ID(); |
643 | - $post_title = get_the_title(); |
|
643 | + $post_title = get_the_title(); |
|
644 | 644 | ?><header><h2><a href="<?php echo get_permalink( $post_id ); ?>" title="<?php echo esc_attr( $post_title ); ?>"><?php echo $post_title; ?></a></h2></header><?php |
645 | 645 | } // End sensei_lesson_archive_lesson_title() |
646 | 646 | |
@@ -657,9 +657,9 @@ discard block |
||
657 | 657 | |
658 | 658 | if( empty( $id ) ){ |
659 | 659 | |
660 | - $id = get_the_ID(); |
|
660 | + $id = get_the_ID(); |
|
661 | 661 | |
662 | - } |
|
662 | + } |
|
663 | 663 | |
664 | 664 | $sensei_breadcrumb_prefix = __( 'Back to: ', 'woothemes-sensei' ); |
665 | 665 | $separator = apply_filters( 'sensei_breadcrumb_separator', '>' ); |
@@ -672,31 +672,31 @@ discard block |
||
672 | 672 | return; |
673 | 673 | } |
674 | 674 | $html .= '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Back to the course', 'woothemes-sensei' ) . '">' . get_the_title( $course_id ) . '</a>'; |
675 | - } // End If Statement |
|
676 | - // Quiz |
|
675 | + } // End If Statement |
|
676 | + // Quiz |
|
677 | 677 | if ( is_singular( 'quiz' ) && 0 < intval( $id ) ) { |
678 | 678 | $lesson_id = intval( get_post_meta( $id, '_quiz_lesson', true ) ); |
679 | 679 | if( ! $lesson_id ) { |
680 | 680 | return; |
681 | 681 | } |
682 | 682 | $html .= '<a href="' . esc_url( get_permalink( $lesson_id ) ) . '" title="' . __( 'Back to the lesson', 'woothemes-sensei' ) . '">' . get_the_title( $lesson_id ) . '</a>'; |
683 | - } // End If Statement |
|
683 | + } // End If Statement |
|
684 | 684 | |
685 | - // Allow other plugins to filter html |
|
686 | - $html = apply_filters ( 'sensei_breadcrumb_output', $html, $separator ); |
|
687 | - $html .= '</section>'; |
|
685 | + // Allow other plugins to filter html |
|
686 | + $html = apply_filters ( 'sensei_breadcrumb_output', $html, $separator ); |
|
687 | + $html .= '</section>'; |
|
688 | 688 | |
689 | - echo $html; |
|
689 | + echo $html; |
|
690 | 690 | } // End sensei_breadcrumb() |
691 | 691 | |
692 | 692 | |
693 | - /** |
|
694 | - * @deprecated since 1.9.0 use WooThemes_Sensei_Lesson::course_signup_link instead |
|
695 | - */ |
|
693 | + /** |
|
694 | + * @deprecated since 1.9.0 use WooThemes_Sensei_Lesson::course_signup_link instead |
|
695 | + */ |
|
696 | 696 | public function sensei_lesson_course_signup_link( ) { |
697 | 697 | |
698 | - _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link' ); |
|
699 | - WooThemes_Sensei_Lesson::course_signup_link(); |
|
698 | + _deprecated_function('sensei_lesson_course_signup_link', '1.9.0', 'WooThemes_Sensei_Lesson::course_signup_link' ); |
|
699 | + WooThemes_Sensei_Lesson::course_signup_link(); |
|
700 | 700 | } |
701 | 701 | |
702 | 702 | public function lesson_tags_display( $lesson_id = 0 ) { |
@@ -715,27 +715,27 @@ discard block |
||
715 | 715 | ?><section class="lesson-tags"> |
716 | 716 | <?php printf( __( 'Lesson tags: %1$s', 'woothemes-sensei' ), $tag_list ); ?> |
717 | 717 | </section><?php |
718 | - } |
|
719 | - } |
|
718 | + } |
|
719 | + } |
|
720 | 720 | } |
721 | 721 | } |
722 | 722 | |
723 | - /** |
|
724 | - * @param WP_Query $query |
|
725 | - */ |
|
723 | + /** |
|
724 | + * @param WP_Query $query |
|
725 | + */ |
|
726 | 726 | public function lesson_tag_archive_filter( $query ) { |
727 | - if( is_tax( 'lesson-tag' ) && $query->is_main_query() ) { |
|
728 | - // Limit to lessons only |
|
729 | - $query->set( 'post_type', 'lesson' ); |
|
727 | + if( is_tax( 'lesson-tag' ) && $query->is_main_query() ) { |
|
728 | + // Limit to lessons only |
|
729 | + $query->set( 'post_type', 'lesson' ); |
|
730 | 730 | |
731 | - // Set order of lessons |
|
732 | - $query->set( 'orderby', 'menu_order' ); |
|
733 | - $query->set( 'order', 'ASC' ); |
|
731 | + // Set order of lessons |
|
732 | + $query->set( 'orderby', 'menu_order' ); |
|
733 | + $query->set( 'order', 'ASC' ); |
|
734 | 734 | |
735 | - } |
|
736 | - } |
|
735 | + } |
|
736 | + } |
|
737 | 737 | |
738 | - public function lesson_tag_archive_header( $title ) { |
|
738 | + public function lesson_tag_archive_header( $title ) { |
|
739 | 739 | if( is_tax( 'lesson-tag' ) ) { |
740 | 740 | $title = sprintf( __( 'Lesson tag: %1$s', 'woothemes-sensei' ), apply_filters( 'sensei_lesson_tag_archive_title', get_queried_object()->name ) ); |
741 | 741 | } |
@@ -757,13 +757,13 @@ discard block |
||
757 | 757 | $sanitized_submit = esc_html( $_POST['quiz_action'] ); |
758 | 758 | |
759 | 759 | switch ($sanitized_submit) { |
760 | - case 'lesson-complete': |
|
760 | + case 'lesson-complete': |
|
761 | 761 | |
762 | 762 | Sensei_Utils::sensei_start_lesson( $post->ID, $current_user->ID, $complete = true ); |
763 | 763 | |
764 | 764 | break; |
765 | 765 | |
766 | - case 'lesson-reset': |
|
766 | + case 'lesson-reset': |
|
767 | 767 | |
768 | 768 | Sensei_Utils::sensei_remove_user_from_lesson( $post->ID, $current_user->ID ); |
769 | 769 | |
@@ -875,13 +875,13 @@ discard block |
||
875 | 875 | if ( 0 < intval( $post_id ) ) { |
876 | 876 | $lesson_video_embed = get_post_meta( $post_id, '_lesson_video_embed', true ); |
877 | 877 | if ( 'http' == substr( $lesson_video_embed, 0, 4) ) { |
878 | - // V2 - make width and height a setting for video embed |
|
879 | - $lesson_video_embed = wp_oembed_get( esc_url( $lesson_video_embed )/*, array( 'width' => 100 , 'height' => 100)*/ ); |
|
880 | - } // End If Statement |
|
881 | - if ( '' != $lesson_video_embed ) { |
|
882 | - ?><div class="video"><?php echo html_entity_decode($lesson_video_embed); ?></div><?php |
|
883 | - } // End If Statement |
|
884 | - } // End If Statement |
|
878 | + // V2 - make width and height a setting for video embed |
|
879 | + $lesson_video_embed = wp_oembed_get( esc_url( $lesson_video_embed )/*, array( 'width' => 100 , 'height' => 100)*/ ); |
|
880 | + } // End If Statement |
|
881 | + if ( '' != $lesson_video_embed ) { |
|
882 | + ?><div class="video"><?php echo html_entity_decode($lesson_video_embed); ?></div><?php |
|
883 | + } // End If Statement |
|
884 | + } // End If Statement |
|
885 | 885 | } // End sensei_lesson_video() |
886 | 886 | |
887 | 887 | public function sensei_complete_lesson_button() { |
@@ -894,8 +894,8 @@ discard block |
||
894 | 894 | $pass_required = true; |
895 | 895 | if( $quiz_id ) { |
896 | 896 | // Get quiz pass setting |
897 | - $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); |
|
898 | - } |
|
897 | + $pass_required = get_post_meta( $quiz_id, '_pass_required', true ); |
|
898 | + } |
|
899 | 899 | if( ! $quiz_id || ( $quiz_id && ! $pass_required ) ) { |
900 | 900 | ?> |
901 | 901 | <form class="lesson_button_form" method="POST" action="<?php echo esc_url( get_permalink() ); ?>"> |
@@ -948,12 +948,12 @@ discard block |
||
948 | 948 | } // End If Statement |
949 | 949 | } // End sensei_reset_lesson_button() |
950 | 950 | |
951 | - /** |
|
952 | - * @deprecated since 1.9.0 |
|
953 | - */ |
|
954 | - public function sensei_lesson_quiz_meta( ) { |
|
951 | + /** |
|
952 | + * @deprecated since 1.9.0 |
|
953 | + */ |
|
954 | + public function sensei_lesson_quiz_meta( ) { |
|
955 | 955 | |
956 | - Sensei_Lesson::footer_quiz_call_to_action(); |
|
956 | + Sensei_Lesson::footer_quiz_call_to_action(); |
|
957 | 957 | |
958 | 958 | } // End sensei_lesson_quiz_meta() |
959 | 959 | |
@@ -979,38 +979,38 @@ discard block |
||
979 | 979 | </p> |
980 | 980 | <p class="course-excerpt"><?php the_excerpt(); ?></p> |
981 | 981 | <?php if ( 0 < $free_lesson_count ) { |
982 | - $free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes-sensei' ), $free_lesson_count ); ?> |
|
982 | + $free_lessons = sprintf( __( 'You can access %d of this course\'s lessons for free', 'woothemes-sensei' ), $free_lesson_count ); ?> |
|
983 | 983 | <p class="sensei-free-lessons"><a href="<?php echo get_permalink( $post_id ); ?>"><?php _e( 'Preview this course', 'woothemes-sensei' ) ?></a> - <?php echo $free_lessons; ?></p> |
984 | 984 | <?php } ?> |
985 | 985 | </section><?php |
986 | 986 | } // End sensei_course_archive_meta() |
987 | 987 | |
988 | - /** |
|
989 | - * @deprecated since 1.9.0 |
|
990 | - */ |
|
988 | + /** |
|
989 | + * @deprecated since 1.9.0 |
|
990 | + */ |
|
991 | 991 | public function sensei_single_main_content() { |
992 | - _deprecated_function('Woothemes_Sensei_Frontend::sensei_single_main_content', '1.9.0'); |
|
992 | + _deprecated_function('Woothemes_Sensei_Frontend::sensei_single_main_content', '1.9.0'); |
|
993 | 993 | } // End sensei_single_main_content() |
994 | 994 | |
995 | - /** |
|
996 | - * @deprecated since 1.9.0 |
|
997 | - */ |
|
995 | + /** |
|
996 | + * @deprecated since 1.9.0 |
|
997 | + */ |
|
998 | 998 | public function sensei_lesson_archive_main_content() { |
999 | - _deprecated_function('Sensei_Frontend::sensei_lesson_archive_main_content', '1.9.0', 'Please include loop-lesson.php directly'); |
|
999 | + _deprecated_function('Sensei_Frontend::sensei_lesson_archive_main_content', '1.9.0', 'Please include loop-lesson.php directly'); |
|
1000 | 1000 | } // End sensei_lesson_archive_main_content() |
1001 | 1001 | |
1002 | - /** |
|
1003 | - * @deprecated since 1.9.0 |
|
1004 | - */ |
|
1002 | + /** |
|
1003 | + * @deprecated since 1.9.0 |
|
1004 | + */ |
|
1005 | 1005 | public function sensei_message_archive_main_content() { |
1006 | 1006 | _deprecated_function( 'Sensei_Frontend::sensei_message_archive_main_content', 'This method is no longer needed' ); |
1007 | 1007 | } // End sensei_lesson_archive_main_content() |
1008 | 1008 | |
1009 | - /** |
|
1010 | - * @deprecated since 1.9.0 |
|
1011 | - */ |
|
1009 | + /** |
|
1010 | + * @deprecated since 1.9.0 |
|
1011 | + */ |
|
1012 | 1012 | public function sensei_no_permissions_main_content() { |
1013 | - _deprecated_function( 'Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed' ); |
|
1013 | + _deprecated_function( 'Sensei_Frontend::sensei_no_permissions_main_content', 'This method is no longer needed' ); |
|
1014 | 1014 | } // End sensei_no_permissions_main_content() |
1015 | 1015 | |
1016 | 1016 | public function sensei_course_category_main_content() { |
@@ -1058,7 +1058,7 @@ discard block |
||
1058 | 1058 | <div class="col-1"> |
1059 | 1059 | <?php |
1060 | 1060 | // output the actual form markup |
1061 | - Sensei_Templates::get_template( 'user/login-form.php'); |
|
1061 | + Sensei_Templates::get_template( 'user/login-form.php'); |
|
1062 | 1062 | ?> |
1063 | 1063 | </div> |
1064 | 1064 | |
@@ -1139,12 +1139,12 @@ discard block |
||
1139 | 1139 | |
1140 | 1140 | //if this is a paid course |
1141 | 1141 | if ( Sensei_WC::is_woocommerce_active() ) { |
1142 | - $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
1143 | - if ( 0 < $wc_post_id ) { |
|
1144 | - $preview_text = __( ' (Free Preview)', 'woothemes-sensei' ); |
|
1145 | - } // End If Statement |
|
1146 | - } |
|
1147 | - return $preview_text; |
|
1142 | + $wc_post_id = get_post_meta( $course_id, '_course_woocommerce_product', true ); |
|
1143 | + if ( 0 < $wc_post_id ) { |
|
1144 | + $preview_text = __( ' (Free Preview)', 'woothemes-sensei' ); |
|
1145 | + } // End If Statement |
|
1146 | + } |
|
1147 | + return $preview_text; |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | public function sensei_lesson_preview_title( $title = '', $id = 0 ) { |
@@ -1176,8 +1176,8 @@ discard block |
||
1176 | 1176 | $is_user_taking_course = Sensei_Utils::user_started_course( $post->ID, $current_user->ID ); |
1177 | 1177 | // Handle user starting the course |
1178 | 1178 | if ( isset( $_POST['course_start'] ) |
1179 | - && wp_verify_nonce( $_POST[ 'woothemes_sensei_start_course_noonce' ], 'woothemes_sensei_start_course_noonce' ) |
|
1180 | - && !$is_user_taking_course ) { |
|
1179 | + && wp_verify_nonce( $_POST[ 'woothemes_sensei_start_course_noonce' ], 'woothemes_sensei_start_course_noonce' ) |
|
1180 | + && !$is_user_taking_course ) { |
|
1181 | 1181 | |
1182 | 1182 | // Start the course |
1183 | 1183 | $activity_logged = Sensei_Utils::user_start_course( $current_user->ID, $post->ID ); |
@@ -1196,35 +1196,35 @@ discard block |
||
1196 | 1196 | } // End If Statement |
1197 | 1197 | } // End sensei_course_start() |
1198 | 1198 | |
1199 | - /** |
|
1200 | - * @deprecated since 1.9.0 |
|
1201 | - */ |
|
1199 | + /** |
|
1200 | + * @deprecated since 1.9.0 |
|
1201 | + */ |
|
1202 | 1202 | public function sensei_course_meta() { |
1203 | - _deprecated_function( 'Sensei_Frontend::sensei_course_meta', '1.9.0' , 'Sensei_Course::the_course_meta()' ); |
|
1204 | - Sensei()->course->the_course_meta( get_post() ); |
|
1203 | + _deprecated_function( 'Sensei_Frontend::sensei_course_meta', '1.9.0' , 'Sensei_Course::the_course_meta()' ); |
|
1204 | + Sensei()->course->the_course_meta( get_post() ); |
|
1205 | 1205 | } // End sensei_course_meta() |
1206 | 1206 | |
1207 | - /** |
|
1208 | - * @deprecated since 1.9.0 |
|
1209 | - */ |
|
1207 | + /** |
|
1208 | + * @deprecated since 1.9.0 |
|
1209 | + */ |
|
1210 | 1210 | public function sensei_course_meta_video() { |
1211 | - _deprecated_function( 'Sensei_Frontend::sensei_course_meta_video', '1.9.0' , 'Sensei_Course::the_course_video()' ); |
|
1212 | - Sensei_Course::the_course_video(); |
|
1211 | + _deprecated_function( 'Sensei_Frontend::sensei_course_meta_video', '1.9.0' , 'Sensei_Course::the_course_video()' ); |
|
1212 | + Sensei_Course::the_course_video(); |
|
1213 | 1213 | } // End sensei_course_meta_video() |
1214 | 1214 | |
1215 | - /** |
|
1216 | - * This function shows the WooCommerce cart notice if the user has |
|
1217 | - * added the current course to cart. It does not show if the user is already taking |
|
1218 | - * the course. |
|
1219 | - * |
|
1220 | - * @since 1.0.2 |
|
1221 | - * @return void; |
|
1222 | - */ |
|
1223 | - public function sensei_woocommerce_in_cart_message() { |
|
1215 | + /** |
|
1216 | + * This function shows the WooCommerce cart notice if the user has |
|
1217 | + * added the current course to cart. It does not show if the user is already taking |
|
1218 | + * the course. |
|
1219 | + * |
|
1220 | + * @since 1.0.2 |
|
1221 | + * @return void; |
|
1222 | + */ |
|
1223 | + public function sensei_woocommerce_in_cart_message() { |
|
1224 | 1224 | global $post, $woocommerce; |
1225 | 1225 | |
1226 | 1226 | $wc_post_id = absint( get_post_meta( $post->ID, '_course_woocommerce_product', true ) ); |
1227 | - $user_course_status_id = Sensei_Utils::user_started_course($post->ID , get_current_user_id() ); |
|
1227 | + $user_course_status_id = Sensei_Utils::user_started_course($post->ID , get_current_user_id() ); |
|
1228 | 1228 | if ( 0 < intval( $wc_post_id ) && ! $user_course_status_id ) { |
1229 | 1229 | |
1230 | 1230 | if ( Sensei_WC::is_product_in_cart( $wc_post_id ) ) { |
@@ -1272,7 +1272,7 @@ discard block |
||
1272 | 1272 | $item_id = $item['product_id']; |
1273 | 1273 | } |
1274 | 1274 | |
1275 | - if ( $item_id > 0 ) { |
|
1275 | + if ( $item_id > 0 ) { |
|
1276 | 1276 | |
1277 | 1277 | $user_id = get_post_meta( $order_id, '_customer_user', true ); |
1278 | 1278 | |
@@ -1352,15 +1352,15 @@ discard block |
||
1352 | 1352 | |
1353 | 1353 | $items = $order->get_items(); |
1354 | 1354 | foreach( $items as $item ) { |
1355 | - if (isset($item['variation_id']) && $item['variation_id'] > 0) { |
|
1356 | - $item_id = $item['variation_id']; |
|
1357 | - $product_type = 'variation'; |
|
1358 | - } else { |
|
1359 | - $item_id = $item['product_id']; |
|
1360 | - } |
|
1355 | + if (isset($item['variation_id']) && $item['variation_id'] > 0) { |
|
1356 | + $item_id = $item['variation_id']; |
|
1357 | + $product_type = 'variation'; |
|
1358 | + } else { |
|
1359 | + $item_id = $item['product_id']; |
|
1360 | + } |
|
1361 | 1361 | |
1362 | - $product_ids[] = $item_id; |
|
1363 | - } |
|
1362 | + $product_ids[] = $item_id; |
|
1363 | + } |
|
1364 | 1364 | |
1365 | 1365 | $order_ids[] = $post_id; |
1366 | 1366 | } |
@@ -1467,32 +1467,32 @@ discard block |
||
1467 | 1467 | |
1468 | 1468 | $items = $order->get_items(); |
1469 | 1469 | foreach( $items as $item ) { |
1470 | - $product = wc_get_product( $item['product_id'] ); |
|
1470 | + $product = wc_get_product( $item['product_id'] ); |
|
1471 | 1471 | |
1472 | - // handle product bundles |
|
1473 | - if( $product->is_type('bundle') ){ |
|
1472 | + // handle product bundles |
|
1473 | + if( $product->is_type('bundle') ){ |
|
1474 | 1474 | |
1475 | - $bundled_product = new WC_Product_Bundle( $product->id ); |
|
1476 | - $bundled_items = $bundled_product->get_bundled_items(); |
|
1475 | + $bundled_product = new WC_Product_Bundle( $product->id ); |
|
1476 | + $bundled_items = $bundled_product->get_bundled_items(); |
|
1477 | 1477 | |
1478 | - foreach( $bundled_items as $bundled_item ){ |
|
1478 | + foreach( $bundled_items as $bundled_item ){ |
|
1479 | 1479 | |
1480 | - if( $bundled_item->product_id == $course_product_id ) { |
|
1481 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
1482 | - return; |
|
1483 | - } |
|
1480 | + if( $bundled_item->product_id == $course_product_id ) { |
|
1481 | + Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
1482 | + return; |
|
1483 | + } |
|
1484 | 1484 | |
1485 | - } |
|
1485 | + } |
|
1486 | 1486 | |
1487 | - } else { |
|
1487 | + } else { |
|
1488 | 1488 | |
1489 | - // handle regular products |
|
1490 | - if( $item['product_id'] == $course_product_id ) { |
|
1491 | - Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
1492 | - return; |
|
1493 | - } |
|
1489 | + // handle regular products |
|
1490 | + if( $item['product_id'] == $course_product_id ) { |
|
1491 | + Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
1492 | + return; |
|
1493 | + } |
|
1494 | 1494 | |
1495 | - } |
|
1495 | + } |
|
1496 | 1496 | } |
1497 | 1497 | } |
1498 | 1498 | |
@@ -1523,21 +1523,21 @@ discard block |
||
1523 | 1523 | |
1524 | 1524 | //if not posted from the sensei login form let |
1525 | 1525 | // WordPress or any other party handle the failed request |
1526 | - if( ! isset( $_REQUEST['form'] ) || 'sensei-login' != $_REQUEST['form'] ){ |
|
1526 | + if( ! isset( $_REQUEST['form'] ) || 'sensei-login' != $_REQUEST['form'] ){ |
|
1527 | 1527 | |
1528 | - return ; |
|
1528 | + return ; |
|
1529 | 1529 | |
1530 | - } |
|
1530 | + } |
|
1531 | 1531 | |
1532 | - // Get the reffering page, where did the post submission come from? |
|
1533 | - $referrer = add_query_arg('login', false, $_SERVER['HTTP_REFERER']); |
|
1532 | + // Get the reffering page, where did the post submission come from? |
|
1533 | + $referrer = add_query_arg('login', false, $_SERVER['HTTP_REFERER']); |
|
1534 | 1534 | |
1535 | 1535 | // if there's a valid referrer, and it's not the default log-in screen |
1536 | - if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){ |
|
1537 | - // let's append some information (login=failed) to the URL for the theme to use |
|
1538 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1539 | - exit; |
|
1540 | - } |
|
1536 | + if(!empty($referrer) && !strstr($referrer,'wp-login') && !strstr($referrer,'wp-admin')){ |
|
1537 | + // let's append some information (login=failed) to the URL for the theme to use |
|
1538 | + wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1539 | + exit; |
|
1540 | + } |
|
1541 | 1541 | }// End sensei_login_fail_redirect_to_front_end_login |
1542 | 1542 | |
1543 | 1543 | /** |
@@ -1548,46 +1548,46 @@ discard block |
||
1548 | 1548 | function sensei_handle_login_request( ) { |
1549 | 1549 | |
1550 | 1550 | // Check that it is a sensei login request and if it has a valid nonce |
1551 | - if( isset( $_REQUEST['form'] ) && 'sensei-login' == $_REQUEST['form'] ) { |
|
1551 | + if( isset( $_REQUEST['form'] ) && 'sensei-login' == $_REQUEST['form'] ) { |
|
1552 | 1552 | |
1553 | - // Validate the login request nonce |
|
1554 | - if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){ |
|
1555 | - return; |
|
1556 | - } |
|
1553 | + // Validate the login request nonce |
|
1554 | + if( !wp_verify_nonce( $_REQUEST['_wpnonce'], 'sensei-login' ) ){ |
|
1555 | + return; |
|
1556 | + } |
|
1557 | 1557 | |
1558 | - //get the page where the sensei log form is located |
|
1559 | - $referrer = $_REQUEST['_wp_http_referer']; |
|
1560 | - //$redirect = $_REQUEST['_sensei_redirect']; |
|
1558 | + //get the page where the sensei log form is located |
|
1559 | + $referrer = $_REQUEST['_wp_http_referer']; |
|
1560 | + //$redirect = $_REQUEST['_sensei_redirect']; |
|
1561 | 1561 | |
1562 | - if ( ( isset( $_REQUEST['log'] ) && !empty( $_REQUEST['log'] ) ) |
|
1563 | - && ( isset( $_REQUEST['pwd'] ) && !empty( $_REQUEST['pwd'] ) ) ){ |
|
1562 | + if ( ( isset( $_REQUEST['log'] ) && !empty( $_REQUEST['log'] ) ) |
|
1563 | + && ( isset( $_REQUEST['pwd'] ) && !empty( $_REQUEST['pwd'] ) ) ){ |
|
1564 | 1564 | |
1565 | - // when the user has entered a password or username do the sensei login |
|
1566 | - $creds = array(); |
|
1565 | + // when the user has entered a password or username do the sensei login |
|
1566 | + $creds = array(); |
|
1567 | 1567 | |
1568 | - // check if the requests login is an email address |
|
1569 | - if( is_email( trim( $_REQUEST['log'] ) ) ){ |
|
1570 | - // query wordpress for the users details |
|
1571 | - $user = get_user_by( 'email', sanitize_email( $_REQUEST['log'] ) ); |
|
1568 | + // check if the requests login is an email address |
|
1569 | + if( is_email( trim( $_REQUEST['log'] ) ) ){ |
|
1570 | + // query wordpress for the users details |
|
1571 | + $user = get_user_by( 'email', sanitize_email( $_REQUEST['log'] ) ); |
|
1572 | 1572 | |
1573 | - // validate the user object |
|
1574 | - if( !$user ){ |
|
1573 | + // validate the user object |
|
1574 | + if( !$user ){ |
|
1575 | 1575 | |
1576 | - // the email doesnt exist |
|
1577 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1578 | - exit; |
|
1576 | + // the email doesnt exist |
|
1577 | + wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1578 | + exit; |
|
1579 | 1579 | |
1580 | - } |
|
1580 | + } |
|
1581 | 1581 | |
1582 | - //assigne the username to the creds array for further processing |
|
1583 | - $creds['user_login'] = $user->user_login ; |
|
1582 | + //assigne the username to the creds array for further processing |
|
1583 | + $creds['user_login'] = $user->user_login ; |
|
1584 | 1584 | |
1585 | - }else{ |
|
1585 | + }else{ |
|
1586 | 1586 | |
1587 | - // process this as a default username login |
|
1588 | - $creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ; |
|
1587 | + // process this as a default username login |
|
1588 | + $creds['user_login'] = sanitize_text_field( $_REQUEST['log'] ) ; |
|
1589 | 1589 | |
1590 | - } |
|
1590 | + } |
|
1591 | 1591 | |
1592 | 1592 | // get setup the rest of the creds array |
1593 | 1593 | $creds['user_password'] = sanitize_text_field( $_REQUEST['pwd'] ); |
@@ -1597,42 +1597,42 @@ discard block |
||
1597 | 1597 | $user = wp_signon( $creds, false ); |
1598 | 1598 | |
1599 | 1599 | if ( is_wp_error($user) ){ // on login failure |
1600 | - wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1601 | - exit; |
|
1600 | + wp_redirect( esc_url_raw( add_query_arg('login', 'failed', $referrer) ) ); |
|
1601 | + exit; |
|
1602 | 1602 | }else{ // on login success |
1603 | 1603 | |
1604 | 1604 | /** |
1605 | - * change the redirect url programatically |
|
1606 | - * |
|
1607 | - * @since 1.6.1 |
|
1608 | - * |
|
1609 | - * @param string $referrer the page where the current url wheresensei login form was posted from |
|
1610 | - */ |
|
1605 | + * change the redirect url programatically |
|
1606 | + * |
|
1607 | + * @since 1.6.1 |
|
1608 | + * |
|
1609 | + * @param string $referrer the page where the current url wheresensei login form was posted from |
|
1610 | + */ |
|
1611 | 1611 | |
1612 | 1612 | $success_redirect_url = apply_filters('sesei_login_success_redirect_url', remove_query_arg( 'login', $referrer ) ); |
1613 | 1613 | |
1614 | 1614 | wp_redirect( esc_url_raw( $success_redirect_url ) ); |
1615 | - exit; |
|
1615 | + exit; |
|
1616 | 1616 | |
1617 | 1617 | } // end is_wp_error($user) |
1618 | 1618 | |
1619 | - }else{ // if username or password is empty |
|
1619 | + }else{ // if username or password is empty |
|
1620 | 1620 | |
1621 | - wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) ); |
|
1622 | - exit; |
|
1621 | + wp_redirect( esc_url_raw( add_query_arg('login', 'emptyfields', $referrer) ) ); |
|
1622 | + exit; |
|
1623 | 1623 | |
1624 | - } // end if username $_REQUEST['log'] and password $_REQUEST['pwd'] is empty |
|
1624 | + } // end if username $_REQUEST['log'] and password $_REQUEST['pwd'] is empty |
|
1625 | 1625 | |
1626 | - }elseif( ( isset( $_GET['login'] ) ) ) { |
|
1627 | - // else if this request is a redircect from a previously faile login request |
|
1628 | - $this->login_message_process(); |
|
1626 | + }elseif( ( isset( $_GET['login'] ) ) ) { |
|
1627 | + // else if this request is a redircect from a previously faile login request |
|
1628 | + $this->login_message_process(); |
|
1629 | 1629 | |
1630 | 1630 | //exit the handle login request function |
1631 | 1631 | return; |
1632 | - } |
|
1632 | + } |
|
1633 | 1633 | |
1634 | - // if none of the above |
|
1635 | - return; |
|
1634 | + // if none of the above |
|
1635 | + return; |
|
1636 | 1636 | |
1637 | 1637 | } // End sensei_login_fail_redirect_to_front_end_login |
1638 | 1638 | |
@@ -1735,7 +1735,7 @@ discard block |
||
1735 | 1735 | */ |
1736 | 1736 | public function login_message_process(){ |
1737 | 1737 | |
1738 | - // setup the message variables |
|
1738 | + // setup the message variables |
|
1739 | 1739 | $message = ''; |
1740 | 1740 | |
1741 | 1741 | //only output message if the url contains login=failed and login=emptyfields |
@@ -1754,22 +1754,22 @@ discard block |
||
1754 | 1754 | }// end login_message_process |
1755 | 1755 | |
1756 | 1756 | |
1757 | - /** |
|
1758 | - * sensei_show_admin_bar(). Use WooCommerce filter |
|
1759 | - * to show admin bar to Teachers as well. |
|
1760 | - * |
|
1761 | - * @return void redirect |
|
1762 | - * |
|
1763 | - */ |
|
1764 | - public function sensei_show_admin_bar () { |
|
1757 | + /** |
|
1758 | + * sensei_show_admin_bar(). Use WooCommerce filter |
|
1759 | + * to show admin bar to Teachers as well. |
|
1760 | + * |
|
1761 | + * @return void redirect |
|
1762 | + * |
|
1763 | + */ |
|
1764 | + public function sensei_show_admin_bar () { |
|
1765 | 1765 | |
1766 | - if (current_user_can('edit_courses')) { |
|
1766 | + if (current_user_can('edit_courses')) { |
|
1767 | 1767 | |
1768 | - add_filter( 'woocommerce_disable_admin_bar', '__return_false', 10, 1); |
|
1768 | + add_filter( 'woocommerce_disable_admin_bar', '__return_false', 10, 1); |
|
1769 | 1769 | |
1770 | - } |
|
1770 | + } |
|
1771 | 1771 | |
1772 | - } |
|
1772 | + } |
|
1773 | 1773 | |
1774 | 1774 | } // End Class |
1775 | 1775 |
@@ -21,6 +21,7 @@ |
||
21 | 21 | /** |
22 | 22 | * Constructor |
23 | 23 | * @since 1.6.0 |
24 | + * @param string $file |
|
24 | 25 | * @return void |
25 | 26 | */ |
26 | 27 | public function __construct ( $file ) { |
@@ -1,5 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
5 | +// Exit if accessed directly |
|
3 | 6 | |
4 | 7 | /** |
5 | 8 | * Sensei Learners Class |
@@ -342,7 +345,7 @@ discard block |
||
342 | 345 | |
343 | 346 | $name = $full_name; |
344 | 347 | |
345 | - }else{ |
|
348 | + } else{ |
|
346 | 349 | |
347 | 350 | $name = $full_name . ' ['. $user->display_name .']'; |
348 | 351 | |
@@ -359,11 +362,17 @@ discard block |
||
359 | 362 | |
360 | 363 | $result = false; |
361 | 364 | |
362 | - if( ! isset( $_POST['add_learner_submit'] ) ) return $result; |
|
365 | + if( ! isset( $_POST['add_learner_submit'] ) ) { |
|
366 | + return $result; |
|
367 | + } |
|
363 | 368 | |
364 | - if ( ! isset( $_POST['add_learner_nonce'] ) || ! wp_verify_nonce( $_POST['add_learner_nonce'], 'add_learner_to_sensei' ) ) return $result; |
|
369 | + if ( ! isset( $_POST['add_learner_nonce'] ) || ! wp_verify_nonce( $_POST['add_learner_nonce'], 'add_learner_to_sensei' ) ) { |
|
370 | + return $result; |
|
371 | + } |
|
365 | 372 | |
366 | - if( ( ! isset( $_POST['add_user_id'] ) || '' == $_POST['add_user_id'] ) || ! isset( $_POST['add_post_type'] ) || ! isset( $_POST['add_course_id'] ) || ! isset( $_POST['add_lesson_id'] ) ) return $result; |
|
373 | + if( ( ! isset( $_POST['add_user_id'] ) || '' == $_POST['add_user_id'] ) || ! isset( $_POST['add_post_type'] ) || ! isset( $_POST['add_course_id'] ) || ! isset( $_POST['add_lesson_id'] ) ) { |
|
374 | + return $result; |
|
375 | + } |
|
367 | 376 | |
368 | 377 | $post_type = $_POST['add_post_type']; |
369 | 378 | $user_id = absint( $_POST['add_user_id'] ); |
@@ -78,16 +78,16 @@ discard block |
||
78 | 78 | |
79 | 79 | // Load Learners JS |
80 | 80 | wp_enqueue_script( 'sensei-learners-general', |
81 | - Sensei()->plugin_url . 'assets/js/learners-general' . $suffix . '.js', |
|
82 | - array('jquery','select2','sensei-chosen-ajax' ), Sensei()->version, true ); |
|
81 | + Sensei()->plugin_url . 'assets/js/learners-general' . $suffix . '.js', |
|
82 | + array('jquery','select2','sensei-chosen-ajax' ), Sensei()->version, true ); |
|
83 | 83 | |
84 | 84 | $data = array( |
85 | 85 | 'remove_generic_confirm' => __( 'Are you sure you want to remove this user?', 'woothemes-sensei' ), |
86 | 86 | 'remove_from_lesson_confirm' => __( 'Are you sure you want to remove the user from this lesson?', 'woothemes-sensei' ), |
87 | 87 | 'remove_from_course_confirm' => __( 'Are you sure you want to remove the user from this course?', 'woothemes-sensei' ), |
88 | 88 | 'remove_user_from_post_nonce' => wp_create_nonce( 'remove_user_from_post_nonce' ), |
89 | - 'search_users_nonce' => wp_create_nonce( 'search-users' ), |
|
90 | - 'selectplaceholder'=> __( 'Select Learner', 'woothemes-sensei' ) |
|
89 | + 'search_users_nonce' => wp_create_nonce( 'search-users' ), |
|
90 | + 'selectplaceholder'=> __( 'Select Learner', 'woothemes-sensei' ) |
|
91 | 91 | ); |
92 | 92 | |
93 | 93 | wp_localize_script( 'sensei-learners-general', 'woo_learners_general_data', $data ); |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | /** |
187 | 187 | * learners_headers outputs Learners general headers |
188 | 188 | * @since 1.6.0 |
189 | - * @param array $args |
|
189 | + * @param array $args |
|
190 | 190 | * @return void |
191 | 191 | */ |
192 | 192 | public function learners_headers( $args = array( 'nav' => 'default' ) ) { |
@@ -281,7 +281,7 @@ discard block |
||
281 | 281 | |
282 | 282 | case 'course': |
283 | 283 | |
284 | - $removed = Sensei_Utils::sensei_remove_user_from_course( $post_id, $user_id ); |
|
284 | + $removed = Sensei_Utils::sensei_remove_user_from_course( $post_id, $user_id ); |
|
285 | 285 | |
286 | 286 | break; |
287 | 287 | |
@@ -328,19 +328,19 @@ discard block |
||
328 | 328 | |
329 | 329 | if ( $users ) { |
330 | 330 | foreach ( $users as $user ) { |
331 | - $full_name = Sensei_Learner::get_full_name( $user->ID ); |
|
331 | + $full_name = Sensei_Learner::get_full_name( $user->ID ); |
|
332 | 332 | |
333 | - if( trim($user->display_name ) == trim( $full_name ) ){ |
|
333 | + if( trim($user->display_name ) == trim( $full_name ) ){ |
|
334 | 334 | |
335 | - $name = $full_name; |
|
335 | + $name = $full_name; |
|
336 | 336 | |
337 | - }else{ |
|
337 | + }else{ |
|
338 | 338 | |
339 | - $name = $full_name . ' ['. $user->display_name .']'; |
|
339 | + $name = $full_name . ' ['. $user->display_name .']'; |
|
340 | 340 | |
341 | - } |
|
341 | + } |
|
342 | 342 | |
343 | - $found_users[ $user->ID ] = $name . ' (#' . $user->ID . ' – ' . sanitize_email( $user->user_email ) . ')'; |
|
343 | + $found_users[ $user->ID ] = $name . ' (#' . $user->ID . ' – ' . sanitize_email( $user->user_email ) . ')'; |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
@@ -384,7 +384,7 @@ discard block |
||
384 | 384 | break; |
385 | 385 | |
386 | 386 | case 'lesson': |
387 | - $lesson_id = absint( $_POST['add_lesson_id'] ); |
|
387 | + $lesson_id = absint( $_POST['add_lesson_id'] ); |
|
388 | 388 | $complete = false; |
389 | 389 | if( isset( $_POST['add_complete_lesson'] ) && 'yes' == $_POST['add_complete_lesson'] ) { |
390 | 390 | $complete = true; |
@@ -444,23 +444,23 @@ discard block |
||
444 | 444 | } |
445 | 445 | } |
446 | 446 | |
447 | - /** |
|
448 | - * Return the full name and surname or the display name of the user. |
|
449 | - * |
|
450 | - * The user must have both name and surname otherwise display name will be returned. |
|
451 | - * |
|
452 | - * @deprecated since 1.9.0 use Se |
|
453 | - * @since 1.8.0 |
|
454 | - * |
|
455 | - * @param int $user_id | bool false for an invalid $user_id |
|
456 | - * |
|
457 | - * @return string $full_name |
|
458 | - */ |
|
459 | - public function get_learner_full_name( $user_id ){ |
|
460 | - |
|
461 | - return Sensei_Learner::get_full_name( $user_id ); |
|
462 | - |
|
463 | - } // end get_learner_full_name |
|
447 | + /** |
|
448 | + * Return the full name and surname or the display name of the user. |
|
449 | + * |
|
450 | + * The user must have both name and surname otherwise display name will be returned. |
|
451 | + * |
|
452 | + * @deprecated since 1.9.0 use Se |
|
453 | + * @since 1.8.0 |
|
454 | + * |
|
455 | + * @param int $user_id | bool false for an invalid $user_id |
|
456 | + * |
|
457 | + * @return string $full_name |
|
458 | + */ |
|
459 | + public function get_learner_full_name( $user_id ){ |
|
460 | + |
|
461 | + return Sensei_Learner::get_full_name( $user_id ); |
|
462 | + |
|
463 | + } // end get_learner_full_name |
|
464 | 464 | |
465 | 465 | } // End Class |
466 | 466 |
@@ -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 Class |
@@ -22,30 +22,30 @@ discard block |
||
22 | 22 | * @since 1.6.0 |
23 | 23 | * @return void |
24 | 24 | */ |
25 | - public function __construct ( $file ) { |
|
26 | - $this->name = __( 'Learner Management', 'woothemes-sensei' );; |
|
25 | + public function __construct($file) { |
|
26 | + $this->name = __('Learner Management', 'woothemes-sensei'); ; |
|
27 | 27 | $this->file = $file; |
28 | 28 | $this->page_slug = 'sensei_learners'; |
29 | 29 | |
30 | 30 | // Admin functions |
31 | - if ( is_admin() ) { |
|
32 | - add_action( 'admin_menu', array( $this, 'learners_admin_menu' ), 30); |
|
33 | - add_action( 'learners_wrapper_container', array( $this, 'wrapper_container' ) ); |
|
34 | - if ( isset( $_GET['page'] ) && ( $_GET['page'] == $this->page_slug ) ) { |
|
35 | - add_action( 'admin_print_scripts', array( $this, 'enqueue_scripts' ) ); |
|
36 | - add_action( 'admin_print_styles', array( $this, 'enqueue_styles' ) ); |
|
31 | + if (is_admin()) { |
|
32 | + add_action('admin_menu', array($this, 'learners_admin_menu'), 30); |
|
33 | + add_action('learners_wrapper_container', array($this, 'wrapper_container')); |
|
34 | + if (isset($_GET['page']) && ($_GET['page'] == $this->page_slug)) { |
|
35 | + add_action('admin_print_scripts', array($this, 'enqueue_scripts')); |
|
36 | + add_action('admin_print_styles', array($this, 'enqueue_styles')); |
|
37 | 37 | } |
38 | 38 | |
39 | - add_action( 'admin_init', array( $this, 'add_new_learners' ) ); |
|
39 | + add_action('admin_init', array($this, 'add_new_learners')); |
|
40 | 40 | |
41 | - add_action( 'admin_notices', array( $this, 'add_learner_notices' ) ); |
|
41 | + add_action('admin_notices', array($this, 'add_learner_notices')); |
|
42 | 42 | } // End If Statement |
43 | 43 | |
44 | 44 | // Ajax functions |
45 | - if ( is_admin() ) { |
|
46 | - add_action( 'wp_ajax_get_redirect_url_learners', array( $this, 'get_redirect_url' ) ); |
|
47 | - add_action( 'wp_ajax_remove_user_from_post', array( $this, 'remove_user_from_post' ) ); |
|
48 | - add_action( 'wp_ajax_sensei_json_search_users', array( $this, 'json_search_users' ) ); |
|
45 | + if (is_admin()) { |
|
46 | + add_action('wp_ajax_get_redirect_url_learners', array($this, 'get_redirect_url')); |
|
47 | + add_action('wp_ajax_remove_user_from_post', array($this, 'remove_user_from_post')); |
|
48 | + add_action('wp_ajax_sensei_json_search_users', array($this, 'json_search_users')); |
|
49 | 49 | } |
50 | 50 | } // End __construct() |
51 | 51 | |
@@ -58,8 +58,8 @@ discard block |
||
58 | 58 | public function learners_admin_menu() { |
59 | 59 | global $menu; |
60 | 60 | |
61 | - if ( current_user_can( 'manage_sensei_grades' ) ) { |
|
62 | - $learners_page = add_submenu_page( 'sensei', $this->name, $this->name, 'manage_sensei_grades', $this->page_slug, array( $this, 'learners_page' ) ); |
|
61 | + if (current_user_can('manage_sensei_grades')) { |
|
62 | + $learners_page = add_submenu_page('sensei', $this->name, $this->name, 'manage_sensei_grades', $this->page_slug, array($this, 'learners_page')); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | } // End learners_admin_menu() |
@@ -72,25 +72,25 @@ discard block |
||
72 | 72 | * @since 1.6.0 |
73 | 73 | * @return void |
74 | 74 | */ |
75 | - public function enqueue_scripts () { |
|
75 | + public function enqueue_scripts() { |
|
76 | 76 | |
77 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
77 | + $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; |
|
78 | 78 | |
79 | 79 | // Load Learners JS |
80 | - wp_enqueue_script( 'sensei-learners-general', |
|
81 | - Sensei()->plugin_url . 'assets/js/learners-general' . $suffix . '.js', |
|
82 | - array('jquery','select2','sensei-chosen-ajax' ), Sensei()->version, true ); |
|
80 | + wp_enqueue_script('sensei-learners-general', |
|
81 | + Sensei()->plugin_url.'assets/js/learners-general'.$suffix.'.js', |
|
82 | + array('jquery', 'select2', 'sensei-chosen-ajax'), Sensei()->version, true); |
|
83 | 83 | |
84 | 84 | $data = array( |
85 | - 'remove_generic_confirm' => __( 'Are you sure you want to remove this user?', 'woothemes-sensei' ), |
|
86 | - 'remove_from_lesson_confirm' => __( 'Are you sure you want to remove the user from this lesson?', 'woothemes-sensei' ), |
|
87 | - 'remove_from_course_confirm' => __( 'Are you sure you want to remove the user from this course?', 'woothemes-sensei' ), |
|
88 | - 'remove_user_from_post_nonce' => wp_create_nonce( 'remove_user_from_post_nonce' ), |
|
89 | - 'search_users_nonce' => wp_create_nonce( 'search-users' ), |
|
90 | - 'selectplaceholder'=> __( 'Select Learner', 'woothemes-sensei' ) |
|
85 | + 'remove_generic_confirm' => __('Are you sure you want to remove this user?', 'woothemes-sensei'), |
|
86 | + 'remove_from_lesson_confirm' => __('Are you sure you want to remove the user from this lesson?', 'woothemes-sensei'), |
|
87 | + 'remove_from_course_confirm' => __('Are you sure you want to remove the user from this course?', 'woothemes-sensei'), |
|
88 | + 'remove_user_from_post_nonce' => wp_create_nonce('remove_user_from_post_nonce'), |
|
89 | + 'search_users_nonce' => wp_create_nonce('search-users'), |
|
90 | + 'selectplaceholder'=> __('Select Learner', 'woothemes-sensei') |
|
91 | 91 | ); |
92 | 92 | |
93 | - wp_localize_script( 'sensei-learners-general', 'woo_learners_general_data', $data ); |
|
93 | + wp_localize_script('sensei-learners-general', 'woo_learners_general_data', $data); |
|
94 | 94 | |
95 | 95 | } // End enqueue_scripts() |
96 | 96 | |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | * @since 1.6.0 |
103 | 103 | * @return void |
104 | 104 | */ |
105 | - public function enqueue_styles () { |
|
105 | + public function enqueue_styles() { |
|
106 | 106 | |
107 | - wp_enqueue_style( 'woothemes-sensei-admin' ); |
|
107 | + wp_enqueue_style('woothemes-sensei-admin'); |
|
108 | 108 | |
109 | 109 | } // End enqueue_styles() |
110 | 110 | |
@@ -116,11 +116,11 @@ discard block |
||
116 | 116 | public function load_data_table_files() { |
117 | 117 | |
118 | 118 | // Load Learners Classes |
119 | - $classes_to_load = array( 'list-table', |
|
119 | + $classes_to_load = array('list-table', |
|
120 | 120 | 'learners-main', |
121 | 121 | ); |
122 | - foreach ( $classes_to_load as $class_file ) { |
|
123 | - Sensei()->load_class( $class_file ); |
|
122 | + foreach ($classes_to_load as $class_file) { |
|
123 | + Sensei()->load_class($class_file); |
|
124 | 124 | } // End For Loop |
125 | 125 | |
126 | 126 | } // End load_data_table_files() |
@@ -133,15 +133,15 @@ discard block |
||
133 | 133 | * @param undefined $optional_data optional constructor arguments |
134 | 134 | * @return object class instance object |
135 | 135 | */ |
136 | - public function load_data_object( $name = '', $data = 0, $optional_data = null ) { |
|
136 | + public function load_data_object($name = '', $data = 0, $optional_data = null) { |
|
137 | 137 | // Load Analysis data |
138 | - $object_name = 'WooThemes_Sensei_Learners_' . $name; |
|
139 | - if ( is_null($optional_data) ) { |
|
140 | - $sensei_learners_object = new $object_name( $data ); |
|
138 | + $object_name = 'WooThemes_Sensei_Learners_'.$name; |
|
139 | + if (is_null($optional_data)) { |
|
140 | + $sensei_learners_object = new $object_name($data); |
|
141 | 141 | } else { |
142 | - $sensei_learners_object = new $object_name( $data, $optional_data ); |
|
142 | + $sensei_learners_object = new $object_name($data, $optional_data); |
|
143 | 143 | } // End If Statement |
144 | - if ( 'Main' == $name ) { |
|
144 | + if ('Main' == $name) { |
|
145 | 145 | $sensei_learners_object->prepare_items(); |
146 | 146 | } // End If Statement |
147 | 147 | return $sensei_learners_object; |
@@ -158,16 +158,16 @@ discard block |
||
158 | 158 | // Load Learners data |
159 | 159 | $course_id = 0; |
160 | 160 | $lesson_id = 0; |
161 | - if( isset( $_GET['course_id'] ) ) { |
|
162 | - $course_id = intval( $_GET['course_id'] ); |
|
161 | + if (isset($_GET['course_id'])) { |
|
162 | + $course_id = intval($_GET['course_id']); |
|
163 | 163 | } |
164 | - if( isset( $_GET['lesson_id'] ) ) { |
|
165 | - $lesson_id = intval( $_GET['lesson_id'] ); |
|
164 | + if (isset($_GET['lesson_id'])) { |
|
165 | + $lesson_id = intval($_GET['lesson_id']); |
|
166 | 166 | } |
167 | - $sensei_learners_main = $this->load_data_object( 'Main', $course_id, $lesson_id ); |
|
167 | + $sensei_learners_main = $this->load_data_object('Main', $course_id, $lesson_id); |
|
168 | 168 | // Wrappers |
169 | - do_action( 'learners_before_container' ); |
|
170 | - do_action( 'learners_wrapper_container', 'top' ); |
|
169 | + do_action('learners_before_container'); |
|
170 | + do_action('learners_wrapper_container', 'top'); |
|
171 | 171 | $this->learners_headers(); |
172 | 172 | ?> |
173 | 173 | <div id="poststuff" class="sensei-learners-wrap"> |
@@ -175,12 +175,12 @@ discard block |
||
175 | 175 | <?php $sensei_learners_main->display(); ?> |
176 | 176 | </div> |
177 | 177 | <div class="sensei-learners-extra"> |
178 | - <?php do_action( 'sensei_learners_extra' ); ?> |
|
178 | + <?php do_action('sensei_learners_extra'); ?> |
|
179 | 179 | </div> |
180 | 180 | </div> |
181 | 181 | <?php |
182 | - do_action( 'learners_wrapper_container', 'bottom' ); |
|
183 | - do_action( 'learners_after_container' ); |
|
182 | + do_action('learners_wrapper_container', 'bottom'); |
|
183 | + do_action('learners_after_container'); |
|
184 | 184 | } // End learners_default_view() |
185 | 185 | |
186 | 186 | /** |
@@ -189,14 +189,14 @@ discard block |
||
189 | 189 | * @param array $args |
190 | 190 | * @return void |
191 | 191 | */ |
192 | - public function learners_headers( $args = array( 'nav' => 'default' ) ) { |
|
192 | + public function learners_headers($args = array('nav' => 'default')) { |
|
193 | 193 | |
194 | - $function = 'learners_' . $args['nav'] . '_nav'; |
|
194 | + $function = 'learners_'.$args['nav'].'_nav'; |
|
195 | 195 | $this->$function(); |
196 | 196 | ?> |
197 | - <p class="powered-by-woo"><?php _e( 'Powered by', 'woothemes-sensei' ); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p> |
|
197 | + <p class="powered-by-woo"><?php _e('Powered by', 'woothemes-sensei'); ?><a href="http://www.woothemes.com/" title="WooThemes"><img src="<?php echo Sensei()->plugin_url; ?>assets/images/woothemes.png" alt="WooThemes" /></a></p> |
|
198 | 198 | <?php |
199 | - do_action( 'sensei_learners_after_headers' ); |
|
199 | + do_action('sensei_learners_after_headers'); |
|
200 | 200 | |
201 | 201 | } // End learners_headers() |
202 | 202 | |
@@ -206,10 +206,10 @@ discard block |
||
206 | 206 | * @param $which string |
207 | 207 | * @return void |
208 | 208 | */ |
209 | - public function wrapper_container( $which ) { |
|
210 | - if ( 'top' == $which ) { |
|
209 | + public function wrapper_container($which) { |
|
210 | + if ('top' == $which) { |
|
211 | 211 | ?><div id="woothemes-sensei" class="wrap woothemes-sensei"><?php |
212 | - } elseif ( 'bottom' == $which ) { |
|
212 | + } elseif ('bottom' == $which) { |
|
213 | 213 | ?></div><!--/#woothemes-sensei--><?php |
214 | 214 | } // End If Statement |
215 | 215 | } // End wrapper_container() |
@@ -220,18 +220,18 @@ discard block |
||
220 | 220 | * @return void |
221 | 221 | */ |
222 | 222 | public function learners_default_nav() { |
223 | - $title = sprintf( '<a href="%s">%s</a>', esc_url( add_query_arg( array( 'page' => $this->page_slug ), admin_url( 'admin.php' ) ) ), esc_html( $this->name ) ); |
|
224 | - if ( isset( $_GET['course_id'] ) ) { |
|
225 | - $course_id = intval( $_GET['course_id'] ); |
|
226 | - $url = add_query_arg( array( 'page' => $this->page_slug, 'course_id' => $course_id, 'view' => 'learners' ), admin_url( 'admin.php' ) ); |
|
227 | - $title .= sprintf( ' <span class="course-title">> <a href="%s">%s</a></span>', esc_url( $url ), get_the_title( $course_id ) ); |
|
223 | + $title = sprintf('<a href="%s">%s</a>', esc_url(add_query_arg(array('page' => $this->page_slug), admin_url('admin.php'))), esc_html($this->name)); |
|
224 | + if (isset($_GET['course_id'])) { |
|
225 | + $course_id = intval($_GET['course_id']); |
|
226 | + $url = add_query_arg(array('page' => $this->page_slug, 'course_id' => $course_id, 'view' => 'learners'), admin_url('admin.php')); |
|
227 | + $title .= sprintf(' <span class="course-title">> <a href="%s">%s</a></span>', esc_url($url), get_the_title($course_id)); |
|
228 | 228 | } |
229 | - if ( isset( $_GET['lesson_id'] ) ) { |
|
230 | - $lesson_id = intval( $_GET['lesson_id'] ); |
|
231 | - $title .= ' <span class="lesson-title">> ' . get_the_title( intval( $lesson_id ) ) . '</span>'; |
|
229 | + if (isset($_GET['lesson_id'])) { |
|
230 | + $lesson_id = intval($_GET['lesson_id']); |
|
231 | + $title .= ' <span class="lesson-title">> '.get_the_title(intval($lesson_id)).'</span>'; |
|
232 | 232 | } |
233 | 233 | ?> |
234 | - <h2><?php echo apply_filters( 'sensei_learners_nav_title', $title ); ?></h2> |
|
234 | + <h2><?php echo apply_filters('sensei_learners_nav_title', $title); ?></h2> |
|
235 | 235 | <?php |
236 | 236 | } // End learners_default_nav() |
237 | 237 | |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | // Parse POST data |
241 | 241 | $data = $_POST['data']; |
242 | 242 | $course_data = array(); |
243 | - parse_str( $data, $course_data ); |
|
243 | + parse_str($data, $course_data); |
|
244 | 244 | |
245 | - $course_cat = intval( $course_data['course_cat'] ); |
|
245 | + $course_cat = intval($course_data['course_cat']); |
|
246 | 246 | |
247 | - $redirect_url = apply_filters( 'sensei_ajax_redirect_url', add_query_arg( array( 'page' => $this->page_slug, 'course_cat' => $course_cat ), admin_url( 'admin.php' ) ) ); |
|
247 | + $redirect_url = apply_filters('sensei_ajax_redirect_url', add_query_arg(array('page' => $this->page_slug, 'course_cat' => $course_cat), admin_url('admin.php'))); |
|
248 | 248 | |
249 | - echo esc_url_raw( $redirect_url ); |
|
249 | + echo esc_url_raw($redirect_url); |
|
250 | 250 | die(); |
251 | 251 | } |
252 | 252 | |
@@ -257,157 +257,157 @@ discard block |
||
257 | 257 | |
258 | 258 | // Security check |
259 | 259 | $nonce = ''; |
260 | - if ( isset($_POST['remove_user_from_post_nonce']) ) { |
|
261 | - $nonce = esc_html( $_POST['remove_user_from_post_nonce'] ); |
|
260 | + if (isset($_POST['remove_user_from_post_nonce'])) { |
|
261 | + $nonce = esc_html($_POST['remove_user_from_post_nonce']); |
|
262 | 262 | } |
263 | - if ( ! wp_verify_nonce( $nonce, 'remove_user_from_post_nonce' ) ) { |
|
264 | - die( $return ); |
|
263 | + if ( ! wp_verify_nonce($nonce, 'remove_user_from_post_nonce')) { |
|
264 | + die($return); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | // Parse POST data |
268 | 268 | $data = $_POST['data']; |
269 | 269 | $action_data = array(); |
270 | - parse_str( $data, $action_data ); |
|
270 | + parse_str($data, $action_data); |
|
271 | 271 | |
272 | - if( $action_data['user_id'] && $action_data['post_id'] && $action_data['post_type'] ) { |
|
272 | + if ($action_data['user_id'] && $action_data['post_id'] && $action_data['post_type']) { |
|
273 | 273 | |
274 | - $user_id = intval( $action_data['user_id'] ); |
|
275 | - $post_id = intval( $action_data['post_id'] ); |
|
276 | - $post_type = sanitize_text_field( $action_data['post_type'] ); |
|
274 | + $user_id = intval($action_data['user_id']); |
|
275 | + $post_id = intval($action_data['post_id']); |
|
276 | + $post_type = sanitize_text_field($action_data['post_type']); |
|
277 | 277 | |
278 | - $user = get_userdata( $user_id ); |
|
278 | + $user = get_userdata($user_id); |
|
279 | 279 | |
280 | - switch( $post_type ) { |
|
280 | + switch ($post_type) { |
|
281 | 281 | |
282 | 282 | case 'course': |
283 | 283 | |
284 | - $removed = Sensei_Utils::sensei_remove_user_from_course( $post_id, $user_id ); |
|
284 | + $removed = Sensei_Utils::sensei_remove_user_from_course($post_id, $user_id); |
|
285 | 285 | |
286 | 286 | break; |
287 | 287 | |
288 | 288 | case 'lesson': |
289 | 289 | |
290 | - $removed = Sensei_Utils::sensei_remove_user_from_lesson( $post_id, $user_id ); |
|
290 | + $removed = Sensei_Utils::sensei_remove_user_from_lesson($post_id, $user_id); |
|
291 | 291 | |
292 | 292 | break; |
293 | 293 | |
294 | 294 | } |
295 | 295 | |
296 | - if( $removed ) { |
|
296 | + if ($removed) { |
|
297 | 297 | $return = 'removed'; |
298 | 298 | } |
299 | 299 | |
300 | 300 | } |
301 | 301 | |
302 | - die( $return ); |
|
302 | + die($return); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | public function json_search_users() { |
306 | 306 | |
307 | 307 | |
308 | - check_ajax_referer( 'search-users', 'security' ); |
|
308 | + check_ajax_referer('search-users', 'security'); |
|
309 | 309 | |
310 | - $term = sanitize_text_field( stripslashes( $_GET['term'] ) ); |
|
310 | + $term = sanitize_text_field(stripslashes($_GET['term'])); |
|
311 | 311 | |
312 | - if ( empty( $term ) ) { |
|
312 | + if (empty($term)) { |
|
313 | 313 | die(); |
314 | 314 | } |
315 | 315 | |
316 | - $default = isset( $_GET['default'] ) ? $_GET['default'] : __( 'None', 'woocommerce' ); |
|
316 | + $default = isset($_GET['default']) ? $_GET['default'] : __('None', 'woocommerce'); |
|
317 | 317 | |
318 | - $found_users = array( '' => $default ); |
|
318 | + $found_users = array('' => $default); |
|
319 | 319 | |
320 | - $users_query = new WP_User_Query( apply_filters( 'sensei_json_search_users_query', array( |
|
320 | + $users_query = new WP_User_Query(apply_filters('sensei_json_search_users_query', array( |
|
321 | 321 | 'fields' => 'all', |
322 | 322 | 'orderby' => 'display_name', |
323 | - 'search' => '*' . $term . '*', |
|
324 | - 'search_columns' => array( 'ID', 'user_login', 'user_email', 'user_nicename','user_firstname','user_lastname' ) |
|
325 | - ), $term ) ); |
|
323 | + 'search' => '*'.$term.'*', |
|
324 | + 'search_columns' => array('ID', 'user_login', 'user_email', 'user_nicename', 'user_firstname', 'user_lastname') |
|
325 | + ), $term)); |
|
326 | 326 | |
327 | 327 | $users = $users_query->get_results(); |
328 | 328 | |
329 | - if ( $users ) { |
|
330 | - foreach ( $users as $user ) { |
|
331 | - $full_name = Sensei_Learner::get_full_name( $user->ID ); |
|
329 | + if ($users) { |
|
330 | + foreach ($users as $user) { |
|
331 | + $full_name = Sensei_Learner::get_full_name($user->ID); |
|
332 | 332 | |
333 | - if( trim($user->display_name ) == trim( $full_name ) ){ |
|
333 | + if (trim($user->display_name) == trim($full_name)) { |
|
334 | 334 | |
335 | 335 | $name = $full_name; |
336 | 336 | |
337 | - }else{ |
|
337 | + } else { |
|
338 | 338 | |
339 | - $name = $full_name . ' ['. $user->display_name .']'; |
|
339 | + $name = $full_name.' ['.$user->display_name.']'; |
|
340 | 340 | |
341 | 341 | } |
342 | 342 | |
343 | - $found_users[ $user->ID ] = $name . ' (#' . $user->ID . ' – ' . sanitize_email( $user->user_email ) . ')'; |
|
343 | + $found_users[$user->ID] = $name.' (#'.$user->ID.' – '.sanitize_email($user->user_email).')'; |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | - wp_send_json( $found_users ); |
|
347 | + wp_send_json($found_users); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | public function add_new_learners() { |
351 | 351 | |
352 | 352 | $result = false; |
353 | 353 | |
354 | - if( ! isset( $_POST['add_learner_submit'] ) ) return $result; |
|
354 | + if ( ! isset($_POST['add_learner_submit'])) return $result; |
|
355 | 355 | |
356 | - if ( ! isset( $_POST['add_learner_nonce'] ) || ! wp_verify_nonce( $_POST['add_learner_nonce'], 'add_learner_to_sensei' ) ) return $result; |
|
356 | + if ( ! isset($_POST['add_learner_nonce']) || ! wp_verify_nonce($_POST['add_learner_nonce'], 'add_learner_to_sensei')) return $result; |
|
357 | 357 | |
358 | - if( ( ! isset( $_POST['add_user_id'] ) || '' == $_POST['add_user_id'] ) || ! isset( $_POST['add_post_type'] ) || ! isset( $_POST['add_course_id'] ) || ! isset( $_POST['add_lesson_id'] ) ) return $result; |
|
358 | + if (( ! isset($_POST['add_user_id']) || '' == $_POST['add_user_id']) || ! isset($_POST['add_post_type']) || ! isset($_POST['add_course_id']) || ! isset($_POST['add_lesson_id'])) return $result; |
|
359 | 359 | |
360 | 360 | $post_type = $_POST['add_post_type']; |
361 | - $user_id = absint( $_POST['add_user_id'] ); |
|
362 | - $course_id = absint( $_POST['add_course_id'] ); |
|
361 | + $user_id = absint($_POST['add_user_id']); |
|
362 | + $course_id = absint($_POST['add_course_id']); |
|
363 | 363 | |
364 | - switch( $post_type ) { |
|
364 | + switch ($post_type) { |
|
365 | 365 | case 'course': |
366 | 366 | |
367 | - $result = Sensei_Utils::user_start_course( $user_id, $course_id ); |
|
367 | + $result = Sensei_Utils::user_start_course($user_id, $course_id); |
|
368 | 368 | |
369 | 369 | // Complete each lesson if course is set to be completed |
370 | - if( isset( $_POST['add_complete_course'] ) && 'yes' == $_POST['add_complete_course'] ) { |
|
370 | + if (isset($_POST['add_complete_course']) && 'yes' == $_POST['add_complete_course']) { |
|
371 | 371 | |
372 | - $lesson_ids = Sensei()->course->course_lessons( $course_id, 'any', 'ids' ); |
|
372 | + $lesson_ids = Sensei()->course->course_lessons($course_id, 'any', 'ids'); |
|
373 | 373 | |
374 | - foreach( $lesson_ids as $id ) { |
|
375 | - Sensei_Utils::sensei_start_lesson( $id, $user_id, true ); |
|
374 | + foreach ($lesson_ids as $id) { |
|
375 | + Sensei_Utils::sensei_start_lesson($id, $user_id, true); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | // Updates the Course status and it's meta data |
379 | - Sensei_Utils::user_complete_course( $course_id, $user_id ); |
|
379 | + Sensei_Utils::user_complete_course($course_id, $user_id); |
|
380 | 380 | |
381 | - do_action( 'sensei_user_course_end', $user_id, $course_id ); |
|
381 | + do_action('sensei_user_course_end', $user_id, $course_id); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | break; |
385 | 385 | |
386 | 386 | case 'lesson': |
387 | - $lesson_id = absint( $_POST['add_lesson_id'] ); |
|
387 | + $lesson_id = absint($_POST['add_lesson_id']); |
|
388 | 388 | $complete = false; |
389 | - if( isset( $_POST['add_complete_lesson'] ) && 'yes' == $_POST['add_complete_lesson'] ) { |
|
389 | + if (isset($_POST['add_complete_lesson']) && 'yes' == $_POST['add_complete_lesson']) { |
|
390 | 390 | $complete = true; |
391 | 391 | } |
392 | 392 | |
393 | - $result = Sensei_Utils::sensei_start_lesson( $lesson_id, $user_id, $complete ); |
|
393 | + $result = Sensei_Utils::sensei_start_lesson($lesson_id, $user_id, $complete); |
|
394 | 394 | |
395 | 395 | // Updates the Course status and it's meta data |
396 | - Sensei_Utils::user_complete_course( $course_id, $user_id ); |
|
396 | + Sensei_Utils::user_complete_course($course_id, $user_id); |
|
397 | 397 | |
398 | 398 | break; |
399 | 399 | } |
400 | 400 | |
401 | 401 | // Set redirect URL after adding user to course/lesson |
402 | - $query_args = array( 'page' => $this->page_slug, 'view' => 'learners' ); |
|
402 | + $query_args = array('page' => $this->page_slug, 'view' => 'learners'); |
|
403 | 403 | |
404 | - if( $result ) { |
|
404 | + if ($result) { |
|
405 | 405 | |
406 | - if( $course_id ) { |
|
406 | + if ($course_id) { |
|
407 | 407 | $query_args['course_id'] = $course_id; |
408 | 408 | } |
409 | 409 | |
410 | - if( $lesson_id ) { |
|
410 | + if ($lesson_id) { |
|
411 | 411 | $query_args['lesson_id'] = $lesson_id; |
412 | 412 | } |
413 | 413 | |
@@ -417,23 +417,23 @@ discard block |
||
417 | 417 | $query_args['message'] = 'error'; |
418 | 418 | } |
419 | 419 | |
420 | - $redirect_url = apply_filters( 'sensei_learners_add_learner_redirect_url', add_query_arg( $query_args, admin_url( 'admin.php' ) ) ); |
|
420 | + $redirect_url = apply_filters('sensei_learners_add_learner_redirect_url', add_query_arg($query_args, admin_url('admin.php'))); |
|
421 | 421 | |
422 | - wp_safe_redirect( esc_url_raw( $redirect_url ) ); |
|
422 | + wp_safe_redirect(esc_url_raw($redirect_url)); |
|
423 | 423 | exit; |
424 | 424 | } |
425 | 425 | |
426 | 426 | public function add_learner_notices() { |
427 | - if( isset( $_GET['page'] ) && $this->page_slug == $_GET['page'] && isset( $_GET['message'] ) && $_GET['message'] ) { |
|
428 | - if( 'success' == $_GET['message'] ) { |
|
427 | + if (isset($_GET['page']) && $this->page_slug == $_GET['page'] && isset($_GET['message']) && $_GET['message']) { |
|
428 | + if ('success' == $_GET['message']) { |
|
429 | 429 | $msg = array( |
430 | 430 | 'updated', |
431 | - __( 'Learner added successfully!', 'woothemes-sensei' ), |
|
431 | + __('Learner added successfully!', 'woothemes-sensei'), |
|
432 | 432 | ); |
433 | 433 | } else { |
434 | 434 | $msg = array( |
435 | 435 | 'error', |
436 | - __( 'Error adding learner.', 'woothemes-sensei' ), |
|
436 | + __('Error adding learner.', 'woothemes-sensei'), |
|
437 | 437 | ); |
438 | 438 | } |
439 | 439 | ?> |
@@ -456,9 +456,9 @@ discard block |
||
456 | 456 | * |
457 | 457 | * @return string $full_name |
458 | 458 | */ |
459 | - public function get_learner_full_name( $user_id ){ |
|
459 | + public function get_learner_full_name($user_id) { |
|
460 | 460 | |
461 | - return Sensei_Learner::get_full_name( $user_id ); |
|
461 | + return Sensei_Learner::get_full_name($user_id); |
|
462 | 462 | |
463 | 463 | } // end get_learner_full_name |
464 | 464 | |
@@ -469,4 +469,4 @@ discard block |
||
469 | 469 | * @ignore only for backward compatibility |
470 | 470 | * @since 1.9.0 |
471 | 471 | */ |
472 | -class WooThemes_Sensei_Learners extends Sensei_Learner_Management{} |
|
472 | +class WooThemes_Sensei_Learners extends Sensei_Learner_Management {} |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | /** |
404 | 404 | * Disable guest checkout if a course product is in the cart |
405 | 405 | * @param boolean $guest_checkout Current guest checkout setting |
406 | - * @return boolean Modified guest checkout setting |
|
406 | + * @return string|boolean Modified guest checkout setting |
|
407 | 407 | */ |
408 | 408 | public function disable_guest_checkout( $guest_checkout ) { |
409 | 409 | global $woocommerce; |
@@ -642,7 +642,7 @@ discard block |
||
642 | 642 | * @since 1.0.0 |
643 | 643 | * @param int $course_id (default: 0) |
644 | 644 | * @param array/Object $order_user (default: array()) Specific user's data. |
645 | - * @return bool|int |
|
645 | + * @return boolean|string |
|
646 | 646 | */ |
647 | 647 | public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
648 | 648 | global $current_user; |
@@ -1241,7 +1241,7 @@ discard block |
||
1241 | 1241 | * |
1242 | 1242 | * @since 1.4.5 |
1243 | 1243 | * @access public |
1244 | - * @param mixed $image_size |
|
1244 | + * @param string $image_size |
|
1245 | 1245 | * @return string |
1246 | 1246 | */ |
1247 | 1247 | public function get_image_size( $image_size ) { |
@@ -1,5 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
3 | + exit; |
|
4 | +} |
|
5 | +// Exit if accessed directly |
|
3 | 6 | |
4 | 7 | /** |
5 | 8 | * Sensei_Main |
@@ -159,7 +162,9 @@ discard block |
||
159 | 162 | $this->init(); |
160 | 163 | |
161 | 164 | // Installation |
162 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); |
|
165 | + if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
166 | + $this->install(); |
|
167 | + } |
|
163 | 168 | |
164 | 169 | // Run this on activation. |
165 | 170 | register_activation_hook( $this->file, array( $this, 'activation' ) ); |
@@ -447,7 +452,9 @@ discard block |
||
447 | 452 | **/ |
448 | 453 | public function virtual_order_payment_complete( $order_status, $order_id ) { |
449 | 454 | $order = new WC_Order( $order_id ); |
450 | - if ( ! isset ( $order ) ) return ''; |
|
455 | + if ( ! isset ( $order ) ) { |
|
456 | + return ''; |
|
457 | + } |
|
451 | 458 | if ( $order_status == 'wc-processing' && ( $order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed' ) ) { |
452 | 459 | $virtual_order = true; |
453 | 460 | |
@@ -612,7 +619,7 @@ discard block |
||
612 | 619 | |
613 | 620 | $sensei_plugin_path = $this->plugin_path; |
614 | 621 | |
615 | - }else{ |
|
622 | + } else{ |
|
616 | 623 | |
617 | 624 | $sensei_plugin_path = plugin_dir_path( __FILE__ ); |
618 | 625 | |
@@ -647,7 +654,9 @@ discard block |
||
647 | 654 | public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
648 | 655 | global $current_user; |
649 | 656 | |
650 | - if ( ! isset( $current_user ) || !$current_user->ID > 0 ) return false; |
|
657 | + if ( ! isset( $current_user ) || !$current_user->ID > 0 ) { |
|
658 | + return false; |
|
659 | + } |
|
651 | 660 | |
652 | 661 | $data_update = false; |
653 | 662 | |
@@ -731,8 +740,7 @@ discard block |
||
731 | 740 | |
732 | 741 | $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); |
733 | 742 | |
734 | - } |
|
735 | - else { |
|
743 | + } else { |
|
736 | 744 | $prerequisite_complete = true; |
737 | 745 | } // End If Statement |
738 | 746 | // Handles restrictions |
@@ -859,7 +867,9 @@ discard block |
||
859 | 867 | */ |
860 | 868 | public function access_settings () { |
861 | 869 | |
862 | - if( sensei_all_access() ) return true; |
|
870 | + if( sensei_all_access() ) { |
|
871 | + return true; |
|
872 | + } |
|
863 | 873 | |
864 | 874 | if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { |
865 | 875 | if ( is_user_logged_in() ) { |
@@ -1188,8 +1198,9 @@ discard block |
||
1188 | 1198 | } |
1189 | 1199 | $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; |
1190 | 1200 | |
1191 | - if ( $post_id > 0 ) |
|
1192 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
1201 | + if ( $post_id > 0 ) { |
|
1202 | + $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
1203 | + } |
|
1193 | 1204 | |
1194 | 1205 | $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
1195 | 1206 | |
@@ -1197,16 +1208,19 @@ discard block |
||
1197 | 1208 | $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
1198 | 1209 | foreach ( (array) $count as $row ) { |
1199 | 1210 | // Don't count post-trashed toward totals |
1200 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
1201 | - $total += $row['num_comments']; |
|
1202 | - if ( isset( $approved[$row['comment_approved']] ) ) |
|
1203 | - $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1211 | + if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) { |
|
1212 | + $total += $row['num_comments']; |
|
1213 | + } |
|
1214 | + if ( isset( $approved[$row['comment_approved']] ) ) { |
|
1215 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1216 | + } |
|
1204 | 1217 | } |
1205 | 1218 | |
1206 | 1219 | $stats['total_comments'] = $total; |
1207 | 1220 | foreach ( $approved as $key ) { |
1208 | - if ( empty($stats[$key]) ) |
|
1209 | - $stats[$key] = 0; |
|
1221 | + if ( empty($stats[$key]) ) { |
|
1222 | + $stats[$key] = 0; |
|
1223 | + } |
|
1210 | 1224 | } |
1211 | 1225 | |
1212 | 1226 | $stats = (object) $stats; |
@@ -1247,8 +1261,9 @@ discard block |
||
1247 | 1261 | public function get_image_size( $image_size ) { |
1248 | 1262 | |
1249 | 1263 | // Only return sizes we define in settings |
1250 | - if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) |
|
1251 | - return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
1264 | + if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) { |
|
1265 | + return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
1266 | + } |
|
1252 | 1267 | |
1253 | 1268 | if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { |
1254 | 1269 | $this->settings->settings[ $image_size . '_width' ] = false; |
@@ -1311,7 +1326,7 @@ discard block |
||
1311 | 1326 | require_once( 'class-sensei-modules.php'); |
1312 | 1327 | Sensei()->modules = new Sensei_Core_Modules( $this->file ); |
1313 | 1328 | |
1314 | - }else{ |
|
1329 | + } else{ |
|
1315 | 1330 | // fallback for people still using the modules extension. |
1316 | 1331 | global $sensei_modules; |
1317 | 1332 | Sensei()->modules = $sensei_modules; |
@@ -1358,7 +1373,7 @@ discard block |
||
1358 | 1373 | |
1359 | 1374 | update_option('sensei_flush_rewrite_rules', '2'); |
1360 | 1375 | |
1361 | - }elseif( '2' == $option ) { |
|
1376 | + } elseif( '2' == $option ) { |
|
1362 | 1377 | |
1363 | 1378 | flush_rewrite_rules(); |
1364 | 1379 | update_option('sensei_flush_rewrite_rules', '0'); |
@@ -14,1347 +14,1347 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class Sensei_Main { |
16 | 16 | |
17 | - /** |
|
18 | - * @var string |
|
19 | - * Reference to the main plugin file |
|
20 | - */ |
|
21 | - private $file; |
|
22 | - |
|
23 | - /** |
|
24 | - * @var Sensei_Main $_instance to the the main and only instance of the Sensei class. |
|
25 | - * @since 1.8.0 |
|
26 | - */ |
|
27 | - protected static $_instance = null; |
|
28 | - |
|
29 | - /** |
|
30 | - * Main reference to the plugins current version |
|
31 | - */ |
|
32 | - public $version; |
|
33 | - |
|
34 | - /** |
|
35 | - * Public token, referencing for the text domain. |
|
36 | - */ |
|
37 | - public $token = 'woothemes-sensei'; |
|
38 | - |
|
39 | - /** |
|
40 | - * Plugin url and path for use when access resources. |
|
41 | - */ |
|
42 | - public $plugin_url; |
|
43 | - public $plugin_path; |
|
44 | - public $template_url; |
|
45 | - |
|
46 | - /** |
|
47 | - * @var Sensei_PostTypes |
|
48 | - * All Sensei sub classes. Currently used to access functionality contained within |
|
49 | - * within Sensei sub classes e.g. Sensei()->course->all_courses() |
|
50 | - */ |
|
51 | - public $post_types; |
|
52 | - |
|
53 | - /** |
|
54 | - * @var WooThemes_Sensei_Settings |
|
55 | - */ |
|
56 | - public $settings; |
|
57 | - |
|
58 | - /** |
|
59 | - * @var WooThemes_Sensei_Course_Results |
|
60 | - */ |
|
61 | - public $course_results; |
|
62 | - |
|
63 | - /** |
|
64 | - * @var Sensei_Updates |
|
65 | - */ |
|
66 | - public $updates; |
|
67 | - /** |
|
68 | - * @var WooThemes_Sensei_Course |
|
69 | - */ |
|
70 | - public $course; |
|
71 | - |
|
72 | - /** |
|
73 | - * @var WooThemes_Sensei_Lesson |
|
74 | - */ |
|
75 | - public $lesson; |
|
76 | - |
|
77 | - /** |
|
78 | - * @var WooThemes_Sensei_Quiz |
|
79 | - */ |
|
80 | - public $quiz; |
|
81 | - |
|
82 | - /** |
|
83 | - * @var WooThemes_Sensei_Question |
|
84 | - */ |
|
85 | - public $question; |
|
86 | - |
|
87 | - /** |
|
88 | - * @var WooThemes_Sensei_Admin |
|
89 | - */ |
|
90 | - public $admin; |
|
91 | - |
|
92 | - /** |
|
93 | - * @var WooThemes_Sensei_Frontend |
|
94 | - */ |
|
95 | - public $frontend; |
|
96 | - |
|
97 | - /** |
|
98 | - * @var Sensei_Notices |
|
99 | - */ |
|
100 | - public $notices; |
|
101 | - |
|
102 | - /** |
|
103 | - * @var WooThemes_Sensei_Grading |
|
104 | - */ |
|
105 | - public $grading; |
|
106 | - |
|
107 | - /** |
|
108 | - * @var WooThemes_Sensei_Emails |
|
109 | - */ |
|
110 | - public $emails; |
|
111 | - |
|
112 | - /** |
|
113 | - * @var WooThemes_Sensei_Learner_Profiles |
|
114 | - */ |
|
115 | - public $learner_profiles; |
|
116 | - |
|
117 | - /** |
|
118 | - * @var Sensei_Teacher |
|
119 | - */ |
|
120 | - public $teacher; |
|
121 | - |
|
122 | - /** |
|
123 | - * @var WooThemes_Sensei_Learners |
|
124 | - */ |
|
125 | - public $learners; |
|
126 | - |
|
127 | - /** |
|
128 | - * @var array |
|
129 | - * Global instance for access to the permissions message shown |
|
130 | - * when users do not have the right privileges to access resources. |
|
131 | - */ |
|
132 | - public $permissions_message; |
|
133 | - |
|
134 | - /** |
|
135 | - * @var Sensei_Core_Modules Sensei Modules functionality |
|
136 | - */ |
|
137 | - public $modules; |
|
138 | - |
|
139 | - /** |
|
140 | - * @var Sensei_Analysis |
|
141 | - */ |
|
142 | - public $analysis; |
|
143 | - |
|
144 | - /** |
|
145 | - * Constructor method. |
|
146 | - * @param string $file The base file of the plugin. |
|
147 | - * @since 1.0.0 |
|
148 | - */ |
|
149 | - public function __construct ( $file ) { |
|
150 | - |
|
151 | - // Setup object data |
|
152 | - $this->file = $file; |
|
153 | - $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); |
|
154 | - $this->plugin_path = trailingslashit( dirname( $file ) ); |
|
155 | - $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); |
|
156 | - $this->permissions_message = array( 'title' => __( 'Permission Denied', 'woothemes-sensei' ), 'message' => __( 'Unfortunately you do not have permissions to access this page.', 'woothemes-sensei' ) ); |
|
157 | - |
|
158 | - // Initialize the core Sensei functionality |
|
159 | - $this->init(); |
|
160 | - |
|
161 | - // Installation |
|
162 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); |
|
163 | - |
|
164 | - // Run this on activation. |
|
165 | - register_activation_hook( $this->file, array( $this, 'activation' ) ); |
|
166 | - |
|
167 | - // Image Sizes |
|
168 | - $this->init_image_sizes(); |
|
169 | - |
|
170 | - // Force WooCommerce Required Settings |
|
171 | - $this->set_woocommerce_functionality(); |
|
172 | - |
|
173 | - // load all hooks |
|
174 | - $this->load_hooks(); |
|
175 | - |
|
176 | - } // End __construct() |
|
177 | - |
|
178 | - /** |
|
179 | - * Load the foundations of Sensei. |
|
180 | - * @since 1.9.0 |
|
181 | - */ |
|
182 | - protected function init(){ |
|
183 | - |
|
184 | - // Localisation |
|
185 | - $this->load_plugin_textdomain(); |
|
186 | - add_action( 'init', array( $this, 'load_localisation' ), 0 ); |
|
187 | - |
|
188 | - // load the shortcode loader into memory, so as to listen to all for |
|
189 | - // all shortcodes on the front end |
|
190 | - new Sensei_Shortcode_Loader(); |
|
191 | - |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Global Sensei Instance |
|
196 | - * |
|
197 | - * Ensure that only one instance of the main Sensei class can be loaded. |
|
198 | - * |
|
199 | - * @since 1.8.0 |
|
200 | - * @static |
|
201 | - * @see WC() |
|
202 | - * @return WooThemes_Sensei Instance. |
|
203 | - */ |
|
204 | - public static function instance() { |
|
17 | + /** |
|
18 | + * @var string |
|
19 | + * Reference to the main plugin file |
|
20 | + */ |
|
21 | + private $file; |
|
22 | + |
|
23 | + /** |
|
24 | + * @var Sensei_Main $_instance to the the main and only instance of the Sensei class. |
|
25 | + * @since 1.8.0 |
|
26 | + */ |
|
27 | + protected static $_instance = null; |
|
28 | + |
|
29 | + /** |
|
30 | + * Main reference to the plugins current version |
|
31 | + */ |
|
32 | + public $version; |
|
33 | + |
|
34 | + /** |
|
35 | + * Public token, referencing for the text domain. |
|
36 | + */ |
|
37 | + public $token = 'woothemes-sensei'; |
|
38 | + |
|
39 | + /** |
|
40 | + * Plugin url and path for use when access resources. |
|
41 | + */ |
|
42 | + public $plugin_url; |
|
43 | + public $plugin_path; |
|
44 | + public $template_url; |
|
45 | + |
|
46 | + /** |
|
47 | + * @var Sensei_PostTypes |
|
48 | + * All Sensei sub classes. Currently used to access functionality contained within |
|
49 | + * within Sensei sub classes e.g. Sensei()->course->all_courses() |
|
50 | + */ |
|
51 | + public $post_types; |
|
52 | + |
|
53 | + /** |
|
54 | + * @var WooThemes_Sensei_Settings |
|
55 | + */ |
|
56 | + public $settings; |
|
57 | + |
|
58 | + /** |
|
59 | + * @var WooThemes_Sensei_Course_Results |
|
60 | + */ |
|
61 | + public $course_results; |
|
62 | + |
|
63 | + /** |
|
64 | + * @var Sensei_Updates |
|
65 | + */ |
|
66 | + public $updates; |
|
67 | + /** |
|
68 | + * @var WooThemes_Sensei_Course |
|
69 | + */ |
|
70 | + public $course; |
|
71 | + |
|
72 | + /** |
|
73 | + * @var WooThemes_Sensei_Lesson |
|
74 | + */ |
|
75 | + public $lesson; |
|
76 | + |
|
77 | + /** |
|
78 | + * @var WooThemes_Sensei_Quiz |
|
79 | + */ |
|
80 | + public $quiz; |
|
81 | + |
|
82 | + /** |
|
83 | + * @var WooThemes_Sensei_Question |
|
84 | + */ |
|
85 | + public $question; |
|
86 | + |
|
87 | + /** |
|
88 | + * @var WooThemes_Sensei_Admin |
|
89 | + */ |
|
90 | + public $admin; |
|
91 | + |
|
92 | + /** |
|
93 | + * @var WooThemes_Sensei_Frontend |
|
94 | + */ |
|
95 | + public $frontend; |
|
96 | + |
|
97 | + /** |
|
98 | + * @var Sensei_Notices |
|
99 | + */ |
|
100 | + public $notices; |
|
101 | + |
|
102 | + /** |
|
103 | + * @var WooThemes_Sensei_Grading |
|
104 | + */ |
|
105 | + public $grading; |
|
106 | + |
|
107 | + /** |
|
108 | + * @var WooThemes_Sensei_Emails |
|
109 | + */ |
|
110 | + public $emails; |
|
111 | + |
|
112 | + /** |
|
113 | + * @var WooThemes_Sensei_Learner_Profiles |
|
114 | + */ |
|
115 | + public $learner_profiles; |
|
116 | + |
|
117 | + /** |
|
118 | + * @var Sensei_Teacher |
|
119 | + */ |
|
120 | + public $teacher; |
|
121 | + |
|
122 | + /** |
|
123 | + * @var WooThemes_Sensei_Learners |
|
124 | + */ |
|
125 | + public $learners; |
|
126 | + |
|
127 | + /** |
|
128 | + * @var array |
|
129 | + * Global instance for access to the permissions message shown |
|
130 | + * when users do not have the right privileges to access resources. |
|
131 | + */ |
|
132 | + public $permissions_message; |
|
133 | + |
|
134 | + /** |
|
135 | + * @var Sensei_Core_Modules Sensei Modules functionality |
|
136 | + */ |
|
137 | + public $modules; |
|
138 | + |
|
139 | + /** |
|
140 | + * @var Sensei_Analysis |
|
141 | + */ |
|
142 | + public $analysis; |
|
143 | + |
|
144 | + /** |
|
145 | + * Constructor method. |
|
146 | + * @param string $file The base file of the plugin. |
|
147 | + * @since 1.0.0 |
|
148 | + */ |
|
149 | + public function __construct ( $file ) { |
|
150 | + |
|
151 | + // Setup object data |
|
152 | + $this->file = $file; |
|
153 | + $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); |
|
154 | + $this->plugin_path = trailingslashit( dirname( $file ) ); |
|
155 | + $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); |
|
156 | + $this->permissions_message = array( 'title' => __( 'Permission Denied', 'woothemes-sensei' ), 'message' => __( 'Unfortunately you do not have permissions to access this page.', 'woothemes-sensei' ) ); |
|
157 | + |
|
158 | + // Initialize the core Sensei functionality |
|
159 | + $this->init(); |
|
160 | + |
|
161 | + // Installation |
|
162 | + if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); |
|
163 | + |
|
164 | + // Run this on activation. |
|
165 | + register_activation_hook( $this->file, array( $this, 'activation' ) ); |
|
166 | + |
|
167 | + // Image Sizes |
|
168 | + $this->init_image_sizes(); |
|
169 | + |
|
170 | + // Force WooCommerce Required Settings |
|
171 | + $this->set_woocommerce_functionality(); |
|
172 | + |
|
173 | + // load all hooks |
|
174 | + $this->load_hooks(); |
|
175 | + |
|
176 | + } // End __construct() |
|
177 | + |
|
178 | + /** |
|
179 | + * Load the foundations of Sensei. |
|
180 | + * @since 1.9.0 |
|
181 | + */ |
|
182 | + protected function init(){ |
|
183 | + |
|
184 | + // Localisation |
|
185 | + $this->load_plugin_textdomain(); |
|
186 | + add_action( 'init', array( $this, 'load_localisation' ), 0 ); |
|
187 | + |
|
188 | + // load the shortcode loader into memory, so as to listen to all for |
|
189 | + // all shortcodes on the front end |
|
190 | + new Sensei_Shortcode_Loader(); |
|
191 | + |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Global Sensei Instance |
|
196 | + * |
|
197 | + * Ensure that only one instance of the main Sensei class can be loaded. |
|
198 | + * |
|
199 | + * @since 1.8.0 |
|
200 | + * @static |
|
201 | + * @see WC() |
|
202 | + * @return WooThemes_Sensei Instance. |
|
203 | + */ |
|
204 | + public static function instance() { |
|
205 | 205 | |
206 | - if ( is_null( self::$_instance ) ) { |
|
206 | + if ( is_null( self::$_instance ) ) { |
|
207 | 207 | |
208 | - //Sensei requires a reference to the main Sensei plugin file |
|
209 | - $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php'; |
|
208 | + //Sensei requires a reference to the main Sensei plugin file |
|
209 | + $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php'; |
|
210 | 210 | |
211 | - self::$_instance = new self( $sensei_main_plugin_file ); |
|
211 | + self::$_instance = new self( $sensei_main_plugin_file ); |
|
212 | 212 | |
213 | - // load the global class objects needed throughout Sensei |
|
214 | - self::$_instance->initialize_global_objects(); |
|
213 | + // load the global class objects needed throughout Sensei |
|
214 | + self::$_instance->initialize_global_objects(); |
|
215 | 215 | |
216 | - } |
|
216 | + } |
|
217 | 217 | |
218 | - return self::$_instance; |
|
218 | + return self::$_instance; |
|
219 | 219 | |
220 | - } // end instance() |
|
220 | + } // end instance() |
|
221 | 221 | |
222 | - /** |
|
223 | - * This function is linked into the activation |
|
224 | - * hook to reset flush the urls to ensure Sensei post types show up. |
|
225 | - * |
|
226 | - * @since 1.9.0 |
|
227 | - * |
|
228 | - * @param $plugin |
|
229 | - */ |
|
230 | - public static function activation_flush_rules( $plugin ){ |
|
222 | + /** |
|
223 | + * This function is linked into the activation |
|
224 | + * hook to reset flush the urls to ensure Sensei post types show up. |
|
225 | + * |
|
226 | + * @since 1.9.0 |
|
227 | + * |
|
228 | + * @param $plugin |
|
229 | + */ |
|
230 | + public static function activation_flush_rules( $plugin ){ |
|
231 | 231 | |
232 | - if( strpos( $plugin, '/woothemes-sensei.php' ) > 0 ){ |
|
232 | + if( strpos( $plugin, '/woothemes-sensei.php' ) > 0 ){ |
|
233 | 233 | |
234 | - flush_rewrite_rules(true); |
|
234 | + flush_rewrite_rules(true); |
|
235 | 235 | |
236 | - } |
|
236 | + } |
|
237 | 237 | |
238 | - } |
|
238 | + } |
|
239 | 239 | |
240 | - /** |
|
241 | - * Cloning is forbidden. |
|
242 | - * @since 1.8.0 |
|
243 | - */ |
|
244 | - public function __clone() { |
|
245 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
246 | - } |
|
240 | + /** |
|
241 | + * Cloning is forbidden. |
|
242 | + * @since 1.8.0 |
|
243 | + */ |
|
244 | + public function __clone() { |
|
245 | + _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
246 | + } |
|
247 | 247 | |
248 | - /** |
|
249 | - * Unserializing instances of this class is forbidden. |
|
250 | - * @since 1.8.0 |
|
251 | - */ |
|
252 | - public function __wakeup() { |
|
253 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
254 | - } |
|
248 | + /** |
|
249 | + * Unserializing instances of this class is forbidden. |
|
250 | + * @since 1.8.0 |
|
251 | + */ |
|
252 | + public function __wakeup() { |
|
253 | + _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
254 | + } |
|
255 | 255 | |
256 | - /** |
|
257 | - * Load the properties for the main Sensei object |
|
258 | - * |
|
259 | - * @since 1.9.0 |
|
260 | - */ |
|
261 | - public function initialize_global_objects(){ |
|
256 | + /** |
|
257 | + * Load the properties for the main Sensei object |
|
258 | + * |
|
259 | + * @since 1.9.0 |
|
260 | + */ |
|
261 | + public function initialize_global_objects(){ |
|
262 | 262 | |
263 | - // Setup post types. |
|
264 | - $this->post_types = new Sensei_PostTypes(); |
|
263 | + // Setup post types. |
|
264 | + $this->post_types = new Sensei_PostTypes(); |
|
265 | 265 | |
266 | - // Lad the updates class |
|
267 | - $this->updates = new Sensei_Updates( $this ); |
|
266 | + // Lad the updates class |
|
267 | + $this->updates = new Sensei_Updates( $this ); |
|
268 | 268 | |
269 | - // Setup settings |
|
270 | - $this->settings = new Sensei_Settings(); |
|
269 | + // Setup settings |
|
270 | + $this->settings = new Sensei_Settings(); |
|
271 | 271 | |
272 | - // Load Course Results Class |
|
273 | - $this->course_results = new Sensei_Course_Results(); |
|
272 | + // Load Course Results Class |
|
273 | + $this->course_results = new Sensei_Course_Results(); |
|
274 | 274 | |
275 | - // Load the teacher role |
|
276 | - $this->teacher = new Sensei_Teacher(); |
|
275 | + // Load the teacher role |
|
276 | + $this->teacher = new Sensei_Teacher(); |
|
277 | 277 | |
278 | - // Add the Course class |
|
279 | - $this->course = $this->post_types->course; |
|
278 | + // Add the Course class |
|
279 | + $this->course = $this->post_types->course; |
|
280 | 280 | |
281 | - // Add the lesson class |
|
282 | - $this->lesson = $this->post_types->lesson; |
|
281 | + // Add the lesson class |
|
282 | + $this->lesson = $this->post_types->lesson; |
|
283 | 283 | |
284 | - // Add the question class |
|
285 | - $this->question = $this->post_types->question; |
|
284 | + // Add the question class |
|
285 | + $this->question = $this->post_types->question; |
|
286 | 286 | |
287 | - //Add the quiz class |
|
288 | - $this->quiz = $this->post_types->quiz; |
|
287 | + //Add the quiz class |
|
288 | + $this->quiz = $this->post_types->quiz; |
|
289 | 289 | |
290 | - // load the modules class after all plugsin are loaded |
|
291 | - add_action( 'plugins_loaded', array( $this, 'load_modules_class' ) ); |
|
290 | + // load the modules class after all plugsin are loaded |
|
291 | + add_action( 'plugins_loaded', array( $this, 'load_modules_class' ) ); |
|
292 | 292 | |
293 | - // Load Learner Management Functionality |
|
294 | - $this->learners = new Sensei_Learner_Management( $this->file ); |
|
293 | + // Load Learner Management Functionality |
|
294 | + $this->learners = new Sensei_Learner_Management( $this->file ); |
|
295 | 295 | |
296 | - // Differentiate between administration and frontend logic. |
|
297 | - if ( is_admin() ) { |
|
296 | + // Differentiate between administration and frontend logic. |
|
297 | + if ( is_admin() ) { |
|
298 | 298 | |
299 | - // Load Admin Welcome class |
|
300 | - new Sensei_Welcome(); |
|
299 | + // Load Admin Welcome class |
|
300 | + new Sensei_Welcome(); |
|
301 | 301 | |
302 | - // Load Admin Class |
|
303 | - $this->admin = new Sensei_Admin( $this->file ); |
|
302 | + // Load Admin Class |
|
303 | + $this->admin = new Sensei_Admin( $this->file ); |
|
304 | 304 | |
305 | - // Load Analysis Reports |
|
306 | - $this->analysis = new Sensei_Analysis( $this->file ); |
|
305 | + // Load Analysis Reports |
|
306 | + $this->analysis = new Sensei_Analysis( $this->file ); |
|
307 | 307 | |
308 | - } else { |
|
308 | + } else { |
|
309 | 309 | |
310 | - // Load Frontend Class |
|
311 | - $this->frontend = new Sensei_Frontend(); |
|
310 | + // Load Frontend Class |
|
311 | + $this->frontend = new Sensei_Frontend(); |
|
312 | 312 | |
313 | - // Load notice Class |
|
314 | - $this->notices = new Sensei_Notices(); |
|
313 | + // Load notice Class |
|
314 | + $this->notices = new Sensei_Notices(); |
|
315 | 315 | |
316 | - // Load built in themes support integration |
|
317 | - new Sensei_Theme_Integration_Loader(); |
|
316 | + // Load built in themes support integration |
|
317 | + new Sensei_Theme_Integration_Loader(); |
|
318 | 318 | |
319 | 319 | |
320 | - } |
|
320 | + } |
|
321 | 321 | |
322 | - // Load Grading Functionality |
|
323 | - $this->grading = new Sensei_Grading( $this->file ); |
|
322 | + // Load Grading Functionality |
|
323 | + $this->grading = new Sensei_Grading( $this->file ); |
|
324 | 324 | |
325 | - // Load Email Class |
|
326 | - $this->emails = new Sensei_Emails( $this->file ); |
|
325 | + // Load Email Class |
|
326 | + $this->emails = new Sensei_Emails( $this->file ); |
|
327 | 327 | |
328 | - // Load Learner Profiles Class |
|
329 | - $this->learner_profiles = new Sensei_Learner_Profiles(); |
|
328 | + // Load Learner Profiles Class |
|
329 | + $this->learner_profiles = new Sensei_Learner_Profiles(); |
|
330 | 330 | |
331 | - } |
|
331 | + } |
|
332 | 332 | |
333 | - /** |
|
334 | - * Initialize all Sensei hooks |
|
335 | - * |
|
336 | - * @since 1.9.0 |
|
337 | - */ |
|
338 | - public function load_hooks(){ |
|
339 | - |
|
340 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
341 | - add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); |
|
342 | - |
|
343 | - // WooCommerce Payment Actions |
|
344 | - add_action( 'woocommerce_payment_complete' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
345 | - add_action( 'woocommerce_thankyou' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
346 | - add_action( 'woocommerce_order_status_completed' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
347 | - add_action( 'woocommerce_order_status_processing' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
348 | - add_action( 'woocommerce_order_status_cancelled' , array( $this, 'sensei_woocommerce_cancel_order' ) ); |
|
349 | - add_action( 'woocommerce_order_status_refunded' , array( $this, 'sensei_woocommerce_cancel_order' ) ); |
|
350 | - add_action( 'subscriptions_activated_for_order', array( $this, 'sensei_activate_subscription' ) ); |
|
351 | - |
|
352 | - // WooCommerce Subscriptions Actions |
|
353 | - add_action( 'reactivated_subscription', array( $this, 'sensei_woocommerce_reactivate_subscription' ), 10, 2 ); |
|
354 | - add_action( 'subscription_expired' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
355 | - add_action( 'subscription_end_of_prepaid_term' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
356 | - add_action( 'cancelled_subscription' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
357 | - add_action( 'subscription_put_on-hold' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
358 | - |
|
359 | - // Add Email link to course orders |
|
360 | - add_action( 'woocommerce_email_after_order_table', array( $this, 'sensei_woocommerce_email_course_details' ), 10, 1 ); |
|
361 | - |
|
362 | - // Filter comment counts |
|
363 | - add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); |
|
364 | - |
|
365 | - add_action( 'body_class', array( $this, 'body_class' ) ); |
|
366 | - |
|
367 | - // Check for and activate JetPack LaTeX support |
|
368 | - add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules |
|
369 | - |
|
370 | - // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 |
|
371 | - add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); |
|
372 | - |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * Run Sensei updates. |
|
377 | - * @access public |
|
378 | - * @since 1.1.0 |
|
379 | - * @return void |
|
380 | - */ |
|
381 | - public function run_updates() { |
|
382 | - // Run updates if administrator |
|
383 | - if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { |
|
384 | - |
|
385 | - $this->updates->update(); |
|
386 | - |
|
387 | - } // End If Statement |
|
388 | - } // End run_updates() |
|
389 | - |
|
390 | - |
|
391 | - |
|
392 | - /** |
|
393 | - * Setup required WooCommerce settings. |
|
394 | - * @access public |
|
395 | - * @since 1.1.0 |
|
396 | - * @return void |
|
397 | - */ |
|
398 | - public function set_woocommerce_functionality() { |
|
399 | - // Disable guest checkout if a course is in the cart as we need a valid user to store data for |
|
400 | - add_filter( 'pre_option_woocommerce_enable_guest_checkout', array( $this, 'disable_guest_checkout' ) ); |
|
401 | - |
|
402 | - // Mark orders with virtual products as complete rather then stay processing |
|
403 | - add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'virtual_order_payment_complete' ), 10, 2 ); |
|
404 | - |
|
405 | - } // End set_woocommerce_functionality() |
|
406 | - |
|
407 | - /** |
|
408 | - * Disable guest checkout if a course product is in the cart |
|
409 | - * @param boolean $guest_checkout Current guest checkout setting |
|
410 | - * @return boolean Modified guest checkout setting |
|
411 | - */ |
|
412 | - public function disable_guest_checkout( $guest_checkout ) { |
|
413 | - global $woocommerce; |
|
414 | - |
|
415 | - if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
416 | - |
|
417 | - if( isset( $woocommerce->cart->cart_contents ) && count( $woocommerce->cart->cart_contents ) > 0 ) { |
|
418 | - foreach( $woocommerce->cart->cart_contents as $cart_key => $product ) { |
|
419 | - if( isset( $product['product_id'] ) ) { |
|
420 | - $args = array( |
|
421 | - 'posts_per_page' => -1, |
|
422 | - 'post_type' => 'course', |
|
423 | - 'meta_query' => array( |
|
424 | - array( |
|
425 | - 'key' => '_course_woocommerce_product', |
|
426 | - 'value' => $product['product_id'] |
|
427 | - ) |
|
428 | - ) |
|
429 | - ); |
|
430 | - $posts = get_posts( $args ); |
|
431 | - if( $posts && count( $posts ) > 0 ) { |
|
432 | - foreach( $posts as $course ) { |
|
433 | - $guest_checkout = ''; |
|
434 | - break; |
|
435 | - } |
|
436 | - } |
|
437 | - } |
|
438 | - } |
|
439 | - } |
|
440 | - } |
|
441 | - |
|
442 | - return $guest_checkout; |
|
443 | - } |
|
444 | - |
|
445 | - /** |
|
446 | - * Change order status with virtual products to completed |
|
447 | - * @since 1.1.0 |
|
448 | - * @param string $order_status |
|
449 | - * @param int $order_id |
|
450 | - * @return string |
|
451 | - **/ |
|
452 | - public function virtual_order_payment_complete( $order_status, $order_id ) { |
|
453 | - $order = new WC_Order( $order_id ); |
|
454 | - if ( ! isset ( $order ) ) return ''; |
|
455 | - if ( $order_status == 'wc-processing' && ( $order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed' ) ) { |
|
456 | - $virtual_order = true; |
|
457 | - |
|
458 | - if ( count( $order->get_items() ) > 0 ) { |
|
459 | - foreach( $order->get_items() as $item ) { |
|
460 | - if ( $item['product_id'] > 0 ) { |
|
461 | - $_product = $order->get_product_from_item( $item ); |
|
462 | - if ( ! $_product->is_virtual() ) { |
|
463 | - $virtual_order = false; |
|
464 | - break; |
|
465 | - } // End If Statement |
|
466 | - } // End If Statement |
|
467 | - } // End For Loop |
|
468 | - } // End If Statement |
|
469 | - |
|
470 | - // virtual order, mark as completed |
|
471 | - if ( $virtual_order ) { |
|
472 | - return 'completed'; |
|
473 | - } // End If Statement |
|
474 | - } // End If Statement |
|
475 | - return $order_status; |
|
476 | - } |
|
477 | - |
|
478 | - /** |
|
479 | - * Register the widgets. |
|
480 | - * @access public |
|
481 | - * @since 1.0.0 |
|
482 | - * @return void |
|
483 | - */ |
|
484 | - public function register_widgets () { |
|
485 | - // Widget List (key => value is filename => widget class). |
|
486 | - $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', |
|
487 | - 'lesson-component' => 'Lesson_Component', |
|
488 | - 'course-categories' => 'Course_Categories', |
|
489 | - 'category-courses' => 'Category_Courses' ) |
|
490 | - ); |
|
491 | - foreach ( $widget_list as $key => $value ) { |
|
492 | - if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ) ) { |
|
493 | - require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ); |
|
494 | - register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); |
|
495 | - } |
|
496 | - } // End For Loop |
|
497 | - |
|
498 | - do_action( 'sensei_register_widgets' ); |
|
499 | - |
|
500 | - } // End register_widgets() |
|
501 | - |
|
502 | - /** |
|
503 | - * Load the plugin's localisation file. |
|
504 | - * @access public |
|
505 | - * @since 1.0.0 |
|
506 | - * @return void |
|
507 | - */ |
|
508 | - public function load_localisation () { |
|
509 | - load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
510 | - } // End load_localisation() |
|
511 | - |
|
512 | - /** |
|
513 | - * Load the plugin textdomain from the main WordPress "languages" folder. |
|
514 | - * @access public |
|
515 | - * @since 1.0.0 |
|
516 | - * @return void |
|
517 | - */ |
|
518 | - public function load_plugin_textdomain () { |
|
519 | - $domain = 'woothemes-sensei'; |
|
520 | - // The "plugin_locale" filter is also used in load_plugin_textdomain() |
|
521 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
522 | - load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); |
|
523 | - load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
524 | - } // End load_plugin_textdomain() |
|
525 | - |
|
526 | - /** |
|
527 | - * Run on activation. |
|
528 | - * @access public |
|
529 | - * @since 1.0.0 |
|
530 | - * @return void |
|
531 | - */ |
|
532 | - public function activation () { |
|
533 | - $this->register_plugin_version(); |
|
534 | - } // End activation() |
|
535 | - |
|
536 | - |
|
537 | - /** |
|
538 | - * Register activation hooks. |
|
539 | - * @access public |
|
540 | - * @since 1.0.0 |
|
541 | - * @return void |
|
542 | - */ |
|
543 | - public function install () { |
|
544 | - register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); |
|
545 | - register_activation_hook( $this->file, 'flush_rewrite_rules' ); |
|
546 | - } // End install() |
|
547 | - |
|
548 | - |
|
549 | - /** |
|
550 | - * Run on activation of the plugin. |
|
551 | - * @access public |
|
552 | - * @since 1.0.0 |
|
553 | - * @return void |
|
554 | - */ |
|
555 | - public function activate_sensei () { |
|
556 | - update_option( 'skip_install_sensei_pages', 0 ); |
|
557 | - update_option( 'sensei_installed', 1 ); |
|
558 | - } // End activate_sensei() |
|
559 | - |
|
560 | - /** |
|
561 | - * Register the plugin's version. |
|
562 | - * @access public |
|
563 | - * @since 1.0.0 |
|
564 | - * @return void |
|
565 | - */ |
|
566 | - private function register_plugin_version () { |
|
567 | - if ( $this->version != '' ) { |
|
568 | - |
|
569 | - // Check previous version to see if forced updates must run |
|
570 | - // $old_version = get_option( 'woothemes-sensei-version', false ); |
|
571 | - // if( $old_version && version_compare( $old_version, '1.7.0', '<' ) ) { |
|
572 | - // update_option( 'woothemes-sensei-force-updates', $this->version ); |
|
573 | - // } else { |
|
574 | - // delete_option( 'woothemes-sensei-force-updates' ); |
|
575 | - // } |
|
576 | - |
|
577 | - update_option( 'woothemes-sensei-version', $this->version ); |
|
578 | - } |
|
579 | - } // End register_plugin_version() |
|
580 | - |
|
581 | - /** |
|
582 | - * Ensure that "post-thumbnails" support is available for those themes that don't register it. |
|
583 | - * @access public |
|
584 | - * @since 1.0.1 |
|
585 | - * @return void |
|
586 | - */ |
|
587 | - public function ensure_post_thumbnails_support () { |
|
588 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } |
|
589 | - } // End ensure_post_thumbnails_support() |
|
590 | - |
|
591 | - |
|
592 | - /** |
|
593 | - * template_loader function. |
|
594 | - * |
|
595 | - * @access public |
|
596 | - * @param mixed $template |
|
597 | - * @return void |
|
598 | - * @deprecated |
|
599 | - */ |
|
600 | - public function template_loader ( $template = '' ) { |
|
601 | - |
|
602 | - _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); |
|
603 | - Sensei_Templates::template_loader( $template ); |
|
604 | - |
|
605 | - } // End template_loader() |
|
606 | - |
|
607 | - /** |
|
608 | - * Determine the relative path to the plugin's directory. |
|
609 | - * @access public |
|
610 | - * @since 1.0.0 |
|
611 | - * @return string $sensei_plugin_path |
|
612 | - */ |
|
613 | - public function plugin_path () { |
|
614 | - |
|
615 | - if ( $this->plugin_path ) { |
|
616 | - |
|
617 | - $sensei_plugin_path = $this->plugin_path; |
|
618 | - |
|
619 | - }else{ |
|
620 | - |
|
621 | - $sensei_plugin_path = plugin_dir_path( __FILE__ ); |
|
622 | - |
|
623 | - } |
|
624 | - |
|
625 | - return $sensei_plugin_path; |
|
626 | - |
|
627 | - } // End plugin_path() |
|
628 | - |
|
629 | - |
|
630 | - /** |
|
631 | - * Retrieve the ID of a specified page setting. |
|
632 | - * @access public |
|
633 | - * @since 1.0.0 |
|
634 | - * @param string $page |
|
635 | - * @return int |
|
636 | - */ |
|
637 | - public function get_page_id ( $page ) { |
|
638 | - $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); |
|
639 | - return ( $page ) ? $page : -1; |
|
640 | - } // End get_page_id() |
|
641 | - |
|
642 | - |
|
643 | - /** |
|
644 | - * If WooCommerce is activated and the customer has purchased the course, update Sensei to indicate that they are taking the course. |
|
645 | - * @access public |
|
646 | - * @since 1.0.0 |
|
647 | - * @param int $course_id (default: 0) |
|
648 | - * @param array/Object $order_user (default: array()) Specific user's data. |
|
649 | - * @return bool|int |
|
650 | - */ |
|
651 | - public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
|
652 | - global $current_user; |
|
653 | - |
|
654 | - if ( ! isset( $current_user ) || !$current_user->ID > 0 ) return false; |
|
655 | - |
|
656 | - $data_update = false; |
|
657 | - |
|
658 | - // Get the product ID |
|
659 | - $wc_post_id = get_post_meta( intval( $course_id ), '_course_woocommerce_product', true ); |
|
660 | - |
|
661 | - // Check if in the admin |
|
662 | - if ( is_admin() ) { |
|
663 | - $user_login = $order_user['user_login']; |
|
664 | - $user_email = $order_user['user_email']; |
|
665 | - $user_url = $order_user['user_url']; |
|
666 | - $user_id = $order_user['ID']; |
|
667 | - } else { |
|
668 | - $user_login = $current_user->user_login; |
|
669 | - $user_email = $current_user->user_email; |
|
670 | - $user_url = $current_user->user_url; |
|
671 | - $user_id = $current_user->ID; |
|
672 | - } // End If Statement |
|
673 | - |
|
674 | - // This doesn't appear to be purely WooCommerce related. Should it be in a separate function? |
|
675 | - $course_prerequisite_id = (int) get_post_meta( $course_id, '_course_prerequisite', true ); |
|
676 | - if( 0 < absint( $course_prerequisite_id ) ) { |
|
677 | - $prereq_course_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, intval( $user_id ) ); |
|
678 | - if ( ! $prereq_course_complete ) { |
|
679 | - // Remove all course user meta |
|
680 | - return Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id ); |
|
681 | - } |
|
682 | - } |
|
683 | - |
|
684 | - $is_user_taking_course = Sensei_Utils::user_started_course( intval( $course_id ), intval( $user_id ) ); |
|
685 | - |
|
686 | - if( ! $is_user_taking_course ) { |
|
687 | - |
|
688 | - if ( Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product( $user_email, $user_id, $wc_post_id ) && ( 0 < $wc_post_id ) ) { |
|
689 | - |
|
690 | - $activity_logged = Sensei_Utils::user_start_course( intval( $user_id), intval( $course_id ) ); |
|
691 | - |
|
692 | - $is_user_taking_course = false; |
|
693 | - if ( true == $activity_logged ) { |
|
694 | - $is_user_taking_course = true; |
|
695 | - } // End If Statement |
|
696 | - } // End If Statement |
|
697 | - } |
|
698 | - |
|
699 | - return $is_user_taking_course; |
|
700 | - } // End woocommerce_course_update() |
|
701 | - |
|
702 | - |
|
703 | - /** |
|
704 | - * check_user_permissions function. |
|
705 | - * |
|
706 | - * @access public |
|
707 | - * @param string $page (default: '') |
|
708 | - * |
|
709 | - * @return bool |
|
710 | - */ |
|
711 | - public function check_user_permissions ( $page = '' ) { |
|
712 | - // REFACTOR |
|
713 | - global $current_user, $post; |
|
714 | - |
|
715 | - // if use is not logged in |
|
716 | - // skipped for single lesson |
|
717 | - if ( empty( $current_user->caps ) && Sensei()->settings->get('access_permission') |
|
718 | - && 'lesson-single' != $page ){ |
|
719 | - $this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei' ); |
|
720 | - $this->permissions_message['message'] = sprintf( __('You must be logged in to view this %s'), get_post_type() ); |
|
721 | - return false; |
|
722 | - } |
|
723 | - |
|
724 | - |
|
725 | - // Get User Meta |
|
726 | - get_currentuserinfo(); |
|
727 | - |
|
728 | - $user_allowed = false; |
|
729 | - |
|
730 | - switch ( $page ) { |
|
731 | - case 'course-single': |
|
732 | - // check for prerequisite course or lesson, |
|
733 | - $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true); |
|
734 | - $update_course = $this->woocommerce_course_update( $post->ID ); |
|
735 | - // Count completed lessons |
|
736 | - if ( 0 < absint( $course_prerequisite_id ) ) { |
|
737 | - |
|
738 | - $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); |
|
739 | - |
|
740 | - } |
|
741 | - else { |
|
742 | - $prerequisite_complete = true; |
|
743 | - } // End If Statement |
|
744 | - // Handles restrictions |
|
745 | - if ( !$prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) { |
|
746 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
747 | - $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
748 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ); |
|
749 | - } else { |
|
750 | - $user_allowed = true; |
|
751 | - } // End If Statement |
|
752 | - break; |
|
753 | - case 'lesson-single': |
|
754 | - // Check for WC purchase |
|
755 | - $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); |
|
756 | - |
|
757 | - $update_course = $this->woocommerce_course_update( $lesson_course_id ); |
|
758 | - $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); |
|
759 | - |
|
760 | - if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { |
|
761 | - $user_allowed = true; |
|
762 | - } elseif( $this->access_settings() && false == $is_preview ) { |
|
763 | - |
|
764 | - $user_allowed = true; |
|
765 | - |
|
766 | - } else { |
|
767 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
768 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
769 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
770 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
771 | - if ( $is_preview ) { |
|
772 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
773 | - } else { |
|
774 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); |
|
775 | - } |
|
776 | - } else { |
|
777 | - if ( $is_preview ) { |
|
778 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
779 | - } else { |
|
780 | - /** This filter is documented in class-woothemes-sensei-frontend.php */ |
|
781 | - $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
782 | - } |
|
783 | - } // End If Statement |
|
784 | - } // End If Statement |
|
785 | - break; |
|
786 | - case 'quiz-single': |
|
787 | - $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); |
|
788 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); |
|
789 | - |
|
790 | - $update_course = $this->woocommerce_course_update( $lesson_course_id ); |
|
791 | - if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { |
|
792 | - |
|
793 | - // Check for prerequisite lesson for this quiz |
|
794 | - $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); |
|
795 | - $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); |
|
796 | - |
|
797 | - // Handle restrictions |
|
798 | - if( sensei_all_access() ) { |
|
799 | - $user_allowed = true; |
|
800 | - } else { |
|
801 | - if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { |
|
802 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
803 | - $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; |
|
804 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); |
|
805 | - } else { |
|
806 | - $user_allowed = true; |
|
807 | - } // End If Statement |
|
808 | - } // End If Statement |
|
809 | - } elseif( $this->access_settings() ) { |
|
810 | - // Check if the user has started the course |
|
811 | - |
|
812 | - if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) { |
|
813 | - |
|
814 | - $user_allowed = false; |
|
815 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
816 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
817 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
818 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
819 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
820 | - } else { |
|
821 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
822 | - } // End If Statement |
|
823 | - } else { |
|
824 | - $user_allowed = true; |
|
825 | - } // End If Statement |
|
826 | - } else { |
|
827 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
828 | - $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
829 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
830 | - } // End If Statement |
|
831 | - break; |
|
832 | - default: |
|
833 | - $user_allowed = true; |
|
834 | - break; |
|
835 | - |
|
836 | - } // End Switch Statement |
|
837 | - |
|
838 | - /** |
|
839 | - * filter the permissions message shown on sensei post types. |
|
840 | - * |
|
841 | - * @since 1.8.7 |
|
842 | - * |
|
843 | - * @param array $permissions_message{ |
|
844 | - * |
|
845 | - * @type string $title |
|
846 | - * @type string $message |
|
847 | - * |
|
848 | - * } |
|
849 | - * @param string $post_id |
|
850 | - */ |
|
851 | - $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); |
|
852 | - |
|
853 | - |
|
854 | - if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { |
|
855 | - $user_allowed = true; |
|
856 | - } |
|
857 | - |
|
858 | - return apply_filters( 'sensei_access_permissions', $user_allowed ); |
|
859 | - } // End get_placeholder_image() |
|
860 | - |
|
861 | - |
|
862 | - /** |
|
863 | - * Check if visitors have access permission. If the "access_permission" setting is active, do a log in check. |
|
864 | - * @since 1.0.0 |
|
865 | - * @access public |
|
866 | - * @return bool |
|
867 | - */ |
|
868 | - public function access_settings () { |
|
869 | - |
|
870 | - if( sensei_all_access() ) return true; |
|
871 | - |
|
872 | - if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { |
|
873 | - if ( is_user_logged_in() ) { |
|
874 | - return true; |
|
875 | - } else { |
|
876 | - return false; |
|
877 | - } // End If Statement |
|
878 | - } else { |
|
879 | - return true; |
|
880 | - } // End If Statement |
|
881 | - } // End access_settings() |
|
882 | - |
|
883 | - /** |
|
884 | - * sensei_woocommerce_complete_order description |
|
885 | - * @since 1.0.3 |
|
886 | - * @access public |
|
887 | - * @param int $order_id WC order ID |
|
888 | - * @return void |
|
889 | - */ |
|
890 | - public function sensei_woocommerce_complete_order ( $order_id = 0 ) { |
|
891 | - $order_user = array(); |
|
892 | - // Check for WooCommerce |
|
893 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $order_id ) ) { |
|
894 | - // Get order object |
|
895 | - $order = new WC_Order( $order_id ); |
|
896 | - $user = get_user_by( 'id', $order->get_user_id() ); |
|
897 | - $order_user['ID'] = $user->ID; |
|
898 | - $order_user['user_login'] = $user->user_login; |
|
899 | - $order_user['user_email'] = $user->user_email; |
|
900 | - $order_user['user_url'] = $user->user_url; |
|
901 | - // Run through each product ordered |
|
902 | - if ( 0 < sizeof( $order->get_items() ) ) { |
|
903 | - foreach( $order->get_items() as $item ) { |
|
904 | - $product_type = ''; |
|
905 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
906 | - $item_id = $item['variation_id']; |
|
907 | - $product_type = 'variation'; |
|
908 | - } else { |
|
909 | - $item_id = $item['product_id']; |
|
910 | - } // End If Statement |
|
911 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
912 | - // Get courses that use the WC product |
|
913 | - $courses = $this->post_types->course->get_product_courses( $_product->id ); |
|
914 | - // Loop and update those courses |
|
915 | - foreach ( $courses as $course_item ) { |
|
916 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
917 | - } // End For Loop |
|
918 | - } // End For Loop |
|
919 | - } // End If Statement |
|
920 | - // Add meta to indicate that payment has been completed successfully |
|
921 | - update_post_meta( $order_id, 'sensei_payment_complete', '1' ); |
|
922 | - } // End If Statement |
|
923 | - } // End sensei_woocommerce_complete_order() |
|
924 | - |
|
925 | - /** |
|
926 | - * Runs when an order is cancelled. |
|
927 | - * @since 1.2.0 |
|
928 | - * @access public |
|
929 | - * @param integer $order_id order ID |
|
930 | - * @return void |
|
931 | - */ |
|
932 | - public function sensei_woocommerce_cancel_order ( $order_id ) { |
|
933 | - |
|
934 | - // Get order object |
|
935 | - $order = new WC_Order( $order_id ); |
|
936 | - |
|
937 | - // Run through each product ordered |
|
938 | - if ( 0 < sizeof( $order->get_items() ) ) { |
|
939 | - |
|
940 | - // Get order user |
|
941 | - $user_id = $order->__get( 'user_id' ); |
|
942 | - |
|
943 | - foreach( $order->get_items() as $item ) { |
|
944 | - |
|
945 | - $product_type = ''; |
|
946 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
947 | - $item_id = $item['variation_id']; |
|
948 | - $product_type = 'variation'; |
|
949 | - } else { |
|
950 | - $item_id = $item['product_id']; |
|
951 | - } // End If Statement |
|
952 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
953 | - |
|
954 | - // Get courses that use the WC product |
|
955 | - $courses = array(); |
|
956 | - $courses = $this->post_types->course->get_product_courses( $item_id ); |
|
957 | - |
|
958 | - // Loop and update those courses |
|
959 | - foreach ($courses as $course_item){ |
|
960 | - // Check and Remove course from courses user meta |
|
961 | - $dataset_changes = Sensei_Utils::sensei_remove_user_from_course( $course_item->ID, $user_id ); |
|
962 | - } // End For Loop |
|
963 | - } // End For Loop |
|
964 | - } // End If Statement |
|
965 | - } // End sensei_woocommerce_cancel_order() |
|
966 | - |
|
967 | - /** |
|
968 | - * Runs when an subscription is cancelled or expires. |
|
969 | - * @since 1.3.3 |
|
970 | - * @access public |
|
971 | - * @param integer $user_id User ID |
|
972 | - * @param integer $subscription_key Subscription Unique Key |
|
973 | - * @return void |
|
974 | - */ |
|
975 | - public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ) { |
|
976 | - $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); |
|
977 | - self::sensei_woocommerce_cancel_order( $subscription['order_id'] ); |
|
978 | - } |
|
979 | - |
|
980 | - /** |
|
981 | - * Runs when an subscription is re-activated after suspension. |
|
982 | - * @since 1.3.3 |
|
983 | - * @access public |
|
984 | - * @param integer $user_id User ID |
|
985 | - * @param integer $subscription_key Subscription Unique Key |
|
986 | - * @return void |
|
987 | - */ |
|
988 | - public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ) { |
|
989 | - $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); |
|
990 | - $order = new WC_Order( $subscription['order_id'] ); |
|
991 | - $user = get_user_by( 'id', $order->get_user_id() ); |
|
992 | - $order_user = array(); |
|
993 | - $order_user['ID'] = $user->ID; |
|
994 | - $order_user['user_login'] = $user->user_login; |
|
995 | - $order_user['user_email'] = $user->user_email; |
|
996 | - $order_user['user_url'] = $user->user_url; |
|
997 | - $courses = $this->post_types->course->get_product_courses( $subscription['product_id'] ); |
|
998 | - foreach ( $courses as $course_item ){ |
|
999 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
1000 | - } // End For Loop |
|
1001 | - } // End sensei_woocommerce_reactivate_subscription |
|
1002 | - |
|
1003 | - /** |
|
1004 | - * Returns the WooCommerce Product Object |
|
1005 | - * |
|
1006 | - * The code caters for pre and post WooCommerce 2.2 installations. |
|
1007 | - * |
|
1008 | - * @since 1.1.1 |
|
1009 | - * @access public |
|
1010 | - * @param integer $wc_product_id Product ID or Variation ID |
|
1011 | - * @param string $product_type '' or 'variation' |
|
1012 | - * @return WC_Product $wc_product_object |
|
1013 | - */ |
|
1014 | - public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { |
|
1015 | - |
|
1016 | - $wc_product_object = false; |
|
1017 | - if ( 0 < intval( $wc_product_id ) ) { |
|
1018 | - |
|
1019 | - // Get the product |
|
1020 | - if ( function_exists( 'wc_get_product' ) ) { |
|
1021 | - |
|
1022 | - $wc_product_object = wc_get_product( $wc_product_id ); // Post WC 2.3 |
|
1023 | - |
|
1024 | - } elseif ( function_exists( 'get_product' ) ) { |
|
1025 | - |
|
1026 | - $wc_product_object = get_product( $wc_product_id ); // Post WC 2.0 |
|
1027 | - |
|
1028 | - } else { |
|
1029 | - |
|
1030 | - // Pre WC 2.0 |
|
1031 | - if ( 'variation' == $product_type || 'subscription_variation' == $product_type ) { |
|
1032 | - |
|
1033 | - $wc_product_object = new WC_Product_Variation( $wc_product_id ); |
|
1034 | - |
|
1035 | - } else { |
|
1036 | - |
|
1037 | - $wc_product_object = new WC_Product( $wc_product_id ); |
|
1038 | - |
|
1039 | - } // End If Statement |
|
1040 | - |
|
1041 | - } // End If Statement |
|
1042 | - |
|
1043 | - } // End If Statement |
|
1044 | - |
|
1045 | - return $wc_product_object; |
|
1046 | - |
|
1047 | - } // End sensei_get_woocommerce_product_object() |
|
1048 | - |
|
1049 | - /** |
|
1050 | - * load_class loads in class files |
|
1051 | - * @since 1.2.0 |
|
1052 | - * @access public |
|
1053 | - * @return void |
|
1054 | - */ |
|
1055 | - public function load_class ( $class_name = '' ) { |
|
1056 | - if ( '' != $class_name && '' != $this->token ) { |
|
1057 | - require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); |
|
1058 | - } // End If Statement |
|
1059 | - } // End load_class() |
|
1060 | - |
|
1061 | - /** |
|
1062 | - * sensei_activate_subscription runs when a subscription product is purchased |
|
1063 | - * @since 1.2.0 |
|
1064 | - * @access public |
|
1065 | - * @param integer $order_id order ID |
|
1066 | - * @return void |
|
1067 | - */ |
|
1068 | - public function sensei_activate_subscription( $order_id = 0 ) { |
|
1069 | - if ( 0 < intval( $order_id ) ) { |
|
1070 | - $order = new WC_Order( $order_id ); |
|
1071 | - $user = get_user_by('id', $order->user_id); |
|
1072 | - $order_user['ID'] = $user->ID; |
|
1073 | - $order_user['user_login'] = $user->user_login; |
|
1074 | - $order_user['user_email'] = $user->user_email; |
|
1075 | - $order_user['user_url'] = $user->user_url; |
|
1076 | - // Run through each product ordered |
|
1077 | - if (sizeof($order->get_items())>0) { |
|
1078 | - foreach($order->get_items() as $item) { |
|
1079 | - $product_type = ''; |
|
1080 | - if (isset($item['variation_id']) && $item['variation_id'] > 0) { |
|
1081 | - $item_id = $item['variation_id']; |
|
1082 | - $product_type = 'subscription_variation'; |
|
1083 | - } else { |
|
1084 | - $item_id = $item['product_id']; |
|
1085 | - } // End If Statement |
|
1086 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
1087 | - // Get courses that use the WC product |
|
1088 | - $courses = array(); |
|
1089 | - if ( $product_type == 'subscription_variation' ) { |
|
1090 | - $courses = $this->post_types->course->get_product_courses( $item_id ); |
|
1091 | - } // End If Statement |
|
1092 | - // Loop and update those courses |
|
1093 | - foreach ($courses as $course_item){ |
|
1094 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
1095 | - } // End For Loop |
|
1096 | - } // End For Loop |
|
1097 | - } // End If Statement |
|
1098 | - } // End If Statement |
|
1099 | - } // End sensei_activate_subscription() |
|
1100 | - |
|
1101 | - /** |
|
1102 | - * sensei_woocommerce_email_course_details adds detail to email |
|
1103 | - * @since 1.4.5 |
|
1104 | - * @access public |
|
1105 | - * @param WC_Order $order |
|
1106 | - * @return void |
|
1107 | - */ |
|
1108 | - public function sensei_woocommerce_email_course_details( $order ) { |
|
1109 | - global $woocommerce; |
|
1110 | - |
|
1111 | - // exit early if not wc-completed or wc-processing |
|
1112 | - if( 'wc-completed' != $order->post_status |
|
1113 | - && 'wc-processing' != $order->post_status ) { |
|
1114 | - return; |
|
1115 | - } |
|
1116 | - |
|
1117 | - $order_items = $order->get_items(); |
|
1118 | - $order_id = $order->id; |
|
1119 | - |
|
1120 | - //If object have items go through them all to find course |
|
1121 | - if ( 0 < sizeof( $order_items ) ) { |
|
1122 | - |
|
1123 | - $course_details_html = '<h2>' . __( 'Course details', 'woothemes-sensei' ) . '</h2>'; |
|
1124 | - $order_contains_courses = false; |
|
1125 | - |
|
1126 | - |
|
1127 | - foreach ( $order_items as $item ) { |
|
1128 | - |
|
1129 | - $product_type = ''; |
|
1130 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
1131 | - // If item has variation_id then its from variation |
|
1132 | - $item_id = $item['variation_id']; |
|
1133 | - $product_type = 'variation'; |
|
1134 | - } else { |
|
1135 | - // If not its real product set its id to item_id |
|
1136 | - $item_id = $item['product_id']; |
|
1137 | - } // End If Statement |
|
1138 | - |
|
1139 | - $user_id = get_post_meta( $order_id, '_customer_user', true ); |
|
1140 | - |
|
1141 | - if( $user_id ) { |
|
1142 | - |
|
1143 | - // Get all courses for product |
|
1144 | - $args = array( |
|
1145 | - 'posts_per_page' => -1, |
|
1146 | - 'post_type' => 'course', |
|
1147 | - 'meta_query' => array( |
|
1148 | - array( |
|
1149 | - 'key' => '_course_woocommerce_product', |
|
1150 | - 'value' => $item_id |
|
1151 | - ) |
|
1152 | - ), |
|
1153 | - 'orderby' => 'menu_order date', |
|
1154 | - 'order' => 'ASC', |
|
1155 | - ); |
|
1156 | - $courses = get_posts( $args ); |
|
1157 | - |
|
1158 | - if( $courses && count( $courses ) > 0 ) { |
|
1159 | - |
|
1160 | - foreach( $courses as $course ) { |
|
1161 | - |
|
1162 | - $title = $course->post_title; |
|
1163 | - $permalink = get_permalink( $course->ID ); |
|
1164 | - $order_contains_courses = true; |
|
1165 | - $course_details_html .= '<p><strong>' . sprintf( __( 'View course: %1$s', 'woothemes-sensei' ), '</strong><a href="' . esc_url( $permalink ) . '">' . $title . '</a>' ) . '</p>'; |
|
1166 | - } |
|
1167 | - |
|
1168 | - |
|
1169 | - } // end if has courses |
|
1170 | - |
|
1171 | - } // end if $userPid |
|
1172 | - |
|
1173 | - } // end for each order item |
|
1174 | - |
|
1175 | - // Output Course details |
|
1176 | - if( $order_contains_courses ){ |
|
1177 | - |
|
1178 | - echo $course_details_html; |
|
1179 | - |
|
1180 | - } |
|
1181 | - |
|
1182 | - |
|
1183 | - } // end if order items not empty |
|
1184 | - |
|
1185 | - } // end func email course details |
|
1186 | - |
|
1187 | - /** |
|
1188 | - * Filtering wp_count_comments to ensure that Sensei comments are ignored |
|
1189 | - * @since 1.4.0 |
|
1190 | - * @access public |
|
1191 | - * @param array $comments |
|
1192 | - * @param integer $post_id |
|
1193 | - * @return array |
|
1194 | - */ |
|
1195 | - public function sensei_count_comments( $comments, $post_id ) { |
|
1196 | - global $wpdb; |
|
1197 | - |
|
1198 | - $post_id = (int) $post_id; |
|
1199 | - |
|
1200 | - $count = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1201 | - |
|
1202 | - if ( false !== $count ) { |
|
1203 | - return $count; |
|
1204 | - } |
|
1205 | - |
|
1206 | - $statuses = array( '' ); // Default to the WP normal comments |
|
1207 | - $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); |
|
1208 | - foreach ( (array) $stati AS $status ) { |
|
1209 | - if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { |
|
1210 | - $statuses[] = $status['comment_type']; |
|
1211 | - } |
|
1212 | - } |
|
1213 | - $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; |
|
1214 | - |
|
1215 | - if ( $post_id > 0 ) |
|
1216 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
1217 | - |
|
1218 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1219 | - |
|
1220 | - $total = 0; |
|
1221 | - $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
|
1222 | - foreach ( (array) $count as $row ) { |
|
1223 | - // Don't count post-trashed toward totals |
|
1224 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
1225 | - $total += $row['num_comments']; |
|
1226 | - if ( isset( $approved[$row['comment_approved']] ) ) |
|
1227 | - $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1228 | - } |
|
1229 | - |
|
1230 | - $stats['total_comments'] = $total; |
|
1231 | - foreach ( $approved as $key ) { |
|
1232 | - if ( empty($stats[$key]) ) |
|
1233 | - $stats[$key] = 0; |
|
1234 | - } |
|
1235 | - |
|
1236 | - $stats = (object) $stats; |
|
1237 | - wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1238 | - |
|
1239 | - return $stats; |
|
1240 | - } |
|
1241 | - |
|
1242 | - /** |
|
1243 | - * Init images. |
|
1244 | - * |
|
1245 | - * @since 1.4.5 |
|
1246 | - * @access public |
|
1247 | - * @return void |
|
1248 | - */ |
|
1249 | - public function init_image_sizes() { |
|
1250 | - $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); |
|
1251 | - $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); |
|
1252 | - $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); |
|
1253 | - $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); |
|
1254 | - |
|
1255 | - add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); |
|
1256 | - add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); |
|
1257 | - add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); |
|
1258 | - add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); |
|
1259 | - } |
|
1260 | - |
|
1261 | - /** |
|
1262 | - * Get an image size. |
|
1263 | - * |
|
1264 | - * Variable is filtered by sensei_get_image_size_{image_size} |
|
1265 | - * |
|
1266 | - * @since 1.4.5 |
|
1267 | - * @access public |
|
1268 | - * @param mixed $image_size |
|
1269 | - * @return string |
|
1270 | - */ |
|
1271 | - public function get_image_size( $image_size ) { |
|
1272 | - |
|
1273 | - // Only return sizes we define in settings |
|
1274 | - if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) |
|
1275 | - return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
1276 | - |
|
1277 | - if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { |
|
1278 | - $this->settings->settings[ $image_size . '_width' ] = false; |
|
1279 | - } |
|
1280 | - if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { |
|
1281 | - $this->settings->settings[ $image_size . '_height' ] = false; |
|
1282 | - } |
|
1283 | - if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { |
|
1284 | - $this->settings->settings[ $image_size . '_hard_crop' ] = false; |
|
1285 | - } |
|
1286 | - |
|
1287 | - $size = array_filter( array( |
|
1288 | - 'width' => $this->settings->settings[ $image_size . '_width' ], |
|
1289 | - 'height' => $this->settings->settings[ $image_size . '_height' ], |
|
1290 | - 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] |
|
1291 | - ) ); |
|
1292 | - |
|
1293 | - $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; |
|
1294 | - $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; |
|
1295 | - $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; |
|
1296 | - |
|
1297 | - return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); |
|
1298 | - } |
|
1299 | - |
|
1300 | - public function body_class( $classes ) { |
|
1301 | - if( is_sensei() ) { |
|
1302 | - $classes[] = 'sensei'; |
|
1303 | - } |
|
1304 | - return $classes; |
|
1305 | - } |
|
1306 | - |
|
1307 | - /** |
|
1308 | - * Checks that the Jetpack Beautiful Maths module has been activated to support LaTeX within question titles and answers |
|
1309 | - * |
|
1310 | - * @return null |
|
1311 | - * @since 1.7.0 |
|
1312 | - */ |
|
1313 | - public function jetpack_latex_support() { |
|
1314 | - if ( function_exists( 'latex_markup') ) { |
|
1315 | - add_filter( 'sensei_question_title', 'latex_markup' ); |
|
1316 | - add_filter( 'sensei_answer_text', 'latex_markup' ); |
|
1317 | - } |
|
1318 | - } |
|
1319 | - |
|
1320 | - /** |
|
1321 | - * Load the module functionality. |
|
1322 | - * |
|
1323 | - * This function is hooked into plugins_loaded to avoid conflicts with |
|
1324 | - * the retired modules extension. |
|
1325 | - * |
|
1326 | - * @since 1.8.0 |
|
1327 | - */ |
|
1328 | - public function load_modules_class(){ |
|
1329 | - global $sensei_modules; |
|
1330 | - |
|
1331 | - if( !class_exists( 'Sensei_Modules' ) |
|
1332 | - && 'Sensei_Modules' != get_class( $sensei_modules ) ) { |
|
1333 | - |
|
1334 | - //Load the modules class |
|
1335 | - require_once( 'class-sensei-modules.php'); |
|
1336 | - Sensei()->modules = new Sensei_Core_Modules( $this->file ); |
|
1337 | - |
|
1338 | - }else{ |
|
1339 | - // fallback for people still using the modules extension. |
|
1340 | - global $sensei_modules; |
|
1341 | - Sensei()->modules = $sensei_modules; |
|
1342 | - add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); |
|
1343 | - } |
|
1344 | - } |
|
1345 | - |
|
1346 | - /** |
|
1347 | - * Tell the user to that the modules extension is no longer needed. |
|
1348 | - * |
|
1349 | - * @since 1.8.0 |
|
1350 | - */ |
|
1351 | - public function disable_sensei_modules_extension(){ ?> |
|
333 | + /** |
|
334 | + * Initialize all Sensei hooks |
|
335 | + * |
|
336 | + * @since 1.9.0 |
|
337 | + */ |
|
338 | + public function load_hooks(){ |
|
339 | + |
|
340 | + add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
341 | + add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); |
|
342 | + |
|
343 | + // WooCommerce Payment Actions |
|
344 | + add_action( 'woocommerce_payment_complete' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
345 | + add_action( 'woocommerce_thankyou' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
346 | + add_action( 'woocommerce_order_status_completed' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
347 | + add_action( 'woocommerce_order_status_processing' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
348 | + add_action( 'woocommerce_order_status_cancelled' , array( $this, 'sensei_woocommerce_cancel_order' ) ); |
|
349 | + add_action( 'woocommerce_order_status_refunded' , array( $this, 'sensei_woocommerce_cancel_order' ) ); |
|
350 | + add_action( 'subscriptions_activated_for_order', array( $this, 'sensei_activate_subscription' ) ); |
|
351 | + |
|
352 | + // WooCommerce Subscriptions Actions |
|
353 | + add_action( 'reactivated_subscription', array( $this, 'sensei_woocommerce_reactivate_subscription' ), 10, 2 ); |
|
354 | + add_action( 'subscription_expired' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
355 | + add_action( 'subscription_end_of_prepaid_term' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
356 | + add_action( 'cancelled_subscription' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
357 | + add_action( 'subscription_put_on-hold' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
358 | + |
|
359 | + // Add Email link to course orders |
|
360 | + add_action( 'woocommerce_email_after_order_table', array( $this, 'sensei_woocommerce_email_course_details' ), 10, 1 ); |
|
361 | + |
|
362 | + // Filter comment counts |
|
363 | + add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); |
|
364 | + |
|
365 | + add_action( 'body_class', array( $this, 'body_class' ) ); |
|
366 | + |
|
367 | + // Check for and activate JetPack LaTeX support |
|
368 | + add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules |
|
369 | + |
|
370 | + // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 |
|
371 | + add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); |
|
372 | + |
|
373 | + } |
|
374 | + |
|
375 | + /** |
|
376 | + * Run Sensei updates. |
|
377 | + * @access public |
|
378 | + * @since 1.1.0 |
|
379 | + * @return void |
|
380 | + */ |
|
381 | + public function run_updates() { |
|
382 | + // Run updates if administrator |
|
383 | + if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { |
|
384 | + |
|
385 | + $this->updates->update(); |
|
386 | + |
|
387 | + } // End If Statement |
|
388 | + } // End run_updates() |
|
389 | + |
|
390 | + |
|
391 | + |
|
392 | + /** |
|
393 | + * Setup required WooCommerce settings. |
|
394 | + * @access public |
|
395 | + * @since 1.1.0 |
|
396 | + * @return void |
|
397 | + */ |
|
398 | + public function set_woocommerce_functionality() { |
|
399 | + // Disable guest checkout if a course is in the cart as we need a valid user to store data for |
|
400 | + add_filter( 'pre_option_woocommerce_enable_guest_checkout', array( $this, 'disable_guest_checkout' ) ); |
|
401 | + |
|
402 | + // Mark orders with virtual products as complete rather then stay processing |
|
403 | + add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'virtual_order_payment_complete' ), 10, 2 ); |
|
404 | + |
|
405 | + } // End set_woocommerce_functionality() |
|
406 | + |
|
407 | + /** |
|
408 | + * Disable guest checkout if a course product is in the cart |
|
409 | + * @param boolean $guest_checkout Current guest checkout setting |
|
410 | + * @return boolean Modified guest checkout setting |
|
411 | + */ |
|
412 | + public function disable_guest_checkout( $guest_checkout ) { |
|
413 | + global $woocommerce; |
|
414 | + |
|
415 | + if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
416 | + |
|
417 | + if( isset( $woocommerce->cart->cart_contents ) && count( $woocommerce->cart->cart_contents ) > 0 ) { |
|
418 | + foreach( $woocommerce->cart->cart_contents as $cart_key => $product ) { |
|
419 | + if( isset( $product['product_id'] ) ) { |
|
420 | + $args = array( |
|
421 | + 'posts_per_page' => -1, |
|
422 | + 'post_type' => 'course', |
|
423 | + 'meta_query' => array( |
|
424 | + array( |
|
425 | + 'key' => '_course_woocommerce_product', |
|
426 | + 'value' => $product['product_id'] |
|
427 | + ) |
|
428 | + ) |
|
429 | + ); |
|
430 | + $posts = get_posts( $args ); |
|
431 | + if( $posts && count( $posts ) > 0 ) { |
|
432 | + foreach( $posts as $course ) { |
|
433 | + $guest_checkout = ''; |
|
434 | + break; |
|
435 | + } |
|
436 | + } |
|
437 | + } |
|
438 | + } |
|
439 | + } |
|
440 | + } |
|
441 | + |
|
442 | + return $guest_checkout; |
|
443 | + } |
|
444 | + |
|
445 | + /** |
|
446 | + * Change order status with virtual products to completed |
|
447 | + * @since 1.1.0 |
|
448 | + * @param string $order_status |
|
449 | + * @param int $order_id |
|
450 | + * @return string |
|
451 | + **/ |
|
452 | + public function virtual_order_payment_complete( $order_status, $order_id ) { |
|
453 | + $order = new WC_Order( $order_id ); |
|
454 | + if ( ! isset ( $order ) ) return ''; |
|
455 | + if ( $order_status == 'wc-processing' && ( $order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed' ) ) { |
|
456 | + $virtual_order = true; |
|
457 | + |
|
458 | + if ( count( $order->get_items() ) > 0 ) { |
|
459 | + foreach( $order->get_items() as $item ) { |
|
460 | + if ( $item['product_id'] > 0 ) { |
|
461 | + $_product = $order->get_product_from_item( $item ); |
|
462 | + if ( ! $_product->is_virtual() ) { |
|
463 | + $virtual_order = false; |
|
464 | + break; |
|
465 | + } // End If Statement |
|
466 | + } // End If Statement |
|
467 | + } // End For Loop |
|
468 | + } // End If Statement |
|
469 | + |
|
470 | + // virtual order, mark as completed |
|
471 | + if ( $virtual_order ) { |
|
472 | + return 'completed'; |
|
473 | + } // End If Statement |
|
474 | + } // End If Statement |
|
475 | + return $order_status; |
|
476 | + } |
|
477 | + |
|
478 | + /** |
|
479 | + * Register the widgets. |
|
480 | + * @access public |
|
481 | + * @since 1.0.0 |
|
482 | + * @return void |
|
483 | + */ |
|
484 | + public function register_widgets () { |
|
485 | + // Widget List (key => value is filename => widget class). |
|
486 | + $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', |
|
487 | + 'lesson-component' => 'Lesson_Component', |
|
488 | + 'course-categories' => 'Course_Categories', |
|
489 | + 'category-courses' => 'Category_Courses' ) |
|
490 | + ); |
|
491 | + foreach ( $widget_list as $key => $value ) { |
|
492 | + if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ) ) { |
|
493 | + require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ); |
|
494 | + register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); |
|
495 | + } |
|
496 | + } // End For Loop |
|
497 | + |
|
498 | + do_action( 'sensei_register_widgets' ); |
|
499 | + |
|
500 | + } // End register_widgets() |
|
501 | + |
|
502 | + /** |
|
503 | + * Load the plugin's localisation file. |
|
504 | + * @access public |
|
505 | + * @since 1.0.0 |
|
506 | + * @return void |
|
507 | + */ |
|
508 | + public function load_localisation () { |
|
509 | + load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
510 | + } // End load_localisation() |
|
511 | + |
|
512 | + /** |
|
513 | + * Load the plugin textdomain from the main WordPress "languages" folder. |
|
514 | + * @access public |
|
515 | + * @since 1.0.0 |
|
516 | + * @return void |
|
517 | + */ |
|
518 | + public function load_plugin_textdomain () { |
|
519 | + $domain = 'woothemes-sensei'; |
|
520 | + // The "plugin_locale" filter is also used in load_plugin_textdomain() |
|
521 | + $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
522 | + load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); |
|
523 | + load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
524 | + } // End load_plugin_textdomain() |
|
525 | + |
|
526 | + /** |
|
527 | + * Run on activation. |
|
528 | + * @access public |
|
529 | + * @since 1.0.0 |
|
530 | + * @return void |
|
531 | + */ |
|
532 | + public function activation () { |
|
533 | + $this->register_plugin_version(); |
|
534 | + } // End activation() |
|
535 | + |
|
536 | + |
|
537 | + /** |
|
538 | + * Register activation hooks. |
|
539 | + * @access public |
|
540 | + * @since 1.0.0 |
|
541 | + * @return void |
|
542 | + */ |
|
543 | + public function install () { |
|
544 | + register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); |
|
545 | + register_activation_hook( $this->file, 'flush_rewrite_rules' ); |
|
546 | + } // End install() |
|
547 | + |
|
548 | + |
|
549 | + /** |
|
550 | + * Run on activation of the plugin. |
|
551 | + * @access public |
|
552 | + * @since 1.0.0 |
|
553 | + * @return void |
|
554 | + */ |
|
555 | + public function activate_sensei () { |
|
556 | + update_option( 'skip_install_sensei_pages', 0 ); |
|
557 | + update_option( 'sensei_installed', 1 ); |
|
558 | + } // End activate_sensei() |
|
559 | + |
|
560 | + /** |
|
561 | + * Register the plugin's version. |
|
562 | + * @access public |
|
563 | + * @since 1.0.0 |
|
564 | + * @return void |
|
565 | + */ |
|
566 | + private function register_plugin_version () { |
|
567 | + if ( $this->version != '' ) { |
|
568 | + |
|
569 | + // Check previous version to see if forced updates must run |
|
570 | + // $old_version = get_option( 'woothemes-sensei-version', false ); |
|
571 | + // if( $old_version && version_compare( $old_version, '1.7.0', '<' ) ) { |
|
572 | + // update_option( 'woothemes-sensei-force-updates', $this->version ); |
|
573 | + // } else { |
|
574 | + // delete_option( 'woothemes-sensei-force-updates' ); |
|
575 | + // } |
|
576 | + |
|
577 | + update_option( 'woothemes-sensei-version', $this->version ); |
|
578 | + } |
|
579 | + } // End register_plugin_version() |
|
580 | + |
|
581 | + /** |
|
582 | + * Ensure that "post-thumbnails" support is available for those themes that don't register it. |
|
583 | + * @access public |
|
584 | + * @since 1.0.1 |
|
585 | + * @return void |
|
586 | + */ |
|
587 | + public function ensure_post_thumbnails_support () { |
|
588 | + if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } |
|
589 | + } // End ensure_post_thumbnails_support() |
|
590 | + |
|
591 | + |
|
592 | + /** |
|
593 | + * template_loader function. |
|
594 | + * |
|
595 | + * @access public |
|
596 | + * @param mixed $template |
|
597 | + * @return void |
|
598 | + * @deprecated |
|
599 | + */ |
|
600 | + public function template_loader ( $template = '' ) { |
|
601 | + |
|
602 | + _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); |
|
603 | + Sensei_Templates::template_loader( $template ); |
|
604 | + |
|
605 | + } // End template_loader() |
|
606 | + |
|
607 | + /** |
|
608 | + * Determine the relative path to the plugin's directory. |
|
609 | + * @access public |
|
610 | + * @since 1.0.0 |
|
611 | + * @return string $sensei_plugin_path |
|
612 | + */ |
|
613 | + public function plugin_path () { |
|
614 | + |
|
615 | + if ( $this->plugin_path ) { |
|
616 | + |
|
617 | + $sensei_plugin_path = $this->plugin_path; |
|
618 | + |
|
619 | + }else{ |
|
620 | + |
|
621 | + $sensei_plugin_path = plugin_dir_path( __FILE__ ); |
|
622 | + |
|
623 | + } |
|
624 | + |
|
625 | + return $sensei_plugin_path; |
|
626 | + |
|
627 | + } // End plugin_path() |
|
628 | + |
|
629 | + |
|
630 | + /** |
|
631 | + * Retrieve the ID of a specified page setting. |
|
632 | + * @access public |
|
633 | + * @since 1.0.0 |
|
634 | + * @param string $page |
|
635 | + * @return int |
|
636 | + */ |
|
637 | + public function get_page_id ( $page ) { |
|
638 | + $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); |
|
639 | + return ( $page ) ? $page : -1; |
|
640 | + } // End get_page_id() |
|
641 | + |
|
642 | + |
|
643 | + /** |
|
644 | + * If WooCommerce is activated and the customer has purchased the course, update Sensei to indicate that they are taking the course. |
|
645 | + * @access public |
|
646 | + * @since 1.0.0 |
|
647 | + * @param int $course_id (default: 0) |
|
648 | + * @param array/Object $order_user (default: array()) Specific user's data. |
|
649 | + * @return bool|int |
|
650 | + */ |
|
651 | + public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
|
652 | + global $current_user; |
|
653 | + |
|
654 | + if ( ! isset( $current_user ) || !$current_user->ID > 0 ) return false; |
|
655 | + |
|
656 | + $data_update = false; |
|
657 | + |
|
658 | + // Get the product ID |
|
659 | + $wc_post_id = get_post_meta( intval( $course_id ), '_course_woocommerce_product', true ); |
|
660 | + |
|
661 | + // Check if in the admin |
|
662 | + if ( is_admin() ) { |
|
663 | + $user_login = $order_user['user_login']; |
|
664 | + $user_email = $order_user['user_email']; |
|
665 | + $user_url = $order_user['user_url']; |
|
666 | + $user_id = $order_user['ID']; |
|
667 | + } else { |
|
668 | + $user_login = $current_user->user_login; |
|
669 | + $user_email = $current_user->user_email; |
|
670 | + $user_url = $current_user->user_url; |
|
671 | + $user_id = $current_user->ID; |
|
672 | + } // End If Statement |
|
673 | + |
|
674 | + // This doesn't appear to be purely WooCommerce related. Should it be in a separate function? |
|
675 | + $course_prerequisite_id = (int) get_post_meta( $course_id, '_course_prerequisite', true ); |
|
676 | + if( 0 < absint( $course_prerequisite_id ) ) { |
|
677 | + $prereq_course_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, intval( $user_id ) ); |
|
678 | + if ( ! $prereq_course_complete ) { |
|
679 | + // Remove all course user meta |
|
680 | + return Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id ); |
|
681 | + } |
|
682 | + } |
|
683 | + |
|
684 | + $is_user_taking_course = Sensei_Utils::user_started_course( intval( $course_id ), intval( $user_id ) ); |
|
685 | + |
|
686 | + if( ! $is_user_taking_course ) { |
|
687 | + |
|
688 | + if ( Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product( $user_email, $user_id, $wc_post_id ) && ( 0 < $wc_post_id ) ) { |
|
689 | + |
|
690 | + $activity_logged = Sensei_Utils::user_start_course( intval( $user_id), intval( $course_id ) ); |
|
691 | + |
|
692 | + $is_user_taking_course = false; |
|
693 | + if ( true == $activity_logged ) { |
|
694 | + $is_user_taking_course = true; |
|
695 | + } // End If Statement |
|
696 | + } // End If Statement |
|
697 | + } |
|
698 | + |
|
699 | + return $is_user_taking_course; |
|
700 | + } // End woocommerce_course_update() |
|
701 | + |
|
702 | + |
|
703 | + /** |
|
704 | + * check_user_permissions function. |
|
705 | + * |
|
706 | + * @access public |
|
707 | + * @param string $page (default: '') |
|
708 | + * |
|
709 | + * @return bool |
|
710 | + */ |
|
711 | + public function check_user_permissions ( $page = '' ) { |
|
712 | + // REFACTOR |
|
713 | + global $current_user, $post; |
|
714 | + |
|
715 | + // if use is not logged in |
|
716 | + // skipped for single lesson |
|
717 | + if ( empty( $current_user->caps ) && Sensei()->settings->get('access_permission') |
|
718 | + && 'lesson-single' != $page ){ |
|
719 | + $this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei' ); |
|
720 | + $this->permissions_message['message'] = sprintf( __('You must be logged in to view this %s'), get_post_type() ); |
|
721 | + return false; |
|
722 | + } |
|
723 | + |
|
724 | + |
|
725 | + // Get User Meta |
|
726 | + get_currentuserinfo(); |
|
727 | + |
|
728 | + $user_allowed = false; |
|
729 | + |
|
730 | + switch ( $page ) { |
|
731 | + case 'course-single': |
|
732 | + // check for prerequisite course or lesson, |
|
733 | + $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true); |
|
734 | + $update_course = $this->woocommerce_course_update( $post->ID ); |
|
735 | + // Count completed lessons |
|
736 | + if ( 0 < absint( $course_prerequisite_id ) ) { |
|
737 | + |
|
738 | + $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); |
|
739 | + |
|
740 | + } |
|
741 | + else { |
|
742 | + $prerequisite_complete = true; |
|
743 | + } // End If Statement |
|
744 | + // Handles restrictions |
|
745 | + if ( !$prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) { |
|
746 | + $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
747 | + $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
748 | + $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ); |
|
749 | + } else { |
|
750 | + $user_allowed = true; |
|
751 | + } // End If Statement |
|
752 | + break; |
|
753 | + case 'lesson-single': |
|
754 | + // Check for WC purchase |
|
755 | + $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); |
|
756 | + |
|
757 | + $update_course = $this->woocommerce_course_update( $lesson_course_id ); |
|
758 | + $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); |
|
759 | + |
|
760 | + if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { |
|
761 | + $user_allowed = true; |
|
762 | + } elseif( $this->access_settings() && false == $is_preview ) { |
|
763 | + |
|
764 | + $user_allowed = true; |
|
765 | + |
|
766 | + } else { |
|
767 | + $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
768 | + $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
769 | + $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
770 | + if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
771 | + if ( $is_preview ) { |
|
772 | + $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
773 | + } else { |
|
774 | + $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); |
|
775 | + } |
|
776 | + } else { |
|
777 | + if ( $is_preview ) { |
|
778 | + $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
779 | + } else { |
|
780 | + /** This filter is documented in class-woothemes-sensei-frontend.php */ |
|
781 | + $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
782 | + } |
|
783 | + } // End If Statement |
|
784 | + } // End If Statement |
|
785 | + break; |
|
786 | + case 'quiz-single': |
|
787 | + $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); |
|
788 | + $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); |
|
789 | + |
|
790 | + $update_course = $this->woocommerce_course_update( $lesson_course_id ); |
|
791 | + if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { |
|
792 | + |
|
793 | + // Check for prerequisite lesson for this quiz |
|
794 | + $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); |
|
795 | + $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); |
|
796 | + |
|
797 | + // Handle restrictions |
|
798 | + if( sensei_all_access() ) { |
|
799 | + $user_allowed = true; |
|
800 | + } else { |
|
801 | + if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { |
|
802 | + $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
803 | + $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; |
|
804 | + $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); |
|
805 | + } else { |
|
806 | + $user_allowed = true; |
|
807 | + } // End If Statement |
|
808 | + } // End If Statement |
|
809 | + } elseif( $this->access_settings() ) { |
|
810 | + // Check if the user has started the course |
|
811 | + |
|
812 | + if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) { |
|
813 | + |
|
814 | + $user_allowed = false; |
|
815 | + $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
816 | + $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
817 | + $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
818 | + if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
819 | + $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
820 | + } else { |
|
821 | + $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
822 | + } // End If Statement |
|
823 | + } else { |
|
824 | + $user_allowed = true; |
|
825 | + } // End If Statement |
|
826 | + } else { |
|
827 | + $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
828 | + $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
829 | + $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
830 | + } // End If Statement |
|
831 | + break; |
|
832 | + default: |
|
833 | + $user_allowed = true; |
|
834 | + break; |
|
835 | + |
|
836 | + } // End Switch Statement |
|
837 | + |
|
838 | + /** |
|
839 | + * filter the permissions message shown on sensei post types. |
|
840 | + * |
|
841 | + * @since 1.8.7 |
|
842 | + * |
|
843 | + * @param array $permissions_message{ |
|
844 | + * |
|
845 | + * @type string $title |
|
846 | + * @type string $message |
|
847 | + * |
|
848 | + * } |
|
849 | + * @param string $post_id |
|
850 | + */ |
|
851 | + $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); |
|
852 | + |
|
853 | + |
|
854 | + if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { |
|
855 | + $user_allowed = true; |
|
856 | + } |
|
857 | + |
|
858 | + return apply_filters( 'sensei_access_permissions', $user_allowed ); |
|
859 | + } // End get_placeholder_image() |
|
860 | + |
|
861 | + |
|
862 | + /** |
|
863 | + * Check if visitors have access permission. If the "access_permission" setting is active, do a log in check. |
|
864 | + * @since 1.0.0 |
|
865 | + * @access public |
|
866 | + * @return bool |
|
867 | + */ |
|
868 | + public function access_settings () { |
|
869 | + |
|
870 | + if( sensei_all_access() ) return true; |
|
871 | + |
|
872 | + if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { |
|
873 | + if ( is_user_logged_in() ) { |
|
874 | + return true; |
|
875 | + } else { |
|
876 | + return false; |
|
877 | + } // End If Statement |
|
878 | + } else { |
|
879 | + return true; |
|
880 | + } // End If Statement |
|
881 | + } // End access_settings() |
|
882 | + |
|
883 | + /** |
|
884 | + * sensei_woocommerce_complete_order description |
|
885 | + * @since 1.0.3 |
|
886 | + * @access public |
|
887 | + * @param int $order_id WC order ID |
|
888 | + * @return void |
|
889 | + */ |
|
890 | + public function sensei_woocommerce_complete_order ( $order_id = 0 ) { |
|
891 | + $order_user = array(); |
|
892 | + // Check for WooCommerce |
|
893 | + if ( Sensei_WC::is_woocommerce_active() && ( 0 < $order_id ) ) { |
|
894 | + // Get order object |
|
895 | + $order = new WC_Order( $order_id ); |
|
896 | + $user = get_user_by( 'id', $order->get_user_id() ); |
|
897 | + $order_user['ID'] = $user->ID; |
|
898 | + $order_user['user_login'] = $user->user_login; |
|
899 | + $order_user['user_email'] = $user->user_email; |
|
900 | + $order_user['user_url'] = $user->user_url; |
|
901 | + // Run through each product ordered |
|
902 | + if ( 0 < sizeof( $order->get_items() ) ) { |
|
903 | + foreach( $order->get_items() as $item ) { |
|
904 | + $product_type = ''; |
|
905 | + if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
906 | + $item_id = $item['variation_id']; |
|
907 | + $product_type = 'variation'; |
|
908 | + } else { |
|
909 | + $item_id = $item['product_id']; |
|
910 | + } // End If Statement |
|
911 | + $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
912 | + // Get courses that use the WC product |
|
913 | + $courses = $this->post_types->course->get_product_courses( $_product->id ); |
|
914 | + // Loop and update those courses |
|
915 | + foreach ( $courses as $course_item ) { |
|
916 | + $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
917 | + } // End For Loop |
|
918 | + } // End For Loop |
|
919 | + } // End If Statement |
|
920 | + // Add meta to indicate that payment has been completed successfully |
|
921 | + update_post_meta( $order_id, 'sensei_payment_complete', '1' ); |
|
922 | + } // End If Statement |
|
923 | + } // End sensei_woocommerce_complete_order() |
|
924 | + |
|
925 | + /** |
|
926 | + * Runs when an order is cancelled. |
|
927 | + * @since 1.2.0 |
|
928 | + * @access public |
|
929 | + * @param integer $order_id order ID |
|
930 | + * @return void |
|
931 | + */ |
|
932 | + public function sensei_woocommerce_cancel_order ( $order_id ) { |
|
933 | + |
|
934 | + // Get order object |
|
935 | + $order = new WC_Order( $order_id ); |
|
936 | + |
|
937 | + // Run through each product ordered |
|
938 | + if ( 0 < sizeof( $order->get_items() ) ) { |
|
939 | + |
|
940 | + // Get order user |
|
941 | + $user_id = $order->__get( 'user_id' ); |
|
942 | + |
|
943 | + foreach( $order->get_items() as $item ) { |
|
944 | + |
|
945 | + $product_type = ''; |
|
946 | + if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
947 | + $item_id = $item['variation_id']; |
|
948 | + $product_type = 'variation'; |
|
949 | + } else { |
|
950 | + $item_id = $item['product_id']; |
|
951 | + } // End If Statement |
|
952 | + $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
953 | + |
|
954 | + // Get courses that use the WC product |
|
955 | + $courses = array(); |
|
956 | + $courses = $this->post_types->course->get_product_courses( $item_id ); |
|
957 | + |
|
958 | + // Loop and update those courses |
|
959 | + foreach ($courses as $course_item){ |
|
960 | + // Check and Remove course from courses user meta |
|
961 | + $dataset_changes = Sensei_Utils::sensei_remove_user_from_course( $course_item->ID, $user_id ); |
|
962 | + } // End For Loop |
|
963 | + } // End For Loop |
|
964 | + } // End If Statement |
|
965 | + } // End sensei_woocommerce_cancel_order() |
|
966 | + |
|
967 | + /** |
|
968 | + * Runs when an subscription is cancelled or expires. |
|
969 | + * @since 1.3.3 |
|
970 | + * @access public |
|
971 | + * @param integer $user_id User ID |
|
972 | + * @param integer $subscription_key Subscription Unique Key |
|
973 | + * @return void |
|
974 | + */ |
|
975 | + public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ) { |
|
976 | + $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); |
|
977 | + self::sensei_woocommerce_cancel_order( $subscription['order_id'] ); |
|
978 | + } |
|
979 | + |
|
980 | + /** |
|
981 | + * Runs when an subscription is re-activated after suspension. |
|
982 | + * @since 1.3.3 |
|
983 | + * @access public |
|
984 | + * @param integer $user_id User ID |
|
985 | + * @param integer $subscription_key Subscription Unique Key |
|
986 | + * @return void |
|
987 | + */ |
|
988 | + public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ) { |
|
989 | + $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); |
|
990 | + $order = new WC_Order( $subscription['order_id'] ); |
|
991 | + $user = get_user_by( 'id', $order->get_user_id() ); |
|
992 | + $order_user = array(); |
|
993 | + $order_user['ID'] = $user->ID; |
|
994 | + $order_user['user_login'] = $user->user_login; |
|
995 | + $order_user['user_email'] = $user->user_email; |
|
996 | + $order_user['user_url'] = $user->user_url; |
|
997 | + $courses = $this->post_types->course->get_product_courses( $subscription['product_id'] ); |
|
998 | + foreach ( $courses as $course_item ){ |
|
999 | + $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
1000 | + } // End For Loop |
|
1001 | + } // End sensei_woocommerce_reactivate_subscription |
|
1002 | + |
|
1003 | + /** |
|
1004 | + * Returns the WooCommerce Product Object |
|
1005 | + * |
|
1006 | + * The code caters for pre and post WooCommerce 2.2 installations. |
|
1007 | + * |
|
1008 | + * @since 1.1.1 |
|
1009 | + * @access public |
|
1010 | + * @param integer $wc_product_id Product ID or Variation ID |
|
1011 | + * @param string $product_type '' or 'variation' |
|
1012 | + * @return WC_Product $wc_product_object |
|
1013 | + */ |
|
1014 | + public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { |
|
1015 | + |
|
1016 | + $wc_product_object = false; |
|
1017 | + if ( 0 < intval( $wc_product_id ) ) { |
|
1018 | + |
|
1019 | + // Get the product |
|
1020 | + if ( function_exists( 'wc_get_product' ) ) { |
|
1021 | + |
|
1022 | + $wc_product_object = wc_get_product( $wc_product_id ); // Post WC 2.3 |
|
1023 | + |
|
1024 | + } elseif ( function_exists( 'get_product' ) ) { |
|
1025 | + |
|
1026 | + $wc_product_object = get_product( $wc_product_id ); // Post WC 2.0 |
|
1027 | + |
|
1028 | + } else { |
|
1029 | + |
|
1030 | + // Pre WC 2.0 |
|
1031 | + if ( 'variation' == $product_type || 'subscription_variation' == $product_type ) { |
|
1032 | + |
|
1033 | + $wc_product_object = new WC_Product_Variation( $wc_product_id ); |
|
1034 | + |
|
1035 | + } else { |
|
1036 | + |
|
1037 | + $wc_product_object = new WC_Product( $wc_product_id ); |
|
1038 | + |
|
1039 | + } // End If Statement |
|
1040 | + |
|
1041 | + } // End If Statement |
|
1042 | + |
|
1043 | + } // End If Statement |
|
1044 | + |
|
1045 | + return $wc_product_object; |
|
1046 | + |
|
1047 | + } // End sensei_get_woocommerce_product_object() |
|
1048 | + |
|
1049 | + /** |
|
1050 | + * load_class loads in class files |
|
1051 | + * @since 1.2.0 |
|
1052 | + * @access public |
|
1053 | + * @return void |
|
1054 | + */ |
|
1055 | + public function load_class ( $class_name = '' ) { |
|
1056 | + if ( '' != $class_name && '' != $this->token ) { |
|
1057 | + require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); |
|
1058 | + } // End If Statement |
|
1059 | + } // End load_class() |
|
1060 | + |
|
1061 | + /** |
|
1062 | + * sensei_activate_subscription runs when a subscription product is purchased |
|
1063 | + * @since 1.2.0 |
|
1064 | + * @access public |
|
1065 | + * @param integer $order_id order ID |
|
1066 | + * @return void |
|
1067 | + */ |
|
1068 | + public function sensei_activate_subscription( $order_id = 0 ) { |
|
1069 | + if ( 0 < intval( $order_id ) ) { |
|
1070 | + $order = new WC_Order( $order_id ); |
|
1071 | + $user = get_user_by('id', $order->user_id); |
|
1072 | + $order_user['ID'] = $user->ID; |
|
1073 | + $order_user['user_login'] = $user->user_login; |
|
1074 | + $order_user['user_email'] = $user->user_email; |
|
1075 | + $order_user['user_url'] = $user->user_url; |
|
1076 | + // Run through each product ordered |
|
1077 | + if (sizeof($order->get_items())>0) { |
|
1078 | + foreach($order->get_items() as $item) { |
|
1079 | + $product_type = ''; |
|
1080 | + if (isset($item['variation_id']) && $item['variation_id'] > 0) { |
|
1081 | + $item_id = $item['variation_id']; |
|
1082 | + $product_type = 'subscription_variation'; |
|
1083 | + } else { |
|
1084 | + $item_id = $item['product_id']; |
|
1085 | + } // End If Statement |
|
1086 | + $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
1087 | + // Get courses that use the WC product |
|
1088 | + $courses = array(); |
|
1089 | + if ( $product_type == 'subscription_variation' ) { |
|
1090 | + $courses = $this->post_types->course->get_product_courses( $item_id ); |
|
1091 | + } // End If Statement |
|
1092 | + // Loop and update those courses |
|
1093 | + foreach ($courses as $course_item){ |
|
1094 | + $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
1095 | + } // End For Loop |
|
1096 | + } // End For Loop |
|
1097 | + } // End If Statement |
|
1098 | + } // End If Statement |
|
1099 | + } // End sensei_activate_subscription() |
|
1100 | + |
|
1101 | + /** |
|
1102 | + * sensei_woocommerce_email_course_details adds detail to email |
|
1103 | + * @since 1.4.5 |
|
1104 | + * @access public |
|
1105 | + * @param WC_Order $order |
|
1106 | + * @return void |
|
1107 | + */ |
|
1108 | + public function sensei_woocommerce_email_course_details( $order ) { |
|
1109 | + global $woocommerce; |
|
1110 | + |
|
1111 | + // exit early if not wc-completed or wc-processing |
|
1112 | + if( 'wc-completed' != $order->post_status |
|
1113 | + && 'wc-processing' != $order->post_status ) { |
|
1114 | + return; |
|
1115 | + } |
|
1116 | + |
|
1117 | + $order_items = $order->get_items(); |
|
1118 | + $order_id = $order->id; |
|
1119 | + |
|
1120 | + //If object have items go through them all to find course |
|
1121 | + if ( 0 < sizeof( $order_items ) ) { |
|
1122 | + |
|
1123 | + $course_details_html = '<h2>' . __( 'Course details', 'woothemes-sensei' ) . '</h2>'; |
|
1124 | + $order_contains_courses = false; |
|
1125 | + |
|
1126 | + |
|
1127 | + foreach ( $order_items as $item ) { |
|
1128 | + |
|
1129 | + $product_type = ''; |
|
1130 | + if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
1131 | + // If item has variation_id then its from variation |
|
1132 | + $item_id = $item['variation_id']; |
|
1133 | + $product_type = 'variation'; |
|
1134 | + } else { |
|
1135 | + // If not its real product set its id to item_id |
|
1136 | + $item_id = $item['product_id']; |
|
1137 | + } // End If Statement |
|
1138 | + |
|
1139 | + $user_id = get_post_meta( $order_id, '_customer_user', true ); |
|
1140 | + |
|
1141 | + if( $user_id ) { |
|
1142 | + |
|
1143 | + // Get all courses for product |
|
1144 | + $args = array( |
|
1145 | + 'posts_per_page' => -1, |
|
1146 | + 'post_type' => 'course', |
|
1147 | + 'meta_query' => array( |
|
1148 | + array( |
|
1149 | + 'key' => '_course_woocommerce_product', |
|
1150 | + 'value' => $item_id |
|
1151 | + ) |
|
1152 | + ), |
|
1153 | + 'orderby' => 'menu_order date', |
|
1154 | + 'order' => 'ASC', |
|
1155 | + ); |
|
1156 | + $courses = get_posts( $args ); |
|
1157 | + |
|
1158 | + if( $courses && count( $courses ) > 0 ) { |
|
1159 | + |
|
1160 | + foreach( $courses as $course ) { |
|
1161 | + |
|
1162 | + $title = $course->post_title; |
|
1163 | + $permalink = get_permalink( $course->ID ); |
|
1164 | + $order_contains_courses = true; |
|
1165 | + $course_details_html .= '<p><strong>' . sprintf( __( 'View course: %1$s', 'woothemes-sensei' ), '</strong><a href="' . esc_url( $permalink ) . '">' . $title . '</a>' ) . '</p>'; |
|
1166 | + } |
|
1167 | + |
|
1168 | + |
|
1169 | + } // end if has courses |
|
1170 | + |
|
1171 | + } // end if $userPid |
|
1172 | + |
|
1173 | + } // end for each order item |
|
1174 | + |
|
1175 | + // Output Course details |
|
1176 | + if( $order_contains_courses ){ |
|
1177 | + |
|
1178 | + echo $course_details_html; |
|
1179 | + |
|
1180 | + } |
|
1181 | + |
|
1182 | + |
|
1183 | + } // end if order items not empty |
|
1184 | + |
|
1185 | + } // end func email course details |
|
1186 | + |
|
1187 | + /** |
|
1188 | + * Filtering wp_count_comments to ensure that Sensei comments are ignored |
|
1189 | + * @since 1.4.0 |
|
1190 | + * @access public |
|
1191 | + * @param array $comments |
|
1192 | + * @param integer $post_id |
|
1193 | + * @return array |
|
1194 | + */ |
|
1195 | + public function sensei_count_comments( $comments, $post_id ) { |
|
1196 | + global $wpdb; |
|
1197 | + |
|
1198 | + $post_id = (int) $post_id; |
|
1199 | + |
|
1200 | + $count = wp_cache_get("comments-{$post_id}", 'counts'); |
|
1201 | + |
|
1202 | + if ( false !== $count ) { |
|
1203 | + return $count; |
|
1204 | + } |
|
1205 | + |
|
1206 | + $statuses = array( '' ); // Default to the WP normal comments |
|
1207 | + $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); |
|
1208 | + foreach ( (array) $stati AS $status ) { |
|
1209 | + if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { |
|
1210 | + $statuses[] = $status['comment_type']; |
|
1211 | + } |
|
1212 | + } |
|
1213 | + $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; |
|
1214 | + |
|
1215 | + if ( $post_id > 0 ) |
|
1216 | + $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
1217 | + |
|
1218 | + $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1219 | + |
|
1220 | + $total = 0; |
|
1221 | + $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
|
1222 | + foreach ( (array) $count as $row ) { |
|
1223 | + // Don't count post-trashed toward totals |
|
1224 | + if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
1225 | + $total += $row['num_comments']; |
|
1226 | + if ( isset( $approved[$row['comment_approved']] ) ) |
|
1227 | + $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
|
1228 | + } |
|
1229 | + |
|
1230 | + $stats['total_comments'] = $total; |
|
1231 | + foreach ( $approved as $key ) { |
|
1232 | + if ( empty($stats[$key]) ) |
|
1233 | + $stats[$key] = 0; |
|
1234 | + } |
|
1235 | + |
|
1236 | + $stats = (object) $stats; |
|
1237 | + wp_cache_set("comments-{$post_id}", $stats, 'counts'); |
|
1238 | + |
|
1239 | + return $stats; |
|
1240 | + } |
|
1241 | + |
|
1242 | + /** |
|
1243 | + * Init images. |
|
1244 | + * |
|
1245 | + * @since 1.4.5 |
|
1246 | + * @access public |
|
1247 | + * @return void |
|
1248 | + */ |
|
1249 | + public function init_image_sizes() { |
|
1250 | + $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); |
|
1251 | + $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); |
|
1252 | + $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); |
|
1253 | + $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); |
|
1254 | + |
|
1255 | + add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); |
|
1256 | + add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); |
|
1257 | + add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); |
|
1258 | + add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); |
|
1259 | + } |
|
1260 | + |
|
1261 | + /** |
|
1262 | + * Get an image size. |
|
1263 | + * |
|
1264 | + * Variable is filtered by sensei_get_image_size_{image_size} |
|
1265 | + * |
|
1266 | + * @since 1.4.5 |
|
1267 | + * @access public |
|
1268 | + * @param mixed $image_size |
|
1269 | + * @return string |
|
1270 | + */ |
|
1271 | + public function get_image_size( $image_size ) { |
|
1272 | + |
|
1273 | + // Only return sizes we define in settings |
|
1274 | + if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) |
|
1275 | + return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
1276 | + |
|
1277 | + if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { |
|
1278 | + $this->settings->settings[ $image_size . '_width' ] = false; |
|
1279 | + } |
|
1280 | + if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { |
|
1281 | + $this->settings->settings[ $image_size . '_height' ] = false; |
|
1282 | + } |
|
1283 | + if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { |
|
1284 | + $this->settings->settings[ $image_size . '_hard_crop' ] = false; |
|
1285 | + } |
|
1286 | + |
|
1287 | + $size = array_filter( array( |
|
1288 | + 'width' => $this->settings->settings[ $image_size . '_width' ], |
|
1289 | + 'height' => $this->settings->settings[ $image_size . '_height' ], |
|
1290 | + 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] |
|
1291 | + ) ); |
|
1292 | + |
|
1293 | + $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; |
|
1294 | + $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; |
|
1295 | + $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; |
|
1296 | + |
|
1297 | + return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); |
|
1298 | + } |
|
1299 | + |
|
1300 | + public function body_class( $classes ) { |
|
1301 | + if( is_sensei() ) { |
|
1302 | + $classes[] = 'sensei'; |
|
1303 | + } |
|
1304 | + return $classes; |
|
1305 | + } |
|
1306 | + |
|
1307 | + /** |
|
1308 | + * Checks that the Jetpack Beautiful Maths module has been activated to support LaTeX within question titles and answers |
|
1309 | + * |
|
1310 | + * @return null |
|
1311 | + * @since 1.7.0 |
|
1312 | + */ |
|
1313 | + public function jetpack_latex_support() { |
|
1314 | + if ( function_exists( 'latex_markup') ) { |
|
1315 | + add_filter( 'sensei_question_title', 'latex_markup' ); |
|
1316 | + add_filter( 'sensei_answer_text', 'latex_markup' ); |
|
1317 | + } |
|
1318 | + } |
|
1319 | + |
|
1320 | + /** |
|
1321 | + * Load the module functionality. |
|
1322 | + * |
|
1323 | + * This function is hooked into plugins_loaded to avoid conflicts with |
|
1324 | + * the retired modules extension. |
|
1325 | + * |
|
1326 | + * @since 1.8.0 |
|
1327 | + */ |
|
1328 | + public function load_modules_class(){ |
|
1329 | + global $sensei_modules; |
|
1330 | + |
|
1331 | + if( !class_exists( 'Sensei_Modules' ) |
|
1332 | + && 'Sensei_Modules' != get_class( $sensei_modules ) ) { |
|
1333 | + |
|
1334 | + //Load the modules class |
|
1335 | + require_once( 'class-sensei-modules.php'); |
|
1336 | + Sensei()->modules = new Sensei_Core_Modules( $this->file ); |
|
1337 | + |
|
1338 | + }else{ |
|
1339 | + // fallback for people still using the modules extension. |
|
1340 | + global $sensei_modules; |
|
1341 | + Sensei()->modules = $sensei_modules; |
|
1342 | + add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); |
|
1343 | + } |
|
1344 | + } |
|
1345 | + |
|
1346 | + /** |
|
1347 | + * Tell the user to that the modules extension is no longer needed. |
|
1348 | + * |
|
1349 | + * @since 1.8.0 |
|
1350 | + */ |
|
1351 | + public function disable_sensei_modules_extension(){ ?> |
|
1352 | 1352 | <div class="notice updated fade"> |
1353 | 1353 | <p> |
1354 | 1354 | <?php |
1355 | - $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; |
|
1356 | - $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; |
|
1357 | - ?> |
|
1355 | + $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; |
|
1356 | + $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; |
|
1357 | + ?> |
|
1358 | 1358 | <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension. |
1359 | 1359 | Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules). |
1360 | 1360 | </p> |
@@ -1362,46 +1362,46 @@ discard block |
||
1362 | 1362 | |
1363 | 1363 | <?php }// end function |
1364 | 1364 | |
1365 | - /** |
|
1366 | - * Sensei wide rewrite flush call. |
|
1367 | - * |
|
1368 | - * To use this simply update the option 'sensei_flush_rewrite_rules' to 1 |
|
1369 | - * |
|
1370 | - * After the option is one the Rules will be flushed. |
|
1371 | - * |
|
1372 | - * @since 1.9.0 |
|
1373 | - */ |
|
1374 | - public function flush_rewrite_rules(){ |
|
1365 | + /** |
|
1366 | + * Sensei wide rewrite flush call. |
|
1367 | + * |
|
1368 | + * To use this simply update the option 'sensei_flush_rewrite_rules' to 1 |
|
1369 | + * |
|
1370 | + * After the option is one the Rules will be flushed. |
|
1371 | + * |
|
1372 | + * @since 1.9.0 |
|
1373 | + */ |
|
1374 | + public function flush_rewrite_rules(){ |
|
1375 | 1375 | |
1376 | - // ensures that the rewrite rules are flushed on the second |
|
1377 | - // attempt. This ensure that the settings for any other process |
|
1378 | - // have been completed and saved to the database before we refresh the |
|
1379 | - // rewrite rules. |
|
1380 | - $option = get_option('sensei_flush_rewrite_rules'); |
|
1381 | - if( '1' == $option ) { |
|
1376 | + // ensures that the rewrite rules are flushed on the second |
|
1377 | + // attempt. This ensure that the settings for any other process |
|
1378 | + // have been completed and saved to the database before we refresh the |
|
1379 | + // rewrite rules. |
|
1380 | + $option = get_option('sensei_flush_rewrite_rules'); |
|
1381 | + if( '1' == $option ) { |
|
1382 | 1382 | |
1383 | - update_option('sensei_flush_rewrite_rules', '2'); |
|
1383 | + update_option('sensei_flush_rewrite_rules', '2'); |
|
1384 | 1384 | |
1385 | - }elseif( '2' == $option ) { |
|
1385 | + }elseif( '2' == $option ) { |
|
1386 | 1386 | |
1387 | - flush_rewrite_rules(); |
|
1388 | - update_option('sensei_flush_rewrite_rules', '0'); |
|
1387 | + flush_rewrite_rules(); |
|
1388 | + update_option('sensei_flush_rewrite_rules', '0'); |
|
1389 | 1389 | |
1390 | - } |
|
1390 | + } |
|
1391 | 1391 | |
1392 | - } // end flush_rewrite_rules |
|
1392 | + } // end flush_rewrite_rules |
|
1393 | 1393 | |
1394 | - /** |
|
1395 | - * Calling this function will tell Sensei to flush rewrite |
|
1396 | - * rules on the next load. |
|
1397 | - * |
|
1398 | - * @since 1.9.0 |
|
1399 | - */ |
|
1400 | - public function initiate_rewrite_rules_flush(){ |
|
1394 | + /** |
|
1395 | + * Calling this function will tell Sensei to flush rewrite |
|
1396 | + * rules on the next load. |
|
1397 | + * |
|
1398 | + * @since 1.9.0 |
|
1399 | + */ |
|
1400 | + public function initiate_rewrite_rules_flush(){ |
|
1401 | 1401 | |
1402 | - update_option('sensei_flush_rewrite_rules', '1'); |
|
1402 | + update_option('sensei_flush_rewrite_rules', '1'); |
|
1403 | 1403 | |
1404 | - } |
|
1404 | + } |
|
1405 | 1405 | |
1406 | 1406 | } // End Class |
1407 | 1407 |
@@ -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_Main |
@@ -146,23 +146,23 @@ discard block |
||
146 | 146 | * @param string $file The base file of the plugin. |
147 | 147 | * @since 1.0.0 |
148 | 148 | */ |
149 | - public function __construct ( $file ) { |
|
149 | + public function __construct($file) { |
|
150 | 150 | |
151 | 151 | // Setup object data |
152 | 152 | $this->file = $file; |
153 | - $this->plugin_url = trailingslashit( plugins_url( '', $plugin = $file ) ); |
|
154 | - $this->plugin_path = trailingslashit( dirname( $file ) ); |
|
155 | - $this->template_url = apply_filters( 'sensei_template_url', 'sensei/' ); |
|
156 | - $this->permissions_message = array( 'title' => __( 'Permission Denied', 'woothemes-sensei' ), 'message' => __( 'Unfortunately you do not have permissions to access this page.', 'woothemes-sensei' ) ); |
|
153 | + $this->plugin_url = trailingslashit(plugins_url('', $plugin = $file)); |
|
154 | + $this->plugin_path = trailingslashit(dirname($file)); |
|
155 | + $this->template_url = apply_filters('sensei_template_url', 'sensei/'); |
|
156 | + $this->permissions_message = array('title' => __('Permission Denied', 'woothemes-sensei'), 'message' => __('Unfortunately you do not have permissions to access this page.', 'woothemes-sensei')); |
|
157 | 157 | |
158 | 158 | // Initialize the core Sensei functionality |
159 | 159 | $this->init(); |
160 | 160 | |
161 | 161 | // Installation |
162 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) $this->install(); |
|
162 | + if (is_admin() && ! defined('DOING_AJAX')) $this->install(); |
|
163 | 163 | |
164 | 164 | // Run this on activation. |
165 | - register_activation_hook( $this->file, array( $this, 'activation' ) ); |
|
165 | + register_activation_hook($this->file, array($this, 'activation')); |
|
166 | 166 | |
167 | 167 | // Image Sizes |
168 | 168 | $this->init_image_sizes(); |
@@ -179,11 +179,11 @@ discard block |
||
179 | 179 | * Load the foundations of Sensei. |
180 | 180 | * @since 1.9.0 |
181 | 181 | */ |
182 | - protected function init(){ |
|
182 | + protected function init() { |
|
183 | 183 | |
184 | 184 | // Localisation |
185 | 185 | $this->load_plugin_textdomain(); |
186 | - add_action( 'init', array( $this, 'load_localisation' ), 0 ); |
|
186 | + add_action('init', array($this, 'load_localisation'), 0); |
|
187 | 187 | |
188 | 188 | // load the shortcode loader into memory, so as to listen to all for |
189 | 189 | // all shortcodes on the front end |
@@ -203,12 +203,12 @@ discard block |
||
203 | 203 | */ |
204 | 204 | public static function instance() { |
205 | 205 | |
206 | - if ( is_null( self::$_instance ) ) { |
|
206 | + if (is_null(self::$_instance)) { |
|
207 | 207 | |
208 | 208 | //Sensei requires a reference to the main Sensei plugin file |
209 | - $sensei_main_plugin_file = dirname ( dirname( __FILE__ ) ) . '/woothemes-sensei.php'; |
|
209 | + $sensei_main_plugin_file = dirname(dirname(__FILE__)).'/woothemes-sensei.php'; |
|
210 | 210 | |
211 | - self::$_instance = new self( $sensei_main_plugin_file ); |
|
211 | + self::$_instance = new self($sensei_main_plugin_file); |
|
212 | 212 | |
213 | 213 | // load the global class objects needed throughout Sensei |
214 | 214 | self::$_instance->initialize_global_objects(); |
@@ -227,9 +227,9 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @param $plugin |
229 | 229 | */ |
230 | - public static function activation_flush_rules( $plugin ){ |
|
230 | + public static function activation_flush_rules($plugin) { |
|
231 | 231 | |
232 | - if( strpos( $plugin, '/woothemes-sensei.php' ) > 0 ){ |
|
232 | + if (strpos($plugin, '/woothemes-sensei.php') > 0) { |
|
233 | 233 | |
234 | 234 | flush_rewrite_rules(true); |
235 | 235 | |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | * @since 1.8.0 |
243 | 243 | */ |
244 | 244 | public function __clone() { |
245 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
245 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '1.8'); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @since 1.8.0 |
251 | 251 | */ |
252 | 252 | public function __wakeup() { |
253 | - _doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'woothemes-sensei' ), '1.8' ); |
|
253 | + _doing_it_wrong(__FUNCTION__, __('Cheatin’ huh?', 'woothemes-sensei'), '1.8'); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | /** |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | * |
259 | 259 | * @since 1.9.0 |
260 | 260 | */ |
261 | - public function initialize_global_objects(){ |
|
261 | + public function initialize_global_objects() { |
|
262 | 262 | |
263 | 263 | // Setup post types. |
264 | 264 | $this->post_types = new Sensei_PostTypes(); |
265 | 265 | |
266 | 266 | // Lad the updates class |
267 | - $this->updates = new Sensei_Updates( $this ); |
|
267 | + $this->updates = new Sensei_Updates($this); |
|
268 | 268 | |
269 | 269 | // Setup settings |
270 | 270 | $this->settings = new Sensei_Settings(); |
@@ -288,22 +288,22 @@ discard block |
||
288 | 288 | $this->quiz = $this->post_types->quiz; |
289 | 289 | |
290 | 290 | // load the modules class after all plugsin are loaded |
291 | - add_action( 'plugins_loaded', array( $this, 'load_modules_class' ) ); |
|
291 | + add_action('plugins_loaded', array($this, 'load_modules_class')); |
|
292 | 292 | |
293 | 293 | // Load Learner Management Functionality |
294 | - $this->learners = new Sensei_Learner_Management( $this->file ); |
|
294 | + $this->learners = new Sensei_Learner_Management($this->file); |
|
295 | 295 | |
296 | 296 | // Differentiate between administration and frontend logic. |
297 | - if ( is_admin() ) { |
|
297 | + if (is_admin()) { |
|
298 | 298 | |
299 | 299 | // Load Admin Welcome class |
300 | 300 | new Sensei_Welcome(); |
301 | 301 | |
302 | 302 | // Load Admin Class |
303 | - $this->admin = new Sensei_Admin( $this->file ); |
|
303 | + $this->admin = new Sensei_Admin($this->file); |
|
304 | 304 | |
305 | 305 | // Load Analysis Reports |
306 | - $this->analysis = new Sensei_Analysis( $this->file ); |
|
306 | + $this->analysis = new Sensei_Analysis($this->file); |
|
307 | 307 | |
308 | 308 | } else { |
309 | 309 | |
@@ -320,10 +320,10 @@ discard block |
||
320 | 320 | } |
321 | 321 | |
322 | 322 | // Load Grading Functionality |
323 | - $this->grading = new Sensei_Grading( $this->file ); |
|
323 | + $this->grading = new Sensei_Grading($this->file); |
|
324 | 324 | |
325 | 325 | // Load Email Class |
326 | - $this->emails = new Sensei_Emails( $this->file ); |
|
326 | + $this->emails = new Sensei_Emails($this->file); |
|
327 | 327 | |
328 | 328 | // Load Learner Profiles Class |
329 | 329 | $this->learner_profiles = new Sensei_Learner_Profiles(); |
@@ -335,40 +335,40 @@ discard block |
||
335 | 335 | * |
336 | 336 | * @since 1.9.0 |
337 | 337 | */ |
338 | - public function load_hooks(){ |
|
338 | + public function load_hooks() { |
|
339 | 339 | |
340 | - add_action( 'widgets_init', array( $this, 'register_widgets' ) ); |
|
341 | - add_action( 'after_setup_theme', array( $this, 'ensure_post_thumbnails_support' ) ); |
|
340 | + add_action('widgets_init', array($this, 'register_widgets')); |
|
341 | + add_action('after_setup_theme', array($this, 'ensure_post_thumbnails_support')); |
|
342 | 342 | |
343 | 343 | // WooCommerce Payment Actions |
344 | - add_action( 'woocommerce_payment_complete' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
345 | - add_action( 'woocommerce_thankyou' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
346 | - add_action( 'woocommerce_order_status_completed' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
347 | - add_action( 'woocommerce_order_status_processing' , array( $this, 'sensei_woocommerce_complete_order' ) ); |
|
348 | - add_action( 'woocommerce_order_status_cancelled' , array( $this, 'sensei_woocommerce_cancel_order' ) ); |
|
349 | - add_action( 'woocommerce_order_status_refunded' , array( $this, 'sensei_woocommerce_cancel_order' ) ); |
|
350 | - add_action( 'subscriptions_activated_for_order', array( $this, 'sensei_activate_subscription' ) ); |
|
344 | + add_action('woocommerce_payment_complete', array($this, 'sensei_woocommerce_complete_order')); |
|
345 | + add_action('woocommerce_thankyou', array($this, 'sensei_woocommerce_complete_order')); |
|
346 | + add_action('woocommerce_order_status_completed', array($this, 'sensei_woocommerce_complete_order')); |
|
347 | + add_action('woocommerce_order_status_processing', array($this, 'sensei_woocommerce_complete_order')); |
|
348 | + add_action('woocommerce_order_status_cancelled', array($this, 'sensei_woocommerce_cancel_order')); |
|
349 | + add_action('woocommerce_order_status_refunded', array($this, 'sensei_woocommerce_cancel_order')); |
|
350 | + add_action('subscriptions_activated_for_order', array($this, 'sensei_activate_subscription')); |
|
351 | 351 | |
352 | 352 | // WooCommerce Subscriptions Actions |
353 | - add_action( 'reactivated_subscription', array( $this, 'sensei_woocommerce_reactivate_subscription' ), 10, 2 ); |
|
354 | - add_action( 'subscription_expired' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
355 | - add_action( 'subscription_end_of_prepaid_term' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
356 | - add_action( 'cancelled_subscription' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
357 | - add_action( 'subscription_put_on-hold' , array( $this, 'sensei_woocommerce_subscription_ended' ), 10, 2 ); |
|
353 | + add_action('reactivated_subscription', array($this, 'sensei_woocommerce_reactivate_subscription'), 10, 2); |
|
354 | + add_action('subscription_expired', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
355 | + add_action('subscription_end_of_prepaid_term', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
356 | + add_action('cancelled_subscription', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
357 | + add_action('subscription_put_on-hold', array($this, 'sensei_woocommerce_subscription_ended'), 10, 2); |
|
358 | 358 | |
359 | 359 | // Add Email link to course orders |
360 | - add_action( 'woocommerce_email_after_order_table', array( $this, 'sensei_woocommerce_email_course_details' ), 10, 1 ); |
|
360 | + add_action('woocommerce_email_after_order_table', array($this, 'sensei_woocommerce_email_course_details'), 10, 1); |
|
361 | 361 | |
362 | 362 | // Filter comment counts |
363 | - add_filter( 'wp_count_comments', array( $this, 'sensei_count_comments' ), 10, 2 ); |
|
363 | + add_filter('wp_count_comments', array($this, 'sensei_count_comments'), 10, 2); |
|
364 | 364 | |
365 | - add_action( 'body_class', array( $this, 'body_class' ) ); |
|
365 | + add_action('body_class', array($this, 'body_class')); |
|
366 | 366 | |
367 | 367 | // Check for and activate JetPack LaTeX support |
368 | - add_action( 'plugins_loaded', array( $this, 'jetpack_latex_support'), 200 ); // Runs after Jetpack has loaded it's modules |
|
368 | + add_action('plugins_loaded', array($this, 'jetpack_latex_support'), 200); // Runs after Jetpack has loaded it's modules |
|
369 | 369 | |
370 | 370 | // check flush the rewrite rules if the option sensei_flush_rewrite_rules option is 1 |
371 | - add_action( 'init', array( $this, 'flush_rewrite_rules'), 101 ); |
|
371 | + add_action('init', array($this, 'flush_rewrite_rules'), 101); |
|
372 | 372 | |
373 | 373 | } |
374 | 374 | |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | */ |
381 | 381 | public function run_updates() { |
382 | 382 | // Run updates if administrator |
383 | - if ( current_user_can( 'manage_options' ) || current_user_can( 'manage_sensei' ) ) { |
|
383 | + if (current_user_can('manage_options') || current_user_can('manage_sensei')) { |
|
384 | 384 | |
385 | 385 | $this->updates->update(); |
386 | 386 | |
@@ -397,10 +397,10 @@ discard block |
||
397 | 397 | */ |
398 | 398 | public function set_woocommerce_functionality() { |
399 | 399 | // Disable guest checkout if a course is in the cart as we need a valid user to store data for |
400 | - add_filter( 'pre_option_woocommerce_enable_guest_checkout', array( $this, 'disable_guest_checkout' ) ); |
|
400 | + add_filter('pre_option_woocommerce_enable_guest_checkout', array($this, 'disable_guest_checkout')); |
|
401 | 401 | |
402 | 402 | // Mark orders with virtual products as complete rather then stay processing |
403 | - add_filter( 'woocommerce_payment_complete_order_status', array( $this, 'virtual_order_payment_complete' ), 10, 2 ); |
|
403 | + add_filter('woocommerce_payment_complete_order_status', array($this, 'virtual_order_payment_complete'), 10, 2); |
|
404 | 404 | |
405 | 405 | } // End set_woocommerce_functionality() |
406 | 406 | |
@@ -409,14 +409,14 @@ discard block |
||
409 | 409 | * @param boolean $guest_checkout Current guest checkout setting |
410 | 410 | * @return boolean Modified guest checkout setting |
411 | 411 | */ |
412 | - public function disable_guest_checkout( $guest_checkout ) { |
|
412 | + public function disable_guest_checkout($guest_checkout) { |
|
413 | 413 | global $woocommerce; |
414 | 414 | |
415 | - if( ! is_admin() || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { |
|
415 | + if ( ! is_admin() || (defined('DOING_AJAX') && DOING_AJAX)) { |
|
416 | 416 | |
417 | - if( isset( $woocommerce->cart->cart_contents ) && count( $woocommerce->cart->cart_contents ) > 0 ) { |
|
418 | - foreach( $woocommerce->cart->cart_contents as $cart_key => $product ) { |
|
419 | - if( isset( $product['product_id'] ) ) { |
|
417 | + if (isset($woocommerce->cart->cart_contents) && count($woocommerce->cart->cart_contents) > 0) { |
|
418 | + foreach ($woocommerce->cart->cart_contents as $cart_key => $product) { |
|
419 | + if (isset($product['product_id'])) { |
|
420 | 420 | $args = array( |
421 | 421 | 'posts_per_page' => -1, |
422 | 422 | 'post_type' => 'course', |
@@ -427,9 +427,9 @@ discard block |
||
427 | 427 | ) |
428 | 428 | ) |
429 | 429 | ); |
430 | - $posts = get_posts( $args ); |
|
431 | - if( $posts && count( $posts ) > 0 ) { |
|
432 | - foreach( $posts as $course ) { |
|
430 | + $posts = get_posts($args); |
|
431 | + if ($posts && count($posts) > 0) { |
|
432 | + foreach ($posts as $course) { |
|
433 | 433 | $guest_checkout = ''; |
434 | 434 | break; |
435 | 435 | } |
@@ -449,17 +449,17 @@ discard block |
||
449 | 449 | * @param int $order_id |
450 | 450 | * @return string |
451 | 451 | **/ |
452 | - public function virtual_order_payment_complete( $order_status, $order_id ) { |
|
453 | - $order = new WC_Order( $order_id ); |
|
454 | - if ( ! isset ( $order ) ) return ''; |
|
455 | - if ( $order_status == 'wc-processing' && ( $order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed' ) ) { |
|
452 | + public function virtual_order_payment_complete($order_status, $order_id) { |
|
453 | + $order = new WC_Order($order_id); |
|
454 | + if ( ! isset ($order)) return ''; |
|
455 | + if ($order_status == 'wc-processing' && ($order->post_status == 'wc-on-hold' || $order->post_status == 'wc-pending' || $order->post_status == 'wc-failed')) { |
|
456 | 456 | $virtual_order = true; |
457 | 457 | |
458 | - if ( count( $order->get_items() ) > 0 ) { |
|
459 | - foreach( $order->get_items() as $item ) { |
|
460 | - if ( $item['product_id'] > 0 ) { |
|
461 | - $_product = $order->get_product_from_item( $item ); |
|
462 | - if ( ! $_product->is_virtual() ) { |
|
458 | + if (count($order->get_items()) > 0) { |
|
459 | + foreach ($order->get_items() as $item) { |
|
460 | + if ($item['product_id'] > 0) { |
|
461 | + $_product = $order->get_product_from_item($item); |
|
462 | + if ( ! $_product->is_virtual()) { |
|
463 | 463 | $virtual_order = false; |
464 | 464 | break; |
465 | 465 | } // End If Statement |
@@ -468,7 +468,7 @@ discard block |
||
468 | 468 | } // End If Statement |
469 | 469 | |
470 | 470 | // virtual order, mark as completed |
471 | - if ( $virtual_order ) { |
|
471 | + if ($virtual_order) { |
|
472 | 472 | return 'completed'; |
473 | 473 | } // End If Statement |
474 | 474 | } // End If Statement |
@@ -481,21 +481,21 @@ discard block |
||
481 | 481 | * @since 1.0.0 |
482 | 482 | * @return void |
483 | 483 | */ |
484 | - public function register_widgets () { |
|
484 | + public function register_widgets() { |
|
485 | 485 | // Widget List (key => value is filename => widget class). |
486 | - $widget_list = apply_filters( 'sensei_registered_widgets_list', array( 'course-component' => 'Course_Component', |
|
486 | + $widget_list = apply_filters('sensei_registered_widgets_list', array('course-component' => 'Course_Component', |
|
487 | 487 | 'lesson-component' => 'Lesson_Component', |
488 | 488 | 'course-categories' => 'Course_Categories', |
489 | - 'category-courses' => 'Category_Courses' ) |
|
489 | + 'category-courses' => 'Category_Courses') |
|
490 | 490 | ); |
491 | - foreach ( $widget_list as $key => $value ) { |
|
492 | - if ( file_exists( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ) ) { |
|
493 | - require_once( $this->plugin_path . 'widgets/widget-woothemes-sensei-' . $key . '.php' ); |
|
494 | - register_widget( 'WooThemes_Sensei_' . $value . '_Widget' ); |
|
491 | + foreach ($widget_list as $key => $value) { |
|
492 | + if (file_exists($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php')) { |
|
493 | + require_once($this->plugin_path.'widgets/widget-woothemes-sensei-'.$key.'.php'); |
|
494 | + register_widget('WooThemes_Sensei_'.$value.'_Widget'); |
|
495 | 495 | } |
496 | 496 | } // End For Loop |
497 | 497 | |
498 | - do_action( 'sensei_register_widgets' ); |
|
498 | + do_action('sensei_register_widgets'); |
|
499 | 499 | |
500 | 500 | } // End register_widgets() |
501 | 501 | |
@@ -505,8 +505,8 @@ discard block |
||
505 | 505 | * @since 1.0.0 |
506 | 506 | * @return void |
507 | 507 | */ |
508 | - public function load_localisation () { |
|
509 | - load_plugin_textdomain( 'woothemes-sensei', false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
508 | + public function load_localisation() { |
|
509 | + load_plugin_textdomain('woothemes-sensei', false, dirname(plugin_basename($this->file)).'/lang/'); |
|
510 | 510 | } // End load_localisation() |
511 | 511 | |
512 | 512 | /** |
@@ -515,12 +515,12 @@ discard block |
||
515 | 515 | * @since 1.0.0 |
516 | 516 | * @return void |
517 | 517 | */ |
518 | - public function load_plugin_textdomain () { |
|
518 | + public function load_plugin_textdomain() { |
|
519 | 519 | $domain = 'woothemes-sensei'; |
520 | 520 | // The "plugin_locale" filter is also used in load_plugin_textdomain() |
521 | - $locale = apply_filters( 'plugin_locale', get_locale(), $domain ); |
|
522 | - load_textdomain( $domain, WP_LANG_DIR . '/' . $domain . '/' . $domain . '-' . $locale . '.mo' ); |
|
523 | - load_plugin_textdomain( $domain, FALSE, dirname( plugin_basename( $this->file ) ) . '/lang/' ); |
|
521 | + $locale = apply_filters('plugin_locale', get_locale(), $domain); |
|
522 | + load_textdomain($domain, WP_LANG_DIR.'/'.$domain.'/'.$domain.'-'.$locale.'.mo'); |
|
523 | + load_plugin_textdomain($domain, FALSE, dirname(plugin_basename($this->file)).'/lang/'); |
|
524 | 524 | } // End load_plugin_textdomain() |
525 | 525 | |
526 | 526 | /** |
@@ -529,7 +529,7 @@ discard block |
||
529 | 529 | * @since 1.0.0 |
530 | 530 | * @return void |
531 | 531 | */ |
532 | - public function activation () { |
|
532 | + public function activation() { |
|
533 | 533 | $this->register_plugin_version(); |
534 | 534 | } // End activation() |
535 | 535 | |
@@ -540,9 +540,9 @@ discard block |
||
540 | 540 | * @since 1.0.0 |
541 | 541 | * @return void |
542 | 542 | */ |
543 | - public function install () { |
|
544 | - register_activation_hook( $this->file, array( $this, 'activate_sensei' ) ); |
|
545 | - register_activation_hook( $this->file, 'flush_rewrite_rules' ); |
|
543 | + public function install() { |
|
544 | + register_activation_hook($this->file, array($this, 'activate_sensei')); |
|
545 | + register_activation_hook($this->file, 'flush_rewrite_rules'); |
|
546 | 546 | } // End install() |
547 | 547 | |
548 | 548 | |
@@ -552,9 +552,9 @@ discard block |
||
552 | 552 | * @since 1.0.0 |
553 | 553 | * @return void |
554 | 554 | */ |
555 | - public function activate_sensei () { |
|
556 | - update_option( 'skip_install_sensei_pages', 0 ); |
|
557 | - update_option( 'sensei_installed', 1 ); |
|
555 | + public function activate_sensei() { |
|
556 | + update_option('skip_install_sensei_pages', 0); |
|
557 | + update_option('sensei_installed', 1); |
|
558 | 558 | } // End activate_sensei() |
559 | 559 | |
560 | 560 | /** |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | * @since 1.0.0 |
564 | 564 | * @return void |
565 | 565 | */ |
566 | - private function register_plugin_version () { |
|
567 | - if ( $this->version != '' ) { |
|
566 | + private function register_plugin_version() { |
|
567 | + if ($this->version != '') { |
|
568 | 568 | |
569 | 569 | // Check previous version to see if forced updates must run |
570 | 570 | // $old_version = get_option( 'woothemes-sensei-version', false ); |
@@ -574,7 +574,7 @@ discard block |
||
574 | 574 | // delete_option( 'woothemes-sensei-force-updates' ); |
575 | 575 | // } |
576 | 576 | |
577 | - update_option( 'woothemes-sensei-version', $this->version ); |
|
577 | + update_option('woothemes-sensei-version', $this->version); |
|
578 | 578 | } |
579 | 579 | } // End register_plugin_version() |
580 | 580 | |
@@ -584,8 +584,8 @@ discard block |
||
584 | 584 | * @since 1.0.1 |
585 | 585 | * @return void |
586 | 586 | */ |
587 | - public function ensure_post_thumbnails_support () { |
|
588 | - if ( ! current_theme_supports( 'post-thumbnails' ) ) { add_theme_support( 'post-thumbnails' ); } |
|
587 | + public function ensure_post_thumbnails_support() { |
|
588 | + if ( ! current_theme_supports('post-thumbnails')) { add_theme_support('post-thumbnails'); } |
|
589 | 589 | } // End ensure_post_thumbnails_support() |
590 | 590 | |
591 | 591 | |
@@ -597,10 +597,10 @@ discard block |
||
597 | 597 | * @return void |
598 | 598 | * @deprecated |
599 | 599 | */ |
600 | - public function template_loader ( $template = '' ) { |
|
600 | + public function template_loader($template = '') { |
|
601 | 601 | |
602 | - _deprecated_function( 'Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead' ); |
|
603 | - Sensei_Templates::template_loader( $template ); |
|
602 | + _deprecated_function('Sensei()->template_loader', '1.9.0', 'Use Sensei_Templates::template_loader( $template ) instead'); |
|
603 | + Sensei_Templates::template_loader($template); |
|
604 | 604 | |
605 | 605 | } // End template_loader() |
606 | 606 | |
@@ -610,15 +610,15 @@ discard block |
||
610 | 610 | * @since 1.0.0 |
611 | 611 | * @return string $sensei_plugin_path |
612 | 612 | */ |
613 | - public function plugin_path () { |
|
613 | + public function plugin_path() { |
|
614 | 614 | |
615 | - if ( $this->plugin_path ) { |
|
615 | + if ($this->plugin_path) { |
|
616 | 616 | |
617 | - $sensei_plugin_path = $this->plugin_path; |
|
617 | + $sensei_plugin_path = $this->plugin_path; |
|
618 | 618 | |
619 | - }else{ |
|
619 | + } else { |
|
620 | 620 | |
621 | - $sensei_plugin_path = plugin_dir_path( __FILE__ ); |
|
621 | + $sensei_plugin_path = plugin_dir_path(__FILE__); |
|
622 | 622 | |
623 | 623 | } |
624 | 624 | |
@@ -634,9 +634,9 @@ discard block |
||
634 | 634 | * @param string $page |
635 | 635 | * @return int |
636 | 636 | */ |
637 | - public function get_page_id ( $page ) { |
|
638 | - $page = apply_filters( 'sensei_get_' . esc_attr( $page ) . '_page_id', get_option( 'sensei_' . esc_attr( $page ) . '_page_id' ) ); |
|
639 | - return ( $page ) ? $page : -1; |
|
637 | + public function get_page_id($page) { |
|
638 | + $page = apply_filters('sensei_get_'.esc_attr($page).'_page_id', get_option('sensei_'.esc_attr($page).'_page_id')); |
|
639 | + return ($page) ? $page : -1; |
|
640 | 640 | } // End get_page_id() |
641 | 641 | |
642 | 642 | |
@@ -648,18 +648,18 @@ discard block |
||
648 | 648 | * @param array/Object $order_user (default: array()) Specific user's data. |
649 | 649 | * @return bool|int |
650 | 650 | */ |
651 | - public function woocommerce_course_update ( $course_id = 0, $order_user = array() ) { |
|
651 | + public function woocommerce_course_update($course_id = 0, $order_user = array()) { |
|
652 | 652 | global $current_user; |
653 | 653 | |
654 | - if ( ! isset( $current_user ) || !$current_user->ID > 0 ) return false; |
|
654 | + if ( ! isset($current_user) || ! $current_user->ID > 0) return false; |
|
655 | 655 | |
656 | 656 | $data_update = false; |
657 | 657 | |
658 | 658 | // Get the product ID |
659 | - $wc_post_id = get_post_meta( intval( $course_id ), '_course_woocommerce_product', true ); |
|
659 | + $wc_post_id = get_post_meta(intval($course_id), '_course_woocommerce_product', true); |
|
660 | 660 | |
661 | 661 | // Check if in the admin |
662 | - if ( is_admin() ) { |
|
662 | + if (is_admin()) { |
|
663 | 663 | $user_login = $order_user['user_login']; |
664 | 664 | $user_email = $order_user['user_email']; |
665 | 665 | $user_url = $order_user['user_url']; |
@@ -672,25 +672,25 @@ discard block |
||
672 | 672 | } // End If Statement |
673 | 673 | |
674 | 674 | // This doesn't appear to be purely WooCommerce related. Should it be in a separate function? |
675 | - $course_prerequisite_id = (int) get_post_meta( $course_id, '_course_prerequisite', true ); |
|
676 | - if( 0 < absint( $course_prerequisite_id ) ) { |
|
677 | - $prereq_course_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, intval( $user_id ) ); |
|
678 | - if ( ! $prereq_course_complete ) { |
|
675 | + $course_prerequisite_id = (int) get_post_meta($course_id, '_course_prerequisite', true); |
|
676 | + if (0 < absint($course_prerequisite_id)) { |
|
677 | + $prereq_course_complete = Sensei_Utils::user_completed_course($course_prerequisite_id, intval($user_id)); |
|
678 | + if ( ! $prereq_course_complete) { |
|
679 | 679 | // Remove all course user meta |
680 | - return Sensei_Utils::sensei_remove_user_from_course( $course_id, $user_id ); |
|
680 | + return Sensei_Utils::sensei_remove_user_from_course($course_id, $user_id); |
|
681 | 681 | } |
682 | 682 | } |
683 | 683 | |
684 | - $is_user_taking_course = Sensei_Utils::user_started_course( intval( $course_id ), intval( $user_id ) ); |
|
684 | + $is_user_taking_course = Sensei_Utils::user_started_course(intval($course_id), intval($user_id)); |
|
685 | 685 | |
686 | - if( ! $is_user_taking_course ) { |
|
686 | + if ( ! $is_user_taking_course) { |
|
687 | 687 | |
688 | - if ( Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product( $user_email, $user_id, $wc_post_id ) && ( 0 < $wc_post_id ) ) { |
|
688 | + if (Sensei_WC::is_woocommerce_active() && Sensei_Utils::sensei_customer_bought_product($user_email, $user_id, $wc_post_id) && (0 < $wc_post_id)) { |
|
689 | 689 | |
690 | - $activity_logged = Sensei_Utils::user_start_course( intval( $user_id), intval( $course_id ) ); |
|
690 | + $activity_logged = Sensei_Utils::user_start_course(intval($user_id), intval($course_id)); |
|
691 | 691 | |
692 | 692 | $is_user_taking_course = false; |
693 | - if ( true == $activity_logged ) { |
|
693 | + if (true == $activity_logged) { |
|
694 | 694 | $is_user_taking_course = true; |
695 | 695 | } // End If Statement |
696 | 696 | } // End If Statement |
@@ -708,16 +708,16 @@ discard block |
||
708 | 708 | * |
709 | 709 | * @return bool |
710 | 710 | */ |
711 | - public function check_user_permissions ( $page = '' ) { |
|
711 | + public function check_user_permissions($page = '') { |
|
712 | 712 | // REFACTOR |
713 | 713 | global $current_user, $post; |
714 | 714 | |
715 | 715 | // if use is not logged in |
716 | 716 | // skipped for single lesson |
717 | - if ( empty( $current_user->caps ) && Sensei()->settings->get('access_permission') |
|
718 | - && 'lesson-single' != $page ){ |
|
719 | - $this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei' ); |
|
720 | - $this->permissions_message['message'] = sprintf( __('You must be logged in to view this %s'), get_post_type() ); |
|
717 | + if (empty($current_user->caps) && Sensei()->settings->get('access_permission') |
|
718 | + && 'lesson-single' != $page) { |
|
719 | + $this->permissions_message['title'] = __('Restricted Access', 'woothemes-sensei'); |
|
720 | + $this->permissions_message['message'] = sprintf(__('You must be logged in to view this %s'), get_post_type()); |
|
721 | 721 | return false; |
722 | 722 | } |
723 | 723 | |
@@ -727,106 +727,106 @@ discard block |
||
727 | 727 | |
728 | 728 | $user_allowed = false; |
729 | 729 | |
730 | - switch ( $page ) { |
|
730 | + switch ($page) { |
|
731 | 731 | case 'course-single': |
732 | 732 | // check for prerequisite course or lesson, |
733 | - $course_prerequisite_id = (int) get_post_meta( $post->ID, '_course_prerequisite', true); |
|
734 | - $update_course = $this->woocommerce_course_update( $post->ID ); |
|
733 | + $course_prerequisite_id = (int) get_post_meta($post->ID, '_course_prerequisite', true); |
|
734 | + $update_course = $this->woocommerce_course_update($post->ID); |
|
735 | 735 | // Count completed lessons |
736 | - if ( 0 < absint( $course_prerequisite_id ) ) { |
|
736 | + if (0 < absint($course_prerequisite_id)) { |
|
737 | 737 | |
738 | - $prerequisite_complete = Sensei_Utils::user_completed_course( $course_prerequisite_id, $current_user->ID ); |
|
738 | + $prerequisite_complete = Sensei_Utils::user_completed_course($course_prerequisite_id, $current_user->ID); |
|
739 | 739 | |
740 | 740 | } |
741 | 741 | else { |
742 | 742 | $prerequisite_complete = true; |
743 | 743 | } // End If Statement |
744 | 744 | // Handles restrictions |
745 | - if ( !$prerequisite_complete && 0 < absint( $course_prerequisite_id ) ) { |
|
746 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
747 | - $course_link = '<a href="' . esc_url( get_permalink( $course_prerequisite_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
748 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this course.', 'woothemes-sensei' ), $course_link ); |
|
745 | + if ( ! $prerequisite_complete && 0 < absint($course_prerequisite_id)) { |
|
746 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
747 | + $course_link = '<a href="'.esc_url(get_permalink($course_prerequisite_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
748 | + $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this course.', 'woothemes-sensei'), $course_link); |
|
749 | 749 | } else { |
750 | 750 | $user_allowed = true; |
751 | 751 | } // End If Statement |
752 | 752 | break; |
753 | 753 | case 'lesson-single': |
754 | 754 | // Check for WC purchase |
755 | - $lesson_course_id = get_post_meta( $post->ID, '_lesson_course',true ); |
|
755 | + $lesson_course_id = get_post_meta($post->ID, '_lesson_course', true); |
|
756 | 756 | |
757 | - $update_course = $this->woocommerce_course_update( $lesson_course_id ); |
|
758 | - $is_preview = Sensei_Utils::is_preview_lesson( $post->ID ); |
|
757 | + $update_course = $this->woocommerce_course_update($lesson_course_id); |
|
758 | + $is_preview = Sensei_Utils::is_preview_lesson($post->ID); |
|
759 | 759 | |
760 | - if ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) { |
|
760 | + if ($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) { |
|
761 | 761 | $user_allowed = true; |
762 | - } elseif( $this->access_settings() && false == $is_preview ) { |
|
762 | + } elseif ($this->access_settings() && false == $is_preview) { |
|
763 | 763 | |
764 | 764 | $user_allowed = true; |
765 | 765 | |
766 | 766 | } else { |
767 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
768 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
769 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
770 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
771 | - if ( $is_preview ) { |
|
772 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
767 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
768 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
769 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
770 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
771 | + if ($is_preview) { |
|
772 | + $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please purchase the %1$s to access all lessons.', 'woothemes-sensei'), $course_link); |
|
773 | 773 | } else { |
774 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei' ), $course_link ); |
|
774 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Lesson.', 'woothemes-sensei'), $course_link); |
|
775 | 775 | } |
776 | 776 | } else { |
777 | - if ( $is_preview ) { |
|
778 | - $this->permissions_message['message'] = sprintf( __('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei' ), $course_link ); |
|
777 | + if ($is_preview) { |
|
778 | + $this->permissions_message['message'] = sprintf(__('This is a preview lesson. Please sign up for the %1$s to access all lessons.', 'woothemes-sensei'), $course_link); |
|
779 | 779 | } else { |
780 | 780 | /** This filter is documented in class-woothemes-sensei-frontend.php */ |
781 | - $this->permissions_message['message'] = sprintf( __( 'Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei' ), $course_link ); |
|
781 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting the lesson.', 'woothemes-sensei'), $course_link); |
|
782 | 782 | } |
783 | 783 | } // End If Statement |
784 | 784 | } // End If Statement |
785 | 785 | break; |
786 | 786 | case 'quiz-single': |
787 | - $lesson_id = get_post_meta( $post->ID, '_quiz_lesson',true ); |
|
788 | - $lesson_course_id = get_post_meta( $lesson_id, '_lesson_course',true ); |
|
787 | + $lesson_id = get_post_meta($post->ID, '_quiz_lesson', true); |
|
788 | + $lesson_course_id = get_post_meta($lesson_id, '_lesson_course', true); |
|
789 | 789 | |
790 | - $update_course = $this->woocommerce_course_update( $lesson_course_id ); |
|
791 | - if ( ( $this->access_settings() && Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) ) || sensei_all_access() ) { |
|
790 | + $update_course = $this->woocommerce_course_update($lesson_course_id); |
|
791 | + if (($this->access_settings() && Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID)) || sensei_all_access()) { |
|
792 | 792 | |
793 | 793 | // Check for prerequisite lesson for this quiz |
794 | - $lesson_prerequisite_id = (int) get_post_meta( $lesson_id, '_lesson_prerequisite', true); |
|
795 | - $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson( $lesson_prerequisite_id, $current_user->ID); |
|
794 | + $lesson_prerequisite_id = (int) get_post_meta($lesson_id, '_lesson_prerequisite', true); |
|
795 | + $user_lesson_prerequisite_complete = Sensei_Utils::user_completed_lesson($lesson_prerequisite_id, $current_user->ID); |
|
796 | 796 | |
797 | 797 | // Handle restrictions |
798 | - if( sensei_all_access() ) { |
|
798 | + if (sensei_all_access()) { |
|
799 | 799 | $user_allowed = true; |
800 | 800 | } else { |
801 | - if ( 0 < absint( $lesson_prerequisite_id ) && ( !$user_lesson_prerequisite_complete ) ) { |
|
802 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
803 | - $lesson_link = '<a href="' . esc_url( get_permalink( $lesson_prerequisite_id ) ) . '">' . __( 'lesson', 'woothemes-sensei' ) . '</a>'; |
|
804 | - $this->permissions_message['message'] = sprintf( __('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei' ), $lesson_link ); |
|
801 | + if (0 < absint($lesson_prerequisite_id) && ( ! $user_lesson_prerequisite_complete)) { |
|
802 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
803 | + $lesson_link = '<a href="'.esc_url(get_permalink($lesson_prerequisite_id)).'">'.__('lesson', 'woothemes-sensei').'</a>'; |
|
804 | + $this->permissions_message['message'] = sprintf(__('Please complete the previous %1$s before taking this Quiz.', 'woothemes-sensei'), $lesson_link); |
|
805 | 805 | } else { |
806 | 806 | $user_allowed = true; |
807 | 807 | } // End If Statement |
808 | 808 | } // End If Statement |
809 | - } elseif( $this->access_settings() ) { |
|
809 | + } elseif ($this->access_settings()) { |
|
810 | 810 | // Check if the user has started the course |
811 | 811 | |
812 | - if ( is_user_logged_in() && ! Sensei_Utils::user_started_course( $lesson_course_id, $current_user->ID ) && ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) ) { |
|
812 | + if (is_user_logged_in() && ! Sensei_Utils::user_started_course($lesson_course_id, $current_user->ID) && (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission']))) { |
|
813 | 813 | |
814 | 814 | $user_allowed = false; |
815 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
816 | - $course_link = '<a href="' . esc_url( get_permalink( $lesson_course_id ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
817 | - $wc_post_id = get_post_meta( $lesson_course_id, '_course_woocommerce_product',true ); |
|
818 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $wc_post_id ) ) { |
|
819 | - $this->permissions_message['message'] = sprintf( __('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
815 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
816 | + $course_link = '<a href="'.esc_url(get_permalink($lesson_course_id)).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
817 | + $wc_post_id = get_post_meta($lesson_course_id, '_course_woocommerce_product', true); |
|
818 | + if (Sensei_WC::is_woocommerce_active() && (0 < $wc_post_id)) { |
|
819 | + $this->permissions_message['message'] = sprintf(__('Please purchase the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
820 | 820 | } else { |
821 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
821 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before starting this Quiz.', 'woothemes-sensei'), $course_link); |
|
822 | 822 | } // End If Statement |
823 | 823 | } else { |
824 | 824 | $user_allowed = true; |
825 | 825 | } // End If Statement |
826 | 826 | } else { |
827 | - $this->permissions_message['title'] = get_the_title( $post->ID ) . ': ' . __('Restricted Access', 'woothemes-sensei' ); |
|
828 | - $course_link = '<a href="' . esc_url( get_permalink( get_post_meta( get_post_meta( $post->ID, '_quiz_lesson', true ), '_lesson_course', true ) ) ) . '">' . __( 'course', 'woothemes-sensei' ) . '</a>'; |
|
829 | - $this->permissions_message['message'] = sprintf( __('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei' ), $course_link ); |
|
827 | + $this->permissions_message['title'] = get_the_title($post->ID).': '.__('Restricted Access', 'woothemes-sensei'); |
|
828 | + $course_link = '<a href="'.esc_url(get_permalink(get_post_meta(get_post_meta($post->ID, '_quiz_lesson', true), '_lesson_course', true))).'">'.__('course', 'woothemes-sensei').'</a>'; |
|
829 | + $this->permissions_message['message'] = sprintf(__('Please sign up for the %1$s before taking this Quiz.', 'woothemes-sensei'), $course_link); |
|
830 | 830 | } // End If Statement |
831 | 831 | break; |
832 | 832 | default: |
@@ -848,14 +848,14 @@ discard block |
||
848 | 848 | * } |
849 | 849 | * @param string $post_id |
850 | 850 | */ |
851 | - $this->permissions_message = apply_filters( 'sensei_permissions_message', $this->permissions_message, $post->ID ); |
|
851 | + $this->permissions_message = apply_filters('sensei_permissions_message', $this->permissions_message, $post->ID); |
|
852 | 852 | |
853 | 853 | |
854 | - if( sensei_all_access() || Sensei_Utils::is_preview_lesson( $post->ID ) ) { |
|
854 | + if (sensei_all_access() || Sensei_Utils::is_preview_lesson($post->ID)) { |
|
855 | 855 | $user_allowed = true; |
856 | 856 | } |
857 | 857 | |
858 | - return apply_filters( 'sensei_access_permissions', $user_allowed ); |
|
858 | + return apply_filters('sensei_access_permissions', $user_allowed); |
|
859 | 859 | } // End get_placeholder_image() |
860 | 860 | |
861 | 861 | |
@@ -865,12 +865,12 @@ discard block |
||
865 | 865 | * @access public |
866 | 866 | * @return bool |
867 | 867 | */ |
868 | - public function access_settings () { |
|
868 | + public function access_settings() { |
|
869 | 869 | |
870 | - if( sensei_all_access() ) return true; |
|
870 | + if (sensei_all_access()) return true; |
|
871 | 871 | |
872 | - if ( isset( $this->settings->settings['access_permission'] ) && ( true == $this->settings->settings['access_permission'] ) ) { |
|
873 | - if ( is_user_logged_in() ) { |
|
872 | + if (isset($this->settings->settings['access_permission']) && (true == $this->settings->settings['access_permission'])) { |
|
873 | + if (is_user_logged_in()) { |
|
874 | 874 | return true; |
875 | 875 | } else { |
876 | 876 | return false; |
@@ -887,38 +887,38 @@ discard block |
||
887 | 887 | * @param int $order_id WC order ID |
888 | 888 | * @return void |
889 | 889 | */ |
890 | - public function sensei_woocommerce_complete_order ( $order_id = 0 ) { |
|
890 | + public function sensei_woocommerce_complete_order($order_id = 0) { |
|
891 | 891 | $order_user = array(); |
892 | 892 | // Check for WooCommerce |
893 | - if ( Sensei_WC::is_woocommerce_active() && ( 0 < $order_id ) ) { |
|
893 | + if (Sensei_WC::is_woocommerce_active() && (0 < $order_id)) { |
|
894 | 894 | // Get order object |
895 | - $order = new WC_Order( $order_id ); |
|
896 | - $user = get_user_by( 'id', $order->get_user_id() ); |
|
895 | + $order = new WC_Order($order_id); |
|
896 | + $user = get_user_by('id', $order->get_user_id()); |
|
897 | 897 | $order_user['ID'] = $user->ID; |
898 | 898 | $order_user['user_login'] = $user->user_login; |
899 | 899 | $order_user['user_email'] = $user->user_email; |
900 | 900 | $order_user['user_url'] = $user->user_url; |
901 | 901 | // Run through each product ordered |
902 | - if ( 0 < sizeof( $order->get_items() ) ) { |
|
903 | - foreach( $order->get_items() as $item ) { |
|
902 | + if (0 < sizeof($order->get_items())) { |
|
903 | + foreach ($order->get_items() as $item) { |
|
904 | 904 | $product_type = ''; |
905 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
905 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
906 | 906 | $item_id = $item['variation_id']; |
907 | 907 | $product_type = 'variation'; |
908 | 908 | } else { |
909 | 909 | $item_id = $item['product_id']; |
910 | 910 | } // End If Statement |
911 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
911 | + $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type); |
|
912 | 912 | // Get courses that use the WC product |
913 | - $courses = $this->post_types->course->get_product_courses( $_product->id ); |
|
913 | + $courses = $this->post_types->course->get_product_courses($_product->id); |
|
914 | 914 | // Loop and update those courses |
915 | - foreach ( $courses as $course_item ) { |
|
916 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
915 | + foreach ($courses as $course_item) { |
|
916 | + $update_course = $this->woocommerce_course_update($course_item->ID, $order_user); |
|
917 | 917 | } // End For Loop |
918 | 918 | } // End For Loop |
919 | 919 | } // End If Statement |
920 | 920 | // Add meta to indicate that payment has been completed successfully |
921 | - update_post_meta( $order_id, 'sensei_payment_complete', '1' ); |
|
921 | + update_post_meta($order_id, 'sensei_payment_complete', '1'); |
|
922 | 922 | } // End If Statement |
923 | 923 | } // End sensei_woocommerce_complete_order() |
924 | 924 | |
@@ -929,36 +929,36 @@ discard block |
||
929 | 929 | * @param integer $order_id order ID |
930 | 930 | * @return void |
931 | 931 | */ |
932 | - public function sensei_woocommerce_cancel_order ( $order_id ) { |
|
932 | + public function sensei_woocommerce_cancel_order($order_id) { |
|
933 | 933 | |
934 | 934 | // Get order object |
935 | - $order = new WC_Order( $order_id ); |
|
935 | + $order = new WC_Order($order_id); |
|
936 | 936 | |
937 | 937 | // Run through each product ordered |
938 | - if ( 0 < sizeof( $order->get_items() ) ) { |
|
938 | + if (0 < sizeof($order->get_items())) { |
|
939 | 939 | |
940 | 940 | // Get order user |
941 | - $user_id = $order->__get( 'user_id' ); |
|
941 | + $user_id = $order->__get('user_id'); |
|
942 | 942 | |
943 | - foreach( $order->get_items() as $item ) { |
|
943 | + foreach ($order->get_items() as $item) { |
|
944 | 944 | |
945 | 945 | $product_type = ''; |
946 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
946 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
947 | 947 | $item_id = $item['variation_id']; |
948 | 948 | $product_type = 'variation'; |
949 | 949 | } else { |
950 | 950 | $item_id = $item['product_id']; |
951 | 951 | } // End If Statement |
952 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
952 | + $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type); |
|
953 | 953 | |
954 | 954 | // Get courses that use the WC product |
955 | 955 | $courses = array(); |
956 | - $courses = $this->post_types->course->get_product_courses( $item_id ); |
|
956 | + $courses = $this->post_types->course->get_product_courses($item_id); |
|
957 | 957 | |
958 | 958 | // Loop and update those courses |
959 | - foreach ($courses as $course_item){ |
|
959 | + foreach ($courses as $course_item) { |
|
960 | 960 | // Check and Remove course from courses user meta |
961 | - $dataset_changes = Sensei_Utils::sensei_remove_user_from_course( $course_item->ID, $user_id ); |
|
961 | + $dataset_changes = Sensei_Utils::sensei_remove_user_from_course($course_item->ID, $user_id); |
|
962 | 962 | } // End For Loop |
963 | 963 | } // End For Loop |
964 | 964 | } // End If Statement |
@@ -972,9 +972,9 @@ discard block |
||
972 | 972 | * @param integer $subscription_key Subscription Unique Key |
973 | 973 | * @return void |
974 | 974 | */ |
975 | - public function sensei_woocommerce_subscription_ended( $user_id, $subscription_key ) { |
|
976 | - $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); |
|
977 | - self::sensei_woocommerce_cancel_order( $subscription['order_id'] ); |
|
975 | + public function sensei_woocommerce_subscription_ended($user_id, $subscription_key) { |
|
976 | + $subscription = WC_Subscriptions_Manager::get_users_subscription($user_id, $subscription_key); |
|
977 | + self::sensei_woocommerce_cancel_order($subscription['order_id']); |
|
978 | 978 | } |
979 | 979 | |
980 | 980 | /** |
@@ -985,18 +985,18 @@ discard block |
||
985 | 985 | * @param integer $subscription_key Subscription Unique Key |
986 | 986 | * @return void |
987 | 987 | */ |
988 | - public function sensei_woocommerce_reactivate_subscription( $user_id, $subscription_key ) { |
|
989 | - $subscription = WC_Subscriptions_Manager::get_users_subscription( $user_id, $subscription_key ); |
|
990 | - $order = new WC_Order( $subscription['order_id'] ); |
|
991 | - $user = get_user_by( 'id', $order->get_user_id() ); |
|
988 | + public function sensei_woocommerce_reactivate_subscription($user_id, $subscription_key) { |
|
989 | + $subscription = WC_Subscriptions_Manager::get_users_subscription($user_id, $subscription_key); |
|
990 | + $order = new WC_Order($subscription['order_id']); |
|
991 | + $user = get_user_by('id', $order->get_user_id()); |
|
992 | 992 | $order_user = array(); |
993 | 993 | $order_user['ID'] = $user->ID; |
994 | 994 | $order_user['user_login'] = $user->user_login; |
995 | 995 | $order_user['user_email'] = $user->user_email; |
996 | 996 | $order_user['user_url'] = $user->user_url; |
997 | - $courses = $this->post_types->course->get_product_courses( $subscription['product_id'] ); |
|
998 | - foreach ( $courses as $course_item ){ |
|
999 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
997 | + $courses = $this->post_types->course->get_product_courses($subscription['product_id']); |
|
998 | + foreach ($courses as $course_item) { |
|
999 | + $update_course = $this->woocommerce_course_update($course_item->ID, $order_user); |
|
1000 | 1000 | } // End For Loop |
1001 | 1001 | } // End sensei_woocommerce_reactivate_subscription |
1002 | 1002 | |
@@ -1011,30 +1011,30 @@ discard block |
||
1011 | 1011 | * @param string $product_type '' or 'variation' |
1012 | 1012 | * @return WC_Product $wc_product_object |
1013 | 1013 | */ |
1014 | - public function sensei_get_woocommerce_product_object ( $wc_product_id = 0, $product_type = '' ) { |
|
1014 | + public function sensei_get_woocommerce_product_object($wc_product_id = 0, $product_type = '') { |
|
1015 | 1015 | |
1016 | 1016 | $wc_product_object = false; |
1017 | - if ( 0 < intval( $wc_product_id ) ) { |
|
1017 | + if (0 < intval($wc_product_id)) { |
|
1018 | 1018 | |
1019 | 1019 | // Get the product |
1020 | - if ( function_exists( 'wc_get_product' ) ) { |
|
1020 | + if (function_exists('wc_get_product')) { |
|
1021 | 1021 | |
1022 | - $wc_product_object = wc_get_product( $wc_product_id ); // Post WC 2.3 |
|
1022 | + $wc_product_object = wc_get_product($wc_product_id); // Post WC 2.3 |
|
1023 | 1023 | |
1024 | - } elseif ( function_exists( 'get_product' ) ) { |
|
1024 | + } elseif (function_exists('get_product')) { |
|
1025 | 1025 | |
1026 | - $wc_product_object = get_product( $wc_product_id ); // Post WC 2.0 |
|
1026 | + $wc_product_object = get_product($wc_product_id); // Post WC 2.0 |
|
1027 | 1027 | |
1028 | 1028 | } else { |
1029 | 1029 | |
1030 | 1030 | // Pre WC 2.0 |
1031 | - if ( 'variation' == $product_type || 'subscription_variation' == $product_type ) { |
|
1031 | + if ('variation' == $product_type || 'subscription_variation' == $product_type) { |
|
1032 | 1032 | |
1033 | - $wc_product_object = new WC_Product_Variation( $wc_product_id ); |
|
1033 | + $wc_product_object = new WC_Product_Variation($wc_product_id); |
|
1034 | 1034 | |
1035 | 1035 | } else { |
1036 | 1036 | |
1037 | - $wc_product_object = new WC_Product( $wc_product_id ); |
|
1037 | + $wc_product_object = new WC_Product($wc_product_id); |
|
1038 | 1038 | |
1039 | 1039 | } // End If Statement |
1040 | 1040 | |
@@ -1052,9 +1052,9 @@ discard block |
||
1052 | 1052 | * @access public |
1053 | 1053 | * @return void |
1054 | 1054 | */ |
1055 | - public function load_class ( $class_name = '' ) { |
|
1056 | - if ( '' != $class_name && '' != $this->token ) { |
|
1057 | - require_once( 'class-' . esc_attr( $this->token ) . '-' . esc_attr( $class_name ) . '.php' ); |
|
1055 | + public function load_class($class_name = '') { |
|
1056 | + if ('' != $class_name && '' != $this->token) { |
|
1057 | + require_once('class-'.esc_attr($this->token).'-'.esc_attr($class_name).'.php'); |
|
1058 | 1058 | } // End If Statement |
1059 | 1059 | } // End load_class() |
1060 | 1060 | |
@@ -1065,17 +1065,17 @@ discard block |
||
1065 | 1065 | * @param integer $order_id order ID |
1066 | 1066 | * @return void |
1067 | 1067 | */ |
1068 | - public function sensei_activate_subscription( $order_id = 0 ) { |
|
1069 | - if ( 0 < intval( $order_id ) ) { |
|
1070 | - $order = new WC_Order( $order_id ); |
|
1068 | + public function sensei_activate_subscription($order_id = 0) { |
|
1069 | + if (0 < intval($order_id)) { |
|
1070 | + $order = new WC_Order($order_id); |
|
1071 | 1071 | $user = get_user_by('id', $order->user_id); |
1072 | 1072 | $order_user['ID'] = $user->ID; |
1073 | 1073 | $order_user['user_login'] = $user->user_login; |
1074 | 1074 | $order_user['user_email'] = $user->user_email; |
1075 | 1075 | $order_user['user_url'] = $user->user_url; |
1076 | 1076 | // Run through each product ordered |
1077 | - if (sizeof($order->get_items())>0) { |
|
1078 | - foreach($order->get_items() as $item) { |
|
1077 | + if (sizeof($order->get_items()) > 0) { |
|
1078 | + foreach ($order->get_items() as $item) { |
|
1079 | 1079 | $product_type = ''; |
1080 | 1080 | if (isset($item['variation_id']) && $item['variation_id'] > 0) { |
1081 | 1081 | $item_id = $item['variation_id']; |
@@ -1083,15 +1083,15 @@ discard block |
||
1083 | 1083 | } else { |
1084 | 1084 | $item_id = $item['product_id']; |
1085 | 1085 | } // End If Statement |
1086 | - $_product = $this->sensei_get_woocommerce_product_object( $item_id, $product_type ); |
|
1086 | + $_product = $this->sensei_get_woocommerce_product_object($item_id, $product_type); |
|
1087 | 1087 | // Get courses that use the WC product |
1088 | 1088 | $courses = array(); |
1089 | - if ( $product_type == 'subscription_variation' ) { |
|
1090 | - $courses = $this->post_types->course->get_product_courses( $item_id ); |
|
1089 | + if ($product_type == 'subscription_variation') { |
|
1090 | + $courses = $this->post_types->course->get_product_courses($item_id); |
|
1091 | 1091 | } // End If Statement |
1092 | 1092 | // Loop and update those courses |
1093 | - foreach ($courses as $course_item){ |
|
1094 | - $update_course = $this->woocommerce_course_update( $course_item->ID, $order_user ); |
|
1093 | + foreach ($courses as $course_item) { |
|
1094 | + $update_course = $this->woocommerce_course_update($course_item->ID, $order_user); |
|
1095 | 1095 | } // End For Loop |
1096 | 1096 | } // End For Loop |
1097 | 1097 | } // End If Statement |
@@ -1105,12 +1105,12 @@ discard block |
||
1105 | 1105 | * @param WC_Order $order |
1106 | 1106 | * @return void |
1107 | 1107 | */ |
1108 | - public function sensei_woocommerce_email_course_details( $order ) { |
|
1108 | + public function sensei_woocommerce_email_course_details($order) { |
|
1109 | 1109 | global $woocommerce; |
1110 | 1110 | |
1111 | 1111 | // exit early if not wc-completed or wc-processing |
1112 | - if( 'wc-completed' != $order->post_status |
|
1113 | - && 'wc-processing' != $order->post_status ) { |
|
1112 | + if ('wc-completed' != $order->post_status |
|
1113 | + && 'wc-processing' != $order->post_status) { |
|
1114 | 1114 | return; |
1115 | 1115 | } |
1116 | 1116 | |
@@ -1118,16 +1118,16 @@ discard block |
||
1118 | 1118 | $order_id = $order->id; |
1119 | 1119 | |
1120 | 1120 | //If object have items go through them all to find course |
1121 | - if ( 0 < sizeof( $order_items ) ) { |
|
1121 | + if (0 < sizeof($order_items)) { |
|
1122 | 1122 | |
1123 | - $course_details_html = '<h2>' . __( 'Course details', 'woothemes-sensei' ) . '</h2>'; |
|
1123 | + $course_details_html = '<h2>'.__('Course details', 'woothemes-sensei').'</h2>'; |
|
1124 | 1124 | $order_contains_courses = false; |
1125 | 1125 | |
1126 | 1126 | |
1127 | - foreach ( $order_items as $item ) { |
|
1127 | + foreach ($order_items as $item) { |
|
1128 | 1128 | |
1129 | 1129 | $product_type = ''; |
1130 | - if ( isset( $item['variation_id'] ) && ( 0 < $item['variation_id'] ) ) { |
|
1130 | + if (isset($item['variation_id']) && (0 < $item['variation_id'])) { |
|
1131 | 1131 | // If item has variation_id then its from variation |
1132 | 1132 | $item_id = $item['variation_id']; |
1133 | 1133 | $product_type = 'variation'; |
@@ -1136,9 +1136,9 @@ discard block |
||
1136 | 1136 | $item_id = $item['product_id']; |
1137 | 1137 | } // End If Statement |
1138 | 1138 | |
1139 | - $user_id = get_post_meta( $order_id, '_customer_user', true ); |
|
1139 | + $user_id = get_post_meta($order_id, '_customer_user', true); |
|
1140 | 1140 | |
1141 | - if( $user_id ) { |
|
1141 | + if ($user_id) { |
|
1142 | 1142 | |
1143 | 1143 | // Get all courses for product |
1144 | 1144 | $args = array( |
@@ -1153,16 +1153,16 @@ discard block |
||
1153 | 1153 | 'orderby' => 'menu_order date', |
1154 | 1154 | 'order' => 'ASC', |
1155 | 1155 | ); |
1156 | - $courses = get_posts( $args ); |
|
1156 | + $courses = get_posts($args); |
|
1157 | 1157 | |
1158 | - if( $courses && count( $courses ) > 0 ) { |
|
1158 | + if ($courses && count($courses) > 0) { |
|
1159 | 1159 | |
1160 | - foreach( $courses as $course ) { |
|
1160 | + foreach ($courses as $course) { |
|
1161 | 1161 | |
1162 | 1162 | $title = $course->post_title; |
1163 | - $permalink = get_permalink( $course->ID ); |
|
1163 | + $permalink = get_permalink($course->ID); |
|
1164 | 1164 | $order_contains_courses = true; |
1165 | - $course_details_html .= '<p><strong>' . sprintf( __( 'View course: %1$s', 'woothemes-sensei' ), '</strong><a href="' . esc_url( $permalink ) . '">' . $title . '</a>' ) . '</p>'; |
|
1165 | + $course_details_html .= '<p><strong>'.sprintf(__('View course: %1$s', 'woothemes-sensei'), '</strong><a href="'.esc_url($permalink).'">'.$title.'</a>').'</p>'; |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | |
@@ -1173,7 +1173,7 @@ discard block |
||
1173 | 1173 | } // end for each order item |
1174 | 1174 | |
1175 | 1175 | // Output Course details |
1176 | - if( $order_contains_courses ){ |
|
1176 | + if ($order_contains_courses) { |
|
1177 | 1177 | |
1178 | 1178 | echo $course_details_html; |
1179 | 1179 | |
@@ -1192,44 +1192,44 @@ discard block |
||
1192 | 1192 | * @param integer $post_id |
1193 | 1193 | * @return array |
1194 | 1194 | */ |
1195 | - public function sensei_count_comments( $comments, $post_id ) { |
|
1195 | + public function sensei_count_comments($comments, $post_id) { |
|
1196 | 1196 | global $wpdb; |
1197 | 1197 | |
1198 | 1198 | $post_id = (int) $post_id; |
1199 | 1199 | |
1200 | 1200 | $count = wp_cache_get("comments-{$post_id}", 'counts'); |
1201 | 1201 | |
1202 | - if ( false !== $count ) { |
|
1202 | + if (false !== $count) { |
|
1203 | 1203 | return $count; |
1204 | 1204 | } |
1205 | 1205 | |
1206 | - $statuses = array( '' ); // Default to the WP normal comments |
|
1207 | - $stati = $wpdb->get_results( "SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A ); |
|
1208 | - foreach ( (array) $stati AS $status ) { |
|
1209 | - if ( 'sensei_' != substr($status['comment_type'], 0, 7 ) ) { |
|
1206 | + $statuses = array(''); // Default to the WP normal comments |
|
1207 | + $stati = $wpdb->get_results("SELECT comment_type FROM {$wpdb->comments} GROUP BY comment_type", ARRAY_A); |
|
1208 | + foreach ((array) $stati AS $status) { |
|
1209 | + if ('sensei_' != substr($status['comment_type'], 0, 7)) { |
|
1210 | 1210 | $statuses[] = $status['comment_type']; |
1211 | 1211 | } |
1212 | 1212 | } |
1213 | - $where = "WHERE comment_type IN ('" . join("', '", array_unique( $statuses ) ) . "')"; |
|
1213 | + $where = "WHERE comment_type IN ('".join("', '", array_unique($statuses))."')"; |
|
1214 | 1214 | |
1215 | - if ( $post_id > 0 ) |
|
1216 | - $where .= $wpdb->prepare( " AND comment_post_ID = %d", $post_id ); |
|
1215 | + if ($post_id > 0) |
|
1216 | + $where .= $wpdb->prepare(" AND comment_post_ID = %d", $post_id); |
|
1217 | 1217 | |
1218 | - $count = $wpdb->get_results( "SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A ); |
|
1218 | + $count = $wpdb->get_results("SELECT comment_approved, COUNT( * ) AS num_comments FROM {$wpdb->comments} {$where} GROUP BY comment_approved", ARRAY_A); |
|
1219 | 1219 | |
1220 | 1220 | $total = 0; |
1221 | 1221 | $approved = array('0' => 'moderated', '1' => 'approved', 'spam' => 'spam', 'trash' => 'trash', 'post-trashed' => 'post-trashed'); |
1222 | - foreach ( (array) $count as $row ) { |
|
1222 | + foreach ((array) $count as $row) { |
|
1223 | 1223 | // Don't count post-trashed toward totals |
1224 | - if ( 'post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved'] ) |
|
1224 | + if ('post-trashed' != $row['comment_approved'] && 'trash' != $row['comment_approved']) |
|
1225 | 1225 | $total += $row['num_comments']; |
1226 | - if ( isset( $approved[$row['comment_approved']] ) ) |
|
1226 | + if (isset($approved[$row['comment_approved']])) |
|
1227 | 1227 | $stats[$approved[$row['comment_approved']]] = $row['num_comments']; |
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | $stats['total_comments'] = $total; |
1231 | - foreach ( $approved as $key ) { |
|
1232 | - if ( empty($stats[$key]) ) |
|
1231 | + foreach ($approved as $key) { |
|
1232 | + if (empty($stats[$key])) |
|
1233 | 1233 | $stats[$key] = 0; |
1234 | 1234 | } |
1235 | 1235 | |
@@ -1247,15 +1247,15 @@ discard block |
||
1247 | 1247 | * @return void |
1248 | 1248 | */ |
1249 | 1249 | public function init_image_sizes() { |
1250 | - $course_archive_thumbnail = $this->get_image_size( 'course_archive_image' ); |
|
1251 | - $course_single_thumbnail = $this->get_image_size( 'course_single_image' ); |
|
1252 | - $lesson_archive_thumbnail = $this->get_image_size( 'lesson_archive_image' ); |
|
1253 | - $lesson_single_thumbnail = $this->get_image_size( 'lesson_single_image' ); |
|
1254 | - |
|
1255 | - add_image_size( 'course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop'] ); |
|
1256 | - add_image_size( 'course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop'] ); |
|
1257 | - add_image_size( 'lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop'] ); |
|
1258 | - add_image_size( 'lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop'] ); |
|
1250 | + $course_archive_thumbnail = $this->get_image_size('course_archive_image'); |
|
1251 | + $course_single_thumbnail = $this->get_image_size('course_single_image'); |
|
1252 | + $lesson_archive_thumbnail = $this->get_image_size('lesson_archive_image'); |
|
1253 | + $lesson_single_thumbnail = $this->get_image_size('lesson_single_image'); |
|
1254 | + |
|
1255 | + add_image_size('course_archive_thumbnail', $course_archive_thumbnail['width'], $course_archive_thumbnail['height'], $course_archive_thumbnail['crop']); |
|
1256 | + add_image_size('course_single_thumbnail', $course_single_thumbnail['width'], $course_single_thumbnail['height'], $course_single_thumbnail['crop']); |
|
1257 | + add_image_size('lesson_archive_thumbnail', $lesson_archive_thumbnail['width'], $lesson_archive_thumbnail['height'], $lesson_archive_thumbnail['crop']); |
|
1258 | + add_image_size('lesson_single_thumbnail', $lesson_single_thumbnail['width'], $lesson_single_thumbnail['height'], $lesson_single_thumbnail['crop']); |
|
1259 | 1259 | } |
1260 | 1260 | |
1261 | 1261 | /** |
@@ -1268,37 +1268,37 @@ discard block |
||
1268 | 1268 | * @param mixed $image_size |
1269 | 1269 | * @return string |
1270 | 1270 | */ |
1271 | - public function get_image_size( $image_size ) { |
|
1271 | + public function get_image_size($image_size) { |
|
1272 | 1272 | |
1273 | 1273 | // Only return sizes we define in settings |
1274 | - if ( ! in_array( $image_size, array( 'course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image' ) ) ) |
|
1275 | - return apply_filters( 'sensei_get_image_size_' . $image_size, '' ); |
|
1274 | + if ( ! in_array($image_size, array('course_archive_image', 'course_single_image', 'lesson_archive_image', 'lesson_single_image'))) |
|
1275 | + return apply_filters('sensei_get_image_size_'.$image_size, ''); |
|
1276 | 1276 | |
1277 | - if( ! isset( $this->settings->settings[ $image_size . '_width' ] ) ) { |
|
1278 | - $this->settings->settings[ $image_size . '_width' ] = false; |
|
1277 | + if ( ! isset($this->settings->settings[$image_size.'_width'])) { |
|
1278 | + $this->settings->settings[$image_size.'_width'] = false; |
|
1279 | 1279 | } |
1280 | - if( ! isset( $this->settings->settings[ $image_size . '_height' ] ) ) { |
|
1281 | - $this->settings->settings[ $image_size . '_height' ] = false; |
|
1280 | + if ( ! isset($this->settings->settings[$image_size.'_height'])) { |
|
1281 | + $this->settings->settings[$image_size.'_height'] = false; |
|
1282 | 1282 | } |
1283 | - if( ! isset( $this->settings->settings[ $image_size . '_hard_crop' ] ) ) { |
|
1284 | - $this->settings->settings[ $image_size . '_hard_crop' ] = false; |
|
1283 | + if ( ! isset($this->settings->settings[$image_size.'_hard_crop'])) { |
|
1284 | + $this->settings->settings[$image_size.'_hard_crop'] = false; |
|
1285 | 1285 | } |
1286 | 1286 | |
1287 | - $size = array_filter( array( |
|
1288 | - 'width' => $this->settings->settings[ $image_size . '_width' ], |
|
1289 | - 'height' => $this->settings->settings[ $image_size . '_height' ], |
|
1290 | - 'crop' => $this->settings->settings[ $image_size . '_hard_crop' ] |
|
1291 | - ) ); |
|
1287 | + $size = array_filter(array( |
|
1288 | + 'width' => $this->settings->settings[$image_size.'_width'], |
|
1289 | + 'height' => $this->settings->settings[$image_size.'_height'], |
|
1290 | + 'crop' => $this->settings->settings[$image_size.'_hard_crop'] |
|
1291 | + )); |
|
1292 | 1292 | |
1293 | - $size['width'] = isset( $size['width'] ) ? $size['width'] : '100'; |
|
1294 | - $size['height'] = isset( $size['height'] ) ? $size['height'] : '100'; |
|
1295 | - $size['crop'] = isset( $size['crop'] ) ? $size['crop'] : 0; |
|
1293 | + $size['width'] = isset($size['width']) ? $size['width'] : '100'; |
|
1294 | + $size['height'] = isset($size['height']) ? $size['height'] : '100'; |
|
1295 | + $size['crop'] = isset($size['crop']) ? $size['crop'] : 0; |
|
1296 | 1296 | |
1297 | - return apply_filters( 'sensei_get_image_size_' . $image_size, $size ); |
|
1297 | + return apply_filters('sensei_get_image_size_'.$image_size, $size); |
|
1298 | 1298 | } |
1299 | 1299 | |
1300 | - public function body_class( $classes ) { |
|
1301 | - if( is_sensei() ) { |
|
1300 | + public function body_class($classes) { |
|
1301 | + if (is_sensei()) { |
|
1302 | 1302 | $classes[] = 'sensei'; |
1303 | 1303 | } |
1304 | 1304 | return $classes; |
@@ -1311,9 +1311,9 @@ discard block |
||
1311 | 1311 | * @since 1.7.0 |
1312 | 1312 | */ |
1313 | 1313 | public function jetpack_latex_support() { |
1314 | - if ( function_exists( 'latex_markup') ) { |
|
1315 | - add_filter( 'sensei_question_title', 'latex_markup' ); |
|
1316 | - add_filter( 'sensei_answer_text', 'latex_markup' ); |
|
1314 | + if (function_exists('latex_markup')) { |
|
1315 | + add_filter('sensei_question_title', 'latex_markup'); |
|
1316 | + add_filter('sensei_answer_text', 'latex_markup'); |
|
1317 | 1317 | } |
1318 | 1318 | } |
1319 | 1319 | |
@@ -1325,21 +1325,21 @@ discard block |
||
1325 | 1325 | * |
1326 | 1326 | * @since 1.8.0 |
1327 | 1327 | */ |
1328 | - public function load_modules_class(){ |
|
1328 | + public function load_modules_class() { |
|
1329 | 1329 | global $sensei_modules; |
1330 | 1330 | |
1331 | - if( !class_exists( 'Sensei_Modules' ) |
|
1332 | - && 'Sensei_Modules' != get_class( $sensei_modules ) ) { |
|
1331 | + if ( ! class_exists('Sensei_Modules') |
|
1332 | + && 'Sensei_Modules' != get_class($sensei_modules)) { |
|
1333 | 1333 | |
1334 | 1334 | //Load the modules class |
1335 | - require_once( 'class-sensei-modules.php'); |
|
1336 | - Sensei()->modules = new Sensei_Core_Modules( $this->file ); |
|
1335 | + require_once('class-sensei-modules.php'); |
|
1336 | + Sensei()->modules = new Sensei_Core_Modules($this->file); |
|
1337 | 1337 | |
1338 | - }else{ |
|
1338 | + } else { |
|
1339 | 1339 | // fallback for people still using the modules extension. |
1340 | 1340 | global $sensei_modules; |
1341 | 1341 | Sensei()->modules = $sensei_modules; |
1342 | - add_action( 'admin_notices', array( $this, 'disable_sensei_modules_extension'), 30 ); |
|
1342 | + add_action('admin_notices', array($this, 'disable_sensei_modules_extension'), 30); |
|
1343 | 1343 | } |
1344 | 1344 | } |
1345 | 1345 | |
@@ -1348,12 +1348,12 @@ discard block |
||
1348 | 1348 | * |
1349 | 1349 | * @since 1.8.0 |
1350 | 1350 | */ |
1351 | - public function disable_sensei_modules_extension(){ ?> |
|
1351 | + public function disable_sensei_modules_extension() { ?> |
|
1352 | 1352 | <div class="notice updated fade"> |
1353 | 1353 | <p> |
1354 | 1354 | <?php |
1355 | 1355 | $plugin_manage_url = admin_url().'plugins.php#sensei-modules'; |
1356 | - $plugin_link_element = '<a href="' . $plugin_manage_url . '" >plugins page</a> '; |
|
1356 | + $plugin_link_element = '<a href="'.$plugin_manage_url.'" >plugins page</a> '; |
|
1357 | 1357 | ?> |
1358 | 1358 | <strong> Modules are now included in Sensei,</strong> so you no longer need the Sensei Modules extension. |
1359 | 1359 | Please deactivate and delete it from your <?php echo $plugin_link_element; ?>. (This will not affect your existing modules). |
@@ -1371,18 +1371,18 @@ discard block |
||
1371 | 1371 | * |
1372 | 1372 | * @since 1.9.0 |
1373 | 1373 | */ |
1374 | - public function flush_rewrite_rules(){ |
|
1374 | + public function flush_rewrite_rules() { |
|
1375 | 1375 | |
1376 | 1376 | // ensures that the rewrite rules are flushed on the second |
1377 | 1377 | // attempt. This ensure that the settings for any other process |
1378 | 1378 | // have been completed and saved to the database before we refresh the |
1379 | 1379 | // rewrite rules. |
1380 | - $option = get_option('sensei_flush_rewrite_rules'); |
|
1381 | - if( '1' == $option ) { |
|
1380 | + $option = get_option('sensei_flush_rewrite_rules'); |
|
1381 | + if ('1' == $option) { |
|
1382 | 1382 | |
1383 | 1383 | update_option('sensei_flush_rewrite_rules', '2'); |
1384 | 1384 | |
1385 | - }elseif( '2' == $option ) { |
|
1385 | + }elseif ('2' == $option) { |
|
1386 | 1386 | |
1387 | 1387 | flush_rewrite_rules(); |
1388 | 1388 | update_option('sensei_flush_rewrite_rules', '0'); |
@@ -1397,7 +1397,7 @@ discard block |
||
1397 | 1397 | * |
1398 | 1398 | * @since 1.9.0 |
1399 | 1399 | */ |
1400 | - public function initiate_rewrite_rules_flush(){ |
|
1400 | + public function initiate_rewrite_rules_flush() { |
|
1401 | 1401 | |
1402 | 1402 | update_option('sensei_flush_rewrite_rules', '1'); |
1403 | 1403 | |
@@ -1410,4 +1410,4 @@ discard block |
||
1410 | 1410 | * for backward compatibility |
1411 | 1411 | * @since 1.9.0 |
1412 | 1412 | */ |
1413 | -class Woothemes_Sensei extends Sensei_Main{ } |
|
1413 | +class Woothemes_Sensei extends Sensei_Main { } |
@@ -10,91 +10,91 @@ |
||
10 | 10 | */ |
11 | 11 | class Sensei_Theme_Integration_Loader { |
12 | 12 | |
13 | - /** |
|
14 | - * @var array |
|
15 | - * Holding a reference core supported themes |
|
16 | - */ |
|
17 | - protected $themes; |
|
18 | - |
|
19 | - /** |
|
20 | - * @var string |
|
21 | - * reference to the theme currently active on this site |
|
22 | - */ |
|
23 | - protected $active_theme; |
|
24 | - |
|
25 | - public function __construct() { |
|
26 | - |
|
27 | - $this->setup_themes(); |
|
28 | - $this->setup_currently_active_theme(); |
|
29 | - $this->possibly_load_supported_theme_wrappers(); |
|
30 | - |
|
31 | - } |
|
32 | - |
|
33 | - /** |
|
34 | - * Setup the theme slugs supported by Sensei Core |
|
35 | - * |
|
36 | - * @since 1.9.0 |
|
37 | - */ |
|
38 | - private function setup_themes(){ |
|
39 | - |
|
40 | - $this->themes = array( |
|
41 | - 'twentyeleven', |
|
42 | - 'twentytwelve', |
|
43 | - 'twentythirteen', |
|
44 | - 'twentyfourteen', |
|
45 | - 'twentyfifteen', |
|
46 | - 'twentysixteen', |
|
47 | - 'storefront', |
|
48 | - ); |
|
49 | - |
|
50 | - }// end setup themes |
|
51 | - |
|
52 | - /** |
|
53 | - * Setup the currently active theme |
|
54 | - * |
|
55 | - * @since 1.9.0 |
|
56 | - */ |
|
57 | - private function setup_currently_active_theme(){ |
|
58 | - |
|
59 | - $this->active_theme = get_option('template'); |
|
60 | - |
|
61 | - } |
|
62 | - |
|
63 | - /** |
|
64 | - * Remove default Sensei wrappers and load |
|
65 | - * supported wrappers if the current theme is |
|
66 | - * a theme we have an integration for within core. |
|
67 | - * |
|
68 | - * @since 1.9.0 |
|
69 | - */ |
|
70 | - private function possibly_load_supported_theme_wrappers(){ |
|
71 | - |
|
72 | - if ( in_array( $this->active_theme, $this->themes ) ){ |
|
73 | - |
|
74 | - // setup file and class names |
|
75 | - $supported_theme_class_file = trailingslashit( Sensei()->plugin_path ) . 'includes/theme-integrations/' . $this->active_theme . '.php'; |
|
76 | - $supported_theme_class_name = 'Sensei_'. ucfirst( $this->active_theme ); |
|
77 | - |
|
78 | - // load the file or exit if there is no file for this theme |
|
79 | - if( ! file_exists( $supported_theme_class_file ) ){ |
|
80 | - return; |
|
81 | - } |
|
82 | - include_once( $supported_theme_class_file ); |
|
83 | - include_once( 'twentytwelve.php' ); |
|
84 | - //initialize the class or exit if there is no class for this theme |
|
85 | - if( ! class_exists( $supported_theme_class_name ) ){ |
|
86 | - return; |
|
87 | - } |
|
88 | - $supported_theme = new $supported_theme_class_name; |
|
89 | - |
|
90 | - // remove default wrappers |
|
91 | - remove_action( 'sensei_before_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper' ), 10 ); |
|
92 | - remove_action( 'sensei_after_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper_end' ), 10 ); |
|
93 | - |
|
94 | - // load the supported theme wrappers |
|
95 | - add_action( 'sensei_before_main_content', array( $supported_theme, 'wrapper_start' ), 10 ); |
|
96 | - add_action( 'sensei_after_main_content', array( $supported_theme, 'wrapper_end' ), 10 ); |
|
97 | - } |
|
98 | - } |
|
13 | + /** |
|
14 | + * @var array |
|
15 | + * Holding a reference core supported themes |
|
16 | + */ |
|
17 | + protected $themes; |
|
18 | + |
|
19 | + /** |
|
20 | + * @var string |
|
21 | + * reference to the theme currently active on this site |
|
22 | + */ |
|
23 | + protected $active_theme; |
|
24 | + |
|
25 | + public function __construct() { |
|
26 | + |
|
27 | + $this->setup_themes(); |
|
28 | + $this->setup_currently_active_theme(); |
|
29 | + $this->possibly_load_supported_theme_wrappers(); |
|
30 | + |
|
31 | + } |
|
32 | + |
|
33 | + /** |
|
34 | + * Setup the theme slugs supported by Sensei Core |
|
35 | + * |
|
36 | + * @since 1.9.0 |
|
37 | + */ |
|
38 | + private function setup_themes(){ |
|
39 | + |
|
40 | + $this->themes = array( |
|
41 | + 'twentyeleven', |
|
42 | + 'twentytwelve', |
|
43 | + 'twentythirteen', |
|
44 | + 'twentyfourteen', |
|
45 | + 'twentyfifteen', |
|
46 | + 'twentysixteen', |
|
47 | + 'storefront', |
|
48 | + ); |
|
49 | + |
|
50 | + }// end setup themes |
|
51 | + |
|
52 | + /** |
|
53 | + * Setup the currently active theme |
|
54 | + * |
|
55 | + * @since 1.9.0 |
|
56 | + */ |
|
57 | + private function setup_currently_active_theme(){ |
|
58 | + |
|
59 | + $this->active_theme = get_option('template'); |
|
60 | + |
|
61 | + } |
|
62 | + |
|
63 | + /** |
|
64 | + * Remove default Sensei wrappers and load |
|
65 | + * supported wrappers if the current theme is |
|
66 | + * a theme we have an integration for within core. |
|
67 | + * |
|
68 | + * @since 1.9.0 |
|
69 | + */ |
|
70 | + private function possibly_load_supported_theme_wrappers(){ |
|
71 | + |
|
72 | + if ( in_array( $this->active_theme, $this->themes ) ){ |
|
73 | + |
|
74 | + // setup file and class names |
|
75 | + $supported_theme_class_file = trailingslashit( Sensei()->plugin_path ) . 'includes/theme-integrations/' . $this->active_theme . '.php'; |
|
76 | + $supported_theme_class_name = 'Sensei_'. ucfirst( $this->active_theme ); |
|
77 | + |
|
78 | + // load the file or exit if there is no file for this theme |
|
79 | + if( ! file_exists( $supported_theme_class_file ) ){ |
|
80 | + return; |
|
81 | + } |
|
82 | + include_once( $supported_theme_class_file ); |
|
83 | + include_once( 'twentytwelve.php' ); |
|
84 | + //initialize the class or exit if there is no class for this theme |
|
85 | + if( ! class_exists( $supported_theme_class_name ) ){ |
|
86 | + return; |
|
87 | + } |
|
88 | + $supported_theme = new $supported_theme_class_name; |
|
89 | + |
|
90 | + // remove default wrappers |
|
91 | + remove_action( 'sensei_before_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper' ), 10 ); |
|
92 | + remove_action( 'sensei_after_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper_end' ), 10 ); |
|
93 | + |
|
94 | + // load the supported theme wrappers |
|
95 | + add_action( 'sensei_before_main_content', array( $supported_theme, 'wrapper_start' ), 10 ); |
|
96 | + add_action( 'sensei_after_main_content', array( $supported_theme, 'wrapper_end' ), 10 ); |
|
97 | + } |
|
98 | + } |
|
99 | 99 | |
100 | 100 | } /// end class |
101 | 101 | \ No newline at end of file |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | * |
36 | 36 | * @since 1.9.0 |
37 | 37 | */ |
38 | - private function setup_themes(){ |
|
38 | + private function setup_themes() { |
|
39 | 39 | |
40 | 40 | $this->themes = array( |
41 | 41 | 'twentyeleven', |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * |
55 | 55 | * @since 1.9.0 |
56 | 56 | */ |
57 | - private function setup_currently_active_theme(){ |
|
57 | + private function setup_currently_active_theme() { |
|
58 | 58 | |
59 | 59 | $this->active_theme = get_option('template'); |
60 | 60 | |
@@ -67,33 +67,33 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @since 1.9.0 |
69 | 69 | */ |
70 | - private function possibly_load_supported_theme_wrappers(){ |
|
70 | + private function possibly_load_supported_theme_wrappers() { |
|
71 | 71 | |
72 | - if ( in_array( $this->active_theme, $this->themes ) ){ |
|
72 | + if (in_array($this->active_theme, $this->themes)) { |
|
73 | 73 | |
74 | 74 | // setup file and class names |
75 | - $supported_theme_class_file = trailingslashit( Sensei()->plugin_path ) . 'includes/theme-integrations/' . $this->active_theme . '.php'; |
|
76 | - $supported_theme_class_name = 'Sensei_'. ucfirst( $this->active_theme ); |
|
75 | + $supported_theme_class_file = trailingslashit(Sensei()->plugin_path).'includes/theme-integrations/'.$this->active_theme.'.php'; |
|
76 | + $supported_theme_class_name = 'Sensei_'.ucfirst($this->active_theme); |
|
77 | 77 | |
78 | 78 | // load the file or exit if there is no file for this theme |
79 | - if( ! file_exists( $supported_theme_class_file ) ){ |
|
79 | + if ( ! file_exists($supported_theme_class_file)) { |
|
80 | 80 | return; |
81 | 81 | } |
82 | - include_once( $supported_theme_class_file ); |
|
83 | - include_once( 'twentytwelve.php' ); |
|
82 | + include_once($supported_theme_class_file); |
|
83 | + include_once('twentytwelve.php'); |
|
84 | 84 | //initialize the class or exit if there is no class for this theme |
85 | - if( ! class_exists( $supported_theme_class_name ) ){ |
|
85 | + if ( ! class_exists($supported_theme_class_name)) { |
|
86 | 86 | return; |
87 | 87 | } |
88 | 88 | $supported_theme = new $supported_theme_class_name; |
89 | 89 | |
90 | 90 | // remove default wrappers |
91 | - remove_action( 'sensei_before_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper' ), 10 ); |
|
92 | - remove_action( 'sensei_after_main_content', array( Sensei()->frontend, 'sensei_output_content_wrapper_end' ), 10 ); |
|
91 | + remove_action('sensei_before_main_content', array(Sensei()->frontend, 'sensei_output_content_wrapper'), 10); |
|
92 | + remove_action('sensei_after_main_content', array(Sensei()->frontend, 'sensei_output_content_wrapper_end'), 10); |
|
93 | 93 | |
94 | 94 | // load the supported theme wrappers |
95 | - add_action( 'sensei_before_main_content', array( $supported_theme, 'wrapper_start' ), 10 ); |
|
96 | - add_action( 'sensei_after_main_content', array( $supported_theme, 'wrapper_end' ), 10 ); |
|
95 | + add_action('sensei_before_main_content', array($supported_theme, 'wrapper_start'), 10); |
|
96 | + add_action('sensei_after_main_content', array($supported_theme, 'wrapper_end'), 10); |
|
97 | 97 | } |
98 | 98 | } |
99 | 99 |
@@ -9,12 +9,12 @@ discard block |
||
9 | 9 | */ |
10 | 10 | Class Sensei_Twentyfourteen { |
11 | 11 | |
12 | - /** |
|
13 | - * Output opening wrappers |
|
14 | - * @since 1.9.0 |
|
15 | - */ |
|
16 | - public function wrapper_start(){ |
|
17 | - ?> |
|
12 | + /** |
|
13 | + * Output opening wrappers |
|
14 | + * @since 1.9.0 |
|
15 | + */ |
|
16 | + public function wrapper_start(){ |
|
17 | + ?> |
|
18 | 18 | |
19 | 19 | <div id="main-content" class="main-content"> |
20 | 20 | <div id="primary" class="content-area"> |
@@ -23,12 +23,12 @@ discard block |
||
23 | 23 | |
24 | 24 | <?php } |
25 | 25 | |
26 | - /** |
|
27 | - * Output closing wrappers |
|
28 | - * |
|
29 | - * @since 1.9.0 |
|
30 | - */ |
|
31 | - public function wrapper_end(){ ?> |
|
26 | + /** |
|
27 | + * Output closing wrappers |
|
28 | + * |
|
29 | + * @since 1.9.0 |
|
30 | + */ |
|
31 | + public function wrapper_end(){ ?> |
|
32 | 32 | |
33 | 33 | |
34 | 34 | </div> |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | </div> |
38 | 38 | |
39 | 39 | <?php |
40 | - get_sidebar(); |
|
40 | + get_sidebar(); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | } |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * Output opening wrappers |
14 | 14 | * @since 1.9.0 |
15 | 15 | */ |
16 | - public function wrapper_start(){ |
|
16 | + public function wrapper_start() { |
|
17 | 17 | ?> |
18 | 18 | |
19 | 19 | <div id="primary" class="site-content"> |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | * |
27 | 27 | * @since 1.9.0 |
28 | 28 | */ |
29 | - public function wrapper_end(){ ?> |
|
29 | + public function wrapper_end() { ?> |
|
30 | 30 | |
31 | 31 | </div> |
32 | 32 | </div> |
@@ -9,28 +9,28 @@ |
||
9 | 9 | */ |
10 | 10 | Class Sensei_Twentyfifteen extends Sensei__S { |
11 | 11 | |
12 | - /** |
|
13 | - * Output opening wrappers |
|
14 | - * @since 1.9.0 |
|
15 | - */ |
|
16 | - public function wrapper_start(){ |
|
12 | + /** |
|
13 | + * Output opening wrappers |
|
14 | + * @since 1.9.0 |
|
15 | + */ |
|
16 | + public function wrapper_start(){ |
|
17 | 17 | |
18 | - // output inline styles |
|
19 | - $this->print_styles(); |
|
18 | + // output inline styles |
|
19 | + $this->print_styles(); |
|
20 | 20 | |
21 | - // call the parent starting wrappers |
|
22 | - parent::wrapper_start(); |
|
21 | + // call the parent starting wrappers |
|
22 | + parent::wrapper_start(); |
|
23 | 23 | |
24 | - } |
|
24 | + } |
|
25 | 25 | |
26 | 26 | |
27 | - /** |
|
28 | - * Output the style for the |
|
29 | - * twenty fifteen theme integration. |
|
30 | - * |
|
31 | - * @since 1.9.0 |
|
32 | - */ |
|
33 | - private function print_styles(){?> |
|
27 | + /** |
|
28 | + * Output the style for the |
|
29 | + * twenty fifteen theme integration. |
|
30 | + * |
|
31 | + * @since 1.9.0 |
|
32 | + */ |
|
33 | + private function print_styles(){?> |
|
34 | 34 | |
35 | 35 | <style> |
36 | 36 | @media screen and (min-width: 59.6875em){ |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * Output opening wrappers |
14 | 14 | * @since 1.9.0 |
15 | 15 | */ |
16 | - public function wrapper_start(){ |
|
16 | + public function wrapper_start() { |
|
17 | 17 | |
18 | 18 | // output inline styles |
19 | 19 | $this->print_styles(); |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @since 1.9.0 |
32 | 32 | */ |
33 | - private function print_styles(){?> |
|
33 | + private function print_styles() {?> |
|
34 | 34 | |
35 | 35 | <style> |
36 | 36 | @media screen and (min-width: 59.6875em){ |
@@ -9,29 +9,29 @@ |
||
9 | 9 | */ |
10 | 10 | Class Sensei__S { |
11 | 11 | |
12 | - /** |
|
13 | - * Output opening wrappers |
|
14 | - * @since 1.9.0 |
|
15 | - */ |
|
16 | - public function wrapper_start(){ ?> |
|
12 | + /** |
|
13 | + * Output opening wrappers |
|
14 | + * @since 1.9.0 |
|
15 | + */ |
|
16 | + public function wrapper_start(){ ?> |
|
17 | 17 | <div id="primary" class="content-area"> |
18 | 18 | <main id="main" class="site-main" role="main"> |
19 | 19 | |
20 | 20 | <?php } |
21 | 21 | |
22 | - /** |
|
23 | - * Output closing wrappers |
|
24 | - * |
|
25 | - * @since 1.9.0 |
|
26 | - */ |
|
27 | - public function wrapper_end(){ ?> |
|
22 | + /** |
|
23 | + * Output closing wrappers |
|
24 | + * |
|
25 | + * @since 1.9.0 |
|
26 | + */ |
|
27 | + public function wrapper_end(){ ?> |
|
28 | 28 | |
29 | 29 | </main> <!-- main-site --> |
30 | 30 | </div> <!-- content-area --> |
31 | 31 | |
32 | 32 | <?php |
33 | 33 | |
34 | - get_sidebar(); |
|
34 | + get_sidebar(); |
|
35 | 35 | |
36 | - } |
|
36 | + } |
|
37 | 37 | } // end class |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | * Output opening wrappers |
14 | 14 | * @since 1.9.0 |
15 | 15 | */ |
16 | - public function wrapper_start(){ ?> |
|
16 | + public function wrapper_start() { ?> |
|
17 | 17 | <div id="primary" class="content-area"> |
18 | 18 | <main id="main" class="site-main" role="main"> |
19 | 19 | |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @since 1.9.0 |
26 | 26 | */ |
27 | - public function wrapper_end(){ ?> |
|
27 | + public function wrapper_end() { ?> |
|
28 | 28 | |
29 | 29 | </main> <!-- main-site --> |
30 | 30 | </div> <!-- content-area --> |