@@ -26,8 +26,8 @@ discard block |
||
26 | 26 | |
27 | 27 | /** |
28 | 28 | * Check if WooCommerce is present. |
29 | - * |
|
30 | - * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_present() |
|
29 | + * |
|
30 | + * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_present() |
|
31 | 31 | * @access public |
32 | 32 | * @since 1.0.2 |
33 | 33 | * @static |
@@ -35,14 +35,14 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public static function sensei_is_woocommerce_present () { |
37 | 37 | |
38 | - return Sensei_WC::is_woocommerce_present(); |
|
38 | + return Sensei_WC::is_woocommerce_present(); |
|
39 | 39 | |
40 | 40 | } // End sensei_is_woocommerce_present() |
41 | 41 | |
42 | 42 | /** |
43 | 43 | * Check if WooCommerce is active. |
44 | - * |
|
45 | - * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active |
|
44 | + * |
|
45 | + * @deprecated since 1.9.0 use Sensei_WC::is_woocommerce_active |
|
46 | 46 | * @access public |
47 | 47 | * @since 1.0.2 |
48 | 48 | * @static |
@@ -187,15 +187,15 @@ discard block |
||
187 | 187 | add_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) ); |
188 | 188 | } |
189 | 189 | |
190 | - //Get the comments |
|
191 | - /** |
|
192 | - * This filter runs inside Sensei_Utils::sensei_check_for_activity |
|
193 | - * |
|
194 | - * It runs while getting the comments for the given request. |
|
195 | - * |
|
196 | - * @param int|array $comments |
|
197 | - */ |
|
198 | - $comments = apply_filters('sensei_check_for_activity', get_comments( $args ) ); |
|
190 | + //Get the comments |
|
191 | + /** |
|
192 | + * This filter runs inside Sensei_Utils::sensei_check_for_activity |
|
193 | + * |
|
194 | + * It runs while getting the comments for the given request. |
|
195 | + * |
|
196 | + * @param int|array $comments |
|
197 | + */ |
|
198 | + $comments = apply_filters('sensei_check_for_activity', get_comments( $args ) ); |
|
199 | 199 | |
200 | 200 | remove_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) ); |
201 | 201 | remove_filter( 'comments_clauses', array( __CLASS__, 'comment_any_status_filter' ) ); |
@@ -280,18 +280,18 @@ discard block |
||
280 | 280 | return $dataset_changes; |
281 | 281 | } // End sensei_delete_activities() |
282 | 282 | |
283 | - /** |
|
284 | - * Delete all activity for specified user |
|
285 | - * @access public |
|
283 | + /** |
|
284 | + * Delete all activity for specified user |
|
285 | + * @access public |
|
286 | 286 | * @since 1.5.0 |
287 | - * @param integer $user_id User ID |
|
288 | - * @return boolean |
|
289 | - */ |
|
290 | - public static function delete_all_user_activity( $user_id = 0 ) { |
|
287 | + * @param integer $user_id User ID |
|
288 | + * @return boolean |
|
289 | + */ |
|
290 | + public static function delete_all_user_activity( $user_id = 0 ) { |
|
291 | 291 | |
292 | - $dataset_changes = false; |
|
292 | + $dataset_changes = false; |
|
293 | 293 | |
294 | - if( $user_id ) { |
|
294 | + if( $user_id ) { |
|
295 | 295 | |
296 | 296 | $activities = Sensei_Utils::sensei_check_for_activity( array( 'user_id' => $user_id ), true ); |
297 | 297 | |
@@ -336,35 +336,35 @@ discard block |
||
336 | 336 | return $activity_value; |
337 | 337 | } // End sensei_get_activity_value() |
338 | 338 | |
339 | - /** |
|
340 | - * Checks if a user (by email) has bought an item. |
|
341 | - * |
|
342 | - * @deprecated since 1.9.0 use Sensei_WC::has_customer_bought_product($user_id, $product_id) |
|
343 | - * @access public |
|
344 | - * @since 1.0.0 |
|
345 | - * @param string $customer_email |
|
346 | - * @param int $user_id |
|
347 | - * @param int $product_id |
|
348 | - * @return bool |
|
349 | - */ |
|
350 | - public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) { |
|
339 | + /** |
|
340 | + * Checks if a user (by email) has bought an item. |
|
341 | + * |
|
342 | + * @deprecated since 1.9.0 use Sensei_WC::has_customer_bought_product($user_id, $product_id) |
|
343 | + * @access public |
|
344 | + * @since 1.0.0 |
|
345 | + * @param string $customer_email |
|
346 | + * @param int $user_id |
|
347 | + * @param int $product_id |
|
348 | + * @return bool |
|
349 | + */ |
|
350 | + public static function sensei_customer_bought_product ( $customer_email, $user_id, $product_id ) { |
|
351 | 351 | |
352 | - $emails = array(); |
|
352 | + $emails = array(); |
|
353 | 353 | |
354 | - if ( $user_id ) { |
|
355 | - $user = get_user_by( 'id', intval( $user_id ) ); |
|
356 | - $emails[] = $user->user_email; |
|
357 | - } |
|
354 | + if ( $user_id ) { |
|
355 | + $user = get_user_by( 'id', intval( $user_id ) ); |
|
356 | + $emails[] = $user->user_email; |
|
357 | + } |
|
358 | 358 | |
359 | - if ( is_email( $customer_email ) ) |
|
360 | - $emails[] = $customer_email; |
|
359 | + if ( is_email( $customer_email ) ) |
|
360 | + $emails[] = $customer_email; |
|
361 | 361 | |
362 | - if ( sizeof( $emails ) == 0 ) |
|
363 | - return false; |
|
362 | + if ( sizeof( $emails ) == 0 ) |
|
363 | + return false; |
|
364 | 364 | |
365 | - return Sensei_WC::has_customer_bought_product( $user_id, $product_id ); |
|
365 | + return Sensei_WC::has_customer_bought_product( $user_id, $product_id ); |
|
366 | 366 | |
367 | - } // End sensei_customer_bought_product() |
|
367 | + } // End sensei_customer_bought_product() |
|
368 | 368 | |
369 | 369 | /** |
370 | 370 | * Load the WordPress rich text editor |
@@ -400,7 +400,7 @@ discard block |
||
400 | 400 | /** |
401 | 401 | * Save quiz answers submitted by users |
402 | 402 | * @param array $submitted User's quiz answers |
403 | - * @param int $user_id |
|
403 | + * @param int $user_id |
|
404 | 404 | * @return boolean Whether the answers were saved or not |
405 | 405 | */ |
406 | 406 | public static function sensei_save_quiz_answers( $submitted = array(), $user_id = 0 ) { |
@@ -468,72 +468,72 @@ discard block |
||
468 | 468 | |
469 | 469 | require_once( ABSPATH . 'wp-admin/includes/admin.php' ); |
470 | 470 | |
471 | - /** |
|
472 | - * Filter the data array for the Sensei wp_handle_upload function call |
|
473 | - * |
|
474 | - * This filter was mainly added for Unit Testing purposes. |
|
475 | - * |
|
476 | - * @since 1.7.4 |
|
477 | - * |
|
478 | - * @param array $file_upload_args { |
|
479 | - * array of current values |
|
480 | - * |
|
481 | - * @type string test_form set to false by default |
|
482 | - * } |
|
483 | - */ |
|
484 | - $file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) ); |
|
485 | - |
|
486 | - $file_return = wp_handle_upload( $file, $file_upload_args ); |
|
487 | - |
|
488 | - if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) { |
|
489 | - return false; |
|
490 | - } else { |
|
471 | + /** |
|
472 | + * Filter the data array for the Sensei wp_handle_upload function call |
|
473 | + * |
|
474 | + * This filter was mainly added for Unit Testing purposes. |
|
475 | + * |
|
476 | + * @since 1.7.4 |
|
477 | + * |
|
478 | + * @param array $file_upload_args { |
|
479 | + * array of current values |
|
480 | + * |
|
481 | + * @type string test_form set to false by default |
|
482 | + * } |
|
483 | + */ |
|
484 | + $file_upload_args = apply_filters( 'sensei_file_upload_args', array('test_form' => false ) ); |
|
485 | + |
|
486 | + $file_return = wp_handle_upload( $file, $file_upload_args ); |
|
487 | + |
|
488 | + if( isset( $file_return['error'] ) || isset( $file_return['upload_error_handler'] ) ) { |
|
489 | + return false; |
|
490 | + } else { |
|
491 | 491 | |
492 | - $filename = $file_return['file']; |
|
492 | + $filename = $file_return['file']; |
|
493 | 493 | |
494 | - $attachment = array( |
|
495 | - 'post_mime_type' => $file_return['type'], |
|
496 | - 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ), |
|
497 | - 'post_content' => '', |
|
498 | - 'post_status' => 'inherit', |
|
499 | - 'guid' => $file_return['url'] |
|
500 | - ); |
|
494 | + $attachment = array( |
|
495 | + 'post_mime_type' => $file_return['type'], |
|
496 | + 'post_title' => preg_replace( '/\.[^.]+$/', '', basename( $filename ) ), |
|
497 | + 'post_content' => '', |
|
498 | + 'post_status' => 'inherit', |
|
499 | + 'guid' => $file_return['url'] |
|
500 | + ); |
|
501 | 501 | |
502 | - $attachment_id = wp_insert_attachment( $attachment, $filename ); |
|
502 | + $attachment_id = wp_insert_attachment( $attachment, $filename ); |
|
503 | 503 | |
504 | - require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
505 | - $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
506 | - wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
504 | + require_once(ABSPATH . 'wp-admin/includes/image.php'); |
|
505 | + $attachment_data = wp_generate_attachment_metadata( $attachment_id, $filename ); |
|
506 | + wp_update_attachment_metadata( $attachment_id, $attachment_data ); |
|
507 | 507 | |
508 | - if( 0 < intval( $attachment_id ) ) { |
|
509 | - return $attachment_id; |
|
510 | - } |
|
511 | - } |
|
508 | + if( 0 < intval( $attachment_id ) ) { |
|
509 | + return $attachment_id; |
|
510 | + } |
|
511 | + } |
|
512 | 512 | |
513 | - return false; |
|
513 | + return false; |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
517 | 517 | * Grade quiz automatically |
518 | - * |
|
519 | - * This function grades each question automatically if the are auto gradable. |
|
520 | - * It store all question grades. |
|
521 | - * |
|
522 | - * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_quiz_auto instead |
|
523 | - * |
|
518 | + * |
|
519 | + * This function grades each question automatically if the are auto gradable. |
|
520 | + * It store all question grades. |
|
521 | + * |
|
522 | + * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_quiz_auto instead |
|
523 | + * |
|
524 | 524 | * @param integer $quiz_id ID of quiz |
525 | 525 | * @param array $submitted questions id ans answers { |
526 | - * @type int $question_id |
|
527 | - * @type mixed $answer |
|
528 | - * } |
|
526 | + * @type int $question_id |
|
527 | + * @type mixed $answer |
|
528 | + * } |
|
529 | 529 | * @param integer $total_questions Total questions in quiz (not used) |
530 | - * @param string $quiz_grade_type Optional defaults to auto |
|
531 | - * |
|
530 | + * @param string $quiz_grade_type Optional defaults to auto |
|
531 | + * |
|
532 | 532 | * @return int $quiz_grade total sum of all question grades |
533 | 533 | */ |
534 | 534 | public static function sensei_grade_quiz_auto( $quiz_id = 0, $submitted = array(), $total_questions = 0, $quiz_grade_type = 'auto' ) { |
535 | 535 | |
536 | - return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type ); |
|
536 | + return Sensei_Grading::grade_quiz_auto( $quiz_id, $submitted, $total_questions, $quiz_grade_type ); |
|
537 | 537 | |
538 | 538 | } // End sensei_grade_quiz_auto() |
539 | 539 | |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | * @param integer $quiz_id ID of quiz |
543 | 543 | * @param integer $grade Grade received |
544 | 544 | * @param integer $user_id ID of user being graded |
545 | - * @param string $quiz_grade_type default 'auto' |
|
545 | + * @param string $quiz_grade_type default 'auto' |
|
546 | 546 | * @return boolean |
547 | 547 | */ |
548 | 548 | public static function sensei_grade_quiz( $quiz_id = 0, $grade = 0, $user_id = 0, $quiz_grade_type = 'auto' ) { |
@@ -566,21 +566,21 @@ discard block |
||
566 | 566 | |
567 | 567 | /** |
568 | 568 | * Grade question automatically |
569 | - * |
|
570 | - * This function checks the question typ and then grades it accordingly. |
|
571 | - * |
|
572 | - * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_question_auto instead |
|
573 | - * |
|
569 | + * |
|
570 | + * This function checks the question typ and then grades it accordingly. |
|
571 | + * |
|
572 | + * @deprecated since 1.7.4 use WooThemes_Sensei_Grading::grade_question_auto instead |
|
573 | + * |
|
574 | 574 | * @param integer $question_id |
575 | - * @param string $question_type of the standard Sensei question types |
|
575 | + * @param string $question_type of the standard Sensei question types |
|
576 | 576 | * @param string $answer |
577 | - * @param int $user_id |
|
578 | - * |
|
577 | + * @param int $user_id |
|
578 | + * |
|
579 | 579 | * @return int $question_grade |
580 | 580 | */ |
581 | 581 | public static function sensei_grade_question_auto( $question_id = 0, $question_type = '', $answer = '', $user_id = 0 ) { |
582 | 582 | |
583 | - return WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id ); |
|
583 | + return WooThemes_Sensei_Grading::grade_question_auto( $question_id, $question_type, $answer, $user_id ); |
|
584 | 584 | |
585 | 585 | } // end sensei_grade_question_auto |
586 | 586 | |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | * Grade question |
589 | 589 | * @param integer $question_id ID of question |
590 | 590 | * @param integer $grade Grade received |
591 | - * @param int $user_id |
|
591 | + * @param int $user_id |
|
592 | 592 | * @return boolean |
593 | 593 | */ |
594 | 594 | public static function sensei_grade_question( $question_id = 0, $grade = 0, $user_id = 0 ) { |
@@ -627,35 +627,35 @@ discard block |
||
627 | 627 | } |
628 | 628 | |
629 | 629 | |
630 | - /** |
|
631 | - * Alias to Woothemes_Sensei_Utils::sensei_start_lesson |
|
632 | - * |
|
633 | - * @since 1.7.4 |
|
634 | - * |
|
635 | - * @param integer $user_id |
|
636 | - * @param integer $lesson_id |
|
637 | - * @param bool $complete |
|
638 | - * |
|
639 | - * @return mixed boolean or comment_ID |
|
640 | - */ |
|
641 | - public static function user_start_lesson( $user_id = 0, $lesson_id = 0, $complete = false ) { |
|
630 | + /** |
|
631 | + * Alias to Woothemes_Sensei_Utils::sensei_start_lesson |
|
632 | + * |
|
633 | + * @since 1.7.4 |
|
634 | + * |
|
635 | + * @param integer $user_id |
|
636 | + * @param integer $lesson_id |
|
637 | + * @param bool $complete |
|
638 | + * |
|
639 | + * @return mixed boolean or comment_ID |
|
640 | + */ |
|
641 | + public static function user_start_lesson( $user_id = 0, $lesson_id = 0, $complete = false ) { |
|
642 | 642 | |
643 | - return self::sensei_start_lesson( $lesson_id, $user_id, $complete ); |
|
643 | + return self::sensei_start_lesson( $lesson_id, $user_id, $complete ); |
|
644 | 644 | |
645 | - }// end user_start_lesson() |
|
645 | + }// end user_start_lesson() |
|
646 | 646 | |
647 | 647 | /** |
648 | 648 | * Mark a lesson as started for user |
649 | - * |
|
650 | - * Will also start the lesson course for the user if the user hans't started taking it already. |
|
651 | - * |
|
652 | - * @since 1.6.0 |
|
653 | - * |
|
649 | + * |
|
650 | + * Will also start the lesson course for the user if the user hans't started taking it already. |
|
651 | + * |
|
652 | + * @since 1.6.0 |
|
653 | + * |
|
654 | 654 | * @param integer $lesson_id ID of lesson |
655 | 655 | * @param int| string $user_id default 0 |
656 | - * @param bool $complete default false |
|
657 | - * |
|
658 | - * @return mixed boolean or comment_ID |
|
656 | + * @param bool $complete default false |
|
657 | + * |
|
658 | + * @return mixed boolean or comment_ID |
|
659 | 659 | */ |
660 | 660 | public static function sensei_start_lesson( $lesson_id = 0, $user_id = 0, $complete = false ) { |
661 | 661 | |
@@ -701,21 +701,21 @@ discard block |
||
701 | 701 | $metadata['start'] = current_time('mysql'); |
702 | 702 | $activity_logged = Sensei_Utils::update_lesson_status( $user_id, $lesson_id, $status, $metadata ); |
703 | 703 | |
704 | - } else { |
|
704 | + } else { |
|
705 | 705 | |
706 | - // if users is already taking the lesson and the status changes to complete update it |
|
707 | - $current_user_activity = get_comment($activity_logged); |
|
708 | - if( $status=='complete' && |
|
709 | - $status != $current_user_activity->comment_approved ){ |
|
706 | + // if users is already taking the lesson and the status changes to complete update it |
|
707 | + $current_user_activity = get_comment($activity_logged); |
|
708 | + if( $status=='complete' && |
|
709 | + $status != $current_user_activity->comment_approved ){ |
|
710 | 710 | |
711 | - $comment = array(); |
|
712 | - $comment['comment_ID'] = $activity_logged; |
|
713 | - $comment['comment_approved'] = $status; |
|
714 | - wp_update_comment( $comment ); |
|
711 | + $comment = array(); |
|
712 | + $comment['comment_ID'] = $activity_logged; |
|
713 | + $comment['comment_approved'] = $status; |
|
714 | + wp_update_comment( $comment ); |
|
715 | 715 | |
716 | - } |
|
716 | + } |
|
717 | 717 | |
718 | - } |
|
718 | + } |
|
719 | 719 | |
720 | 720 | if ( $complete ) { |
721 | 721 | // Run this *after* the lesson status has been created/updated |
@@ -861,7 +861,7 @@ discard block |
||
861 | 861 | /** |
862 | 862 | * Returns the answer_notes for a specific question and user, or sensei_user_answer entry |
863 | 863 | * |
864 | - * @deprecated since 1.7.5 use Sensei()->quiz->get_user_question_feedback instead |
|
864 | + * @deprecated since 1.7.5 use Sensei()->quiz->get_user_question_feedback instead |
|
865 | 865 | * @param mixed $question |
866 | 866 | * @param int $user_id |
867 | 867 | * @return string |
@@ -921,7 +921,7 @@ discard block |
||
921 | 921 | * Add answer notes to question |
922 | 922 | * @param integer $question_id ID of question |
923 | 923 | * @param integer $user_id ID of user |
924 | - * @param string $notes |
|
924 | + * @param string $notes |
|
925 | 925 | * @return boolean |
926 | 926 | */ |
927 | 927 | public static function sensei_add_answer_notes( $question_id = 0, $user_id = 0, $notes = '' ) { |
@@ -979,17 +979,17 @@ discard block |
||
979 | 979 | * @return void |
980 | 980 | */ |
981 | 981 | public static function sort_array_by_key( $array, $key ) { |
982 | - $sorter = array(); |
|
983 | - $ret = array(); |
|
984 | - reset( $array ); |
|
985 | - foreach ( $array as $ii => $va ) { |
|
986 | - $sorter[$ii] = $va[$key]; |
|
987 | - } // End For Loop |
|
988 | - asort( $sorter ); |
|
989 | - foreach ( $sorter as $ii => $va ) { |
|
990 | - $ret[$ii] = $array[$ii]; |
|
991 | - } // End For Loop |
|
992 | - $array = $ret; |
|
982 | + $sorter = array(); |
|
983 | + $ret = array(); |
|
984 | + reset( $array ); |
|
985 | + foreach ( $array as $ii => $va ) { |
|
986 | + $sorter[$ii] = $va[$key]; |
|
987 | + } // End For Loop |
|
988 | + asort( $sorter ); |
|
989 | + foreach ( $sorter as $ii => $va ) { |
|
990 | + $ret[$ii] = $array[$ii]; |
|
991 | + } // End For Loop |
|
992 | + $array = $ret; |
|
993 | 993 | } // End sort_array_by_key() |
994 | 994 | |
995 | 995 | /** |
@@ -1002,21 +1002,21 @@ discard block |
||
1002 | 1002 | $questions_array = array(); |
1003 | 1003 | if ( 0 < $quiz_id ) { |
1004 | 1004 | $question_args = array( 'post_type' => 'question', |
1005 | - 'posts_per_page' => -1, |
|
1006 | - 'orderby' => 'ID', |
|
1007 | - 'order' => 'ASC', |
|
1008 | - 'meta_query' => array( |
|
1005 | + 'posts_per_page' => -1, |
|
1006 | + 'orderby' => 'ID', |
|
1007 | + 'order' => 'ASC', |
|
1008 | + 'meta_query' => array( |
|
1009 | 1009 | array( |
1010 | 1010 | 'key' => '_quiz_id', |
1011 | 1011 | 'value' => $quiz_id, |
1012 | 1012 | ) |
1013 | 1013 | ), |
1014 | - 'post_status' => 'any', |
|
1015 | - 'suppress_filters' => 0 |
|
1016 | - ); |
|
1017 | - $questions_array = get_posts( $question_args ); |
|
1018 | - } // End If Statement |
|
1019 | - return $questions_array; |
|
1014 | + 'post_status' => 'any', |
|
1015 | + 'suppress_filters' => 0 |
|
1016 | + ); |
|
1017 | + $questions_array = get_posts( $question_args ); |
|
1018 | + } // End If Statement |
|
1019 | + return $questions_array; |
|
1020 | 1020 | } // End lesson_quiz_questions() |
1021 | 1021 | |
1022 | 1022 | /** |
@@ -1174,7 +1174,7 @@ discard block |
||
1174 | 1174 | * Set the status message displayed to the user for a quiz |
1175 | 1175 | * @param integer $lesson_id ID of quiz lesson |
1176 | 1176 | * @param integer $user_id ID of user |
1177 | - * @param bool $is_lesson |
|
1177 | + * @param bool $is_lesson |
|
1178 | 1178 | * @return array Status code and message |
1179 | 1179 | */ |
1180 | 1180 | public static function sensei_user_quiz_status_message( $lesson_id = 0, $user_id = 0, $is_lesson = false ) { |
@@ -1257,20 +1257,20 @@ discard block |
||
1257 | 1257 | } |
1258 | 1258 | } |
1259 | 1259 | |
1260 | - // add next lesson button |
|
1261 | - $nav_id_array = sensei_get_prev_next_lessons( $lesson_id ); |
|
1262 | - $next_lesson_id = absint( $nav_id_array['next_lesson'] ); |
|
1260 | + // add next lesson button |
|
1261 | + $nav_id_array = sensei_get_prev_next_lessons( $lesson_id ); |
|
1262 | + $next_lesson_id = absint( $nav_id_array['next_lesson'] ); |
|
1263 | 1263 | |
1264 | - // Output HTML |
|
1265 | - if ( ( 0 < $next_lesson_id ) ) { |
|
1266 | - $message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) ) |
|
1267 | - . '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei') |
|
1268 | - .'</a>'; |
|
1264 | + // Output HTML |
|
1265 | + if ( ( 0 < $next_lesson_id ) ) { |
|
1266 | + $message .= ' ' . '<a class="next-lesson" href="' . esc_url( get_permalink( $next_lesson_id ) ) |
|
1267 | + . '" rel="next"><span class="meta-nav"></span>'. __( 'Next Lesson' ,'woothemes-sensei') |
|
1268 | + .'</a>'; |
|
1269 | 1269 | |
1270 | - } |
|
1270 | + } |
|
1271 | 1271 | |
1272 | 1272 | } |
1273 | - // Lesson/Quiz not complete |
|
1273 | + // Lesson/Quiz not complete |
|
1274 | 1274 | else { |
1275 | 1275 | // Lesson/Quiz isn't "complete" instead it's ungraded (previously this "state" meant that it *was* complete) |
1276 | 1276 | if ( isset( $user_lesson_status->comment_approved ) && 'ungraded' == $user_lesson_status->comment_approved ) { |
@@ -1310,7 +1310,7 @@ discard block |
||
1310 | 1310 | $message = apply_filters( 'sensei_user_quiz_status_' . $status, $message ); |
1311 | 1311 | |
1312 | 1312 | if( $is_lesson && ! in_array( $status, array( 'login_required', 'not_started_course' ) ) ) { |
1313 | - $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
1313 | + $quiz_id = Sensei()->lesson->lesson_quizzes( $lesson_id ); |
|
1314 | 1314 | $extra = '<p><a class="button" href="' . esc_url( get_permalink( $quiz_id ) ) . '" title="' . __( 'View the lesson quiz', 'woothemes-sensei' ) . '">' . __( 'View the lesson quiz', 'woothemes-sensei' ) . '</a></p>'; |
1315 | 1315 | } |
1316 | 1316 | |
@@ -1368,9 +1368,9 @@ discard block |
||
1368 | 1368 | $user_id = get_current_user_id(); |
1369 | 1369 | } |
1370 | 1370 | |
1371 | - if( ! $user_id > 0 ){ |
|
1372 | - return false; |
|
1373 | - } |
|
1371 | + if( ! $user_id > 0 ){ |
|
1372 | + return false; |
|
1373 | + } |
|
1374 | 1374 | |
1375 | 1375 | $user_course_status_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $course_id, 'user_id' => $user_id, 'type' => 'sensei_course_status', 'field' => 'comment_ID' ) ); |
1376 | 1376 | if( $user_course_status_id ) { |
@@ -1494,7 +1494,7 @@ discard block |
||
1494 | 1494 | * Check if a user has completed a course or not |
1495 | 1495 | * |
1496 | 1496 | * @param int | WP_Post | WP_Comment $course course_id or sensei_course_status entry |
1497 | - * |
|
1497 | + * |
|
1498 | 1498 | * @param int $user_id |
1499 | 1499 | * @return boolean |
1500 | 1500 | */ |
@@ -1512,14 +1512,14 @@ discard block |
||
1512 | 1512 | $user_id = get_current_user_id(); |
1513 | 1513 | } |
1514 | 1514 | |
1515 | - if( is_a( $course, 'WP_Post' ) ){ |
|
1516 | - $course = $course->ID; |
|
1517 | - } |
|
1515 | + if( is_a( $course, 'WP_Post' ) ){ |
|
1516 | + $course = $course->ID; |
|
1517 | + } |
|
1518 | 1518 | |
1519 | 1519 | $user_course_status = Sensei_Utils::user_course_status( $course , $user_id ); |
1520 | 1520 | if( isset( $user_course_status->comment_approved ) ){ |
1521 | - $user_course_status = $user_course_status->comment_approved; |
|
1522 | - } |
|
1521 | + $user_course_status = $user_course_status->comment_approved; |
|
1522 | + } |
|
1523 | 1523 | |
1524 | 1524 | } |
1525 | 1525 | if( $user_course_status && 'complete' == $user_course_status ) { |
@@ -1544,11 +1544,11 @@ discard block |
||
1544 | 1544 | $user_id = get_current_user_id(); |
1545 | 1545 | } |
1546 | 1546 | |
1547 | - $activity_args = array( |
|
1548 | - 'post_id' => $lesson_id, |
|
1549 | - 'user_id' => $user_id, |
|
1550 | - 'type' => 'sensei_lesson_status', |
|
1551 | - 'field' => 'comment_ID' ); |
|
1547 | + $activity_args = array( |
|
1548 | + 'post_id' => $lesson_id, |
|
1549 | + 'user_id' => $user_id, |
|
1550 | + 'type' => 'sensei_lesson_status', |
|
1551 | + 'field' => 'comment_ID' ); |
|
1552 | 1552 | |
1553 | 1553 | $user_lesson_status_id = Sensei_Utils::sensei_get_activity_value( $activity_args ); |
1554 | 1554 | if( $user_lesson_status_id ) { |
@@ -1561,7 +1561,7 @@ discard block |
||
1561 | 1561 | /** |
1562 | 1562 | * Check if a user has completed a lesson or not |
1563 | 1563 | * |
1564 | - * @uses Sensei() |
|
1564 | + * @uses Sensei() |
|
1565 | 1565 | * @param mixed $lesson lesson_id or sensei_lesson_status entry |
1566 | 1566 | * @param int $user_id |
1567 | 1567 | * @return boolean |
@@ -1582,10 +1582,10 @@ discard block |
||
1582 | 1582 | $user_id = get_current_user_id(); |
1583 | 1583 | } |
1584 | 1584 | |
1585 | - // the user is not logged in |
|
1586 | - if( ! $user_id > 0 ){ |
|
1587 | - return false; |
|
1588 | - } |
|
1585 | + // the user is not logged in |
|
1586 | + if( ! $user_id > 0 ){ |
|
1587 | + return false; |
|
1588 | + } |
|
1589 | 1589 | $_user_lesson_status = Sensei_Utils::user_lesson_status( $lesson, $user_id ); |
1590 | 1590 | |
1591 | 1591 | if ( $_user_lesson_status ) { |
@@ -1664,9 +1664,9 @@ discard block |
||
1664 | 1664 | */ |
1665 | 1665 | public static function user_lesson_status( $lesson_id = 0, $user_id = 0 ) { |
1666 | 1666 | |
1667 | - if( ! $user_id ) { |
|
1668 | - $user_id = get_current_user_id(); |
|
1669 | - } |
|
1667 | + if( ! $user_id ) { |
|
1668 | + $user_id = get_current_user_id(); |
|
1669 | + } |
|
1670 | 1670 | |
1671 | 1671 | if( $lesson_id > 0 && $user_id > 0 ) { |
1672 | 1672 | |
@@ -1717,12 +1717,12 @@ discard block |
||
1717 | 1717 | * Sets the status for the lesson |
1718 | 1718 | * |
1719 | 1719 | * @since 1.7.0 |
1720 | - * |
|
1720 | + * |
|
1721 | 1721 | * @param int|string $user_id |
1722 | 1722 | * @param int|string $lesson_id |
1723 | 1723 | * @param string $status |
1724 | 1724 | * @param array $metadata |
1725 | - * |
|
1725 | + * |
|
1726 | 1726 | * @return mixed false or comment_ID |
1727 | 1727 | */ |
1728 | 1728 | public static function update_lesson_status( $user_id, $lesson_id, $status = 'in-progress', $metadata = array() ) { |
@@ -1838,7 +1838,7 @@ discard block |
||
1838 | 1838 | /** |
1839 | 1839 | * Adjust the comment query to be faster on the database, used by Analysis admin |
1840 | 1840 | * @since 1.7.0 |
1841 | - * @param array $pieces |
|
1841 | + * @param array $pieces |
|
1842 | 1842 | * @return array $pieces |
1843 | 1843 | */ |
1844 | 1844 | public static function comment_total_sum_meta_value_filter( $pieces ) { |
@@ -1873,360 +1873,360 @@ discard block |
||
1873 | 1873 | return $pieces; |
1874 | 1874 | } |
1875 | 1875 | |
1876 | - /** |
|
1877 | - * |
|
1878 | - * Alias to Woothemes_Sensei_Utils::update_user_data |
|
1879 | - * @since 1.7.4 |
|
1880 | - * |
|
1881 | - * @param string $data_key maximum 39 characters allowed |
|
1882 | - * @param int $post_id |
|
1883 | - * @param mixed $value |
|
1884 | - * @param int $user_id |
|
1885 | - * |
|
1886 | - * @return bool $success |
|
1887 | - */ |
|
1888 | - public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0 ){ |
|
1889 | - |
|
1890 | - return self::update_user_data( $data_key, $post_id, $value , $user_id ); |
|
1891 | - |
|
1892 | - }// end add_user_data |
|
1893 | - |
|
1894 | - /** |
|
1895 | - * add user specific data to the passed in sensei post type id |
|
1896 | - * |
|
1897 | - * This function saves comment meta on the users current status. If no status is available |
|
1898 | - * status will be created. It only operates on the available sensei Post types: course, lesson, quiz. |
|
1899 | - * |
|
1900 | - * @since 1.7.4 |
|
1901 | - * |
|
1902 | - * @param string $data_key maximum 39 characters allowed |
|
1903 | - * @param int $post_id |
|
1904 | - * @param mixed $value |
|
1905 | - * @param int $user_id |
|
1906 | - * |
|
1907 | - * @return bool $success |
|
1908 | - */ |
|
1909 | - public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0 ){ |
|
1910 | - |
|
1911 | - if( ! ( $user_id > 0 ) ){ |
|
1912 | - $user_id = get_current_user_id(); |
|
1913 | - } |
|
1914 | - |
|
1915 | - $supported_post_types = array( 'course', 'lesson' ); |
|
1916 | - $post_type = get_post_type( $post_id ); |
|
1917 | - if( empty( $post_id ) || empty( $data_key ) |
|
1918 | - || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) |
|
1919 | - || !get_userdata( $user_id ) |
|
1920 | - || ! in_array( $post_type, $supported_post_types ) ){ |
|
1921 | - |
|
1922 | - return false; |
|
1923 | - } |
|
1924 | - |
|
1925 | - // check if there and existing Sensei status on this post type if not create it |
|
1926 | - // and get the activity ID |
|
1927 | - $status_function = 'user_'.$post_type.'_status'; |
|
1928 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); |
|
1929 | - if( ! isset( $sensei_user_status->comment_ID ) ){ |
|
1930 | - |
|
1931 | - $start_function = 'user_start_'.$post_type; |
|
1932 | - $sensei_user_activity_id = self::$start_function( $user_id, $post_id ); |
|
1933 | - |
|
1934 | - }else{ |
|
1935 | - |
|
1936 | - $sensei_user_activity_id = $sensei_user_status->comment_ID; |
|
1937 | - |
|
1938 | - } |
|
1939 | - |
|
1940 | - // store the data |
|
1941 | - $success = update_comment_meta( $sensei_user_activity_id, $data_key, $value ); |
|
1942 | - |
|
1943 | - return $success; |
|
1944 | - |
|
1945 | - }//update_user_data |
|
1946 | - |
|
1947 | - /** |
|
1948 | - * Get the user data stored on the passed in post type |
|
1949 | - * |
|
1950 | - * This function gets the comment meta on the lesson or course status |
|
1951 | - * |
|
1952 | - * @since 1.7.4 |
|
1953 | - * |
|
1954 | - * @param $data_key |
|
1955 | - * @param $post_id |
|
1956 | - * @param int $user_id |
|
1957 | - * |
|
1958 | - * @return mixed $user_data_value |
|
1959 | - */ |
|
1960 | - public static function get_user_data( $data_key, $post_id, $user_id = 0 ){ |
|
1961 | - |
|
1962 | - $user_data_value = true; |
|
1963 | - |
|
1964 | - if( ! ( $user_id > 0 ) ){ |
|
1965 | - $user_id = get_current_user_id(); |
|
1966 | - } |
|
1967 | - |
|
1968 | - $supported_post_types = array( 'course', 'lesson' ); |
|
1969 | - $post_type = get_post_type( $post_id ); |
|
1970 | - if( empty( $post_id ) || empty( $data_key ) |
|
1971 | - || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) |
|
1972 | - || ! get_userdata( $user_id ) |
|
1973 | - || !in_array( $post_type, $supported_post_types ) ){ |
|
1974 | - |
|
1975 | - return false; |
|
1976 | - } |
|
1977 | - |
|
1978 | - // check if there and existing Sensei status on this post type if not create it |
|
1979 | - // and get the activity ID |
|
1980 | - $status_function = 'user_'.$post_type.'_status'; |
|
1981 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); |
|
1982 | - if( ! isset( $sensei_user_status->comment_ID ) ){ |
|
1983 | - return false; |
|
1984 | - } |
|
1985 | - |
|
1986 | - $sensei_user_activity_id = $sensei_user_status->comment_ID; |
|
1987 | - $user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true ); |
|
1988 | - |
|
1989 | - return $user_data_value; |
|
1990 | - |
|
1991 | - }// end get_user_data |
|
1992 | - |
|
1993 | - /** |
|
1994 | - * Delete the Sensei user data for the given key, Sensei post type and user combination. |
|
1995 | - * |
|
1996 | - * @param int $data_key |
|
1997 | - * @param int $post_id |
|
1998 | - * @param int $user_id |
|
1999 | - * |
|
2000 | - * @return bool $deleted |
|
2001 | - */ |
|
2002 | - public static function delete_user_data( $data_key, $post_id , $user_id ){ |
|
2003 | - $deleted = true; |
|
1876 | + /** |
|
1877 | + * |
|
1878 | + * Alias to Woothemes_Sensei_Utils::update_user_data |
|
1879 | + * @since 1.7.4 |
|
1880 | + * |
|
1881 | + * @param string $data_key maximum 39 characters allowed |
|
1882 | + * @param int $post_id |
|
1883 | + * @param mixed $value |
|
1884 | + * @param int $user_id |
|
1885 | + * |
|
1886 | + * @return bool $success |
|
1887 | + */ |
|
1888 | + public static function add_user_data( $data_key, $post_id , $value = '' , $user_id = 0 ){ |
|
1889 | + |
|
1890 | + return self::update_user_data( $data_key, $post_id, $value , $user_id ); |
|
1891 | + |
|
1892 | + }// end add_user_data |
|
1893 | + |
|
1894 | + /** |
|
1895 | + * add user specific data to the passed in sensei post type id |
|
1896 | + * |
|
1897 | + * This function saves comment meta on the users current status. If no status is available |
|
1898 | + * status will be created. It only operates on the available sensei Post types: course, lesson, quiz. |
|
1899 | + * |
|
1900 | + * @since 1.7.4 |
|
1901 | + * |
|
1902 | + * @param string $data_key maximum 39 characters allowed |
|
1903 | + * @param int $post_id |
|
1904 | + * @param mixed $value |
|
1905 | + * @param int $user_id |
|
1906 | + * |
|
1907 | + * @return bool $success |
|
1908 | + */ |
|
1909 | + public static function update_user_data( $data_key, $post_id, $value = '' , $user_id = 0 ){ |
|
1910 | + |
|
1911 | + if( ! ( $user_id > 0 ) ){ |
|
1912 | + $user_id = get_current_user_id(); |
|
1913 | + } |
|
1914 | + |
|
1915 | + $supported_post_types = array( 'course', 'lesson' ); |
|
1916 | + $post_type = get_post_type( $post_id ); |
|
1917 | + if( empty( $post_id ) || empty( $data_key ) |
|
1918 | + || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) |
|
1919 | + || !get_userdata( $user_id ) |
|
1920 | + || ! in_array( $post_type, $supported_post_types ) ){ |
|
1921 | + |
|
1922 | + return false; |
|
1923 | + } |
|
1924 | + |
|
1925 | + // check if there and existing Sensei status on this post type if not create it |
|
1926 | + // and get the activity ID |
|
1927 | + $status_function = 'user_'.$post_type.'_status'; |
|
1928 | + $sensei_user_status = self::$status_function( $post_id ,$user_id ); |
|
1929 | + if( ! isset( $sensei_user_status->comment_ID ) ){ |
|
1930 | + |
|
1931 | + $start_function = 'user_start_'.$post_type; |
|
1932 | + $sensei_user_activity_id = self::$start_function( $user_id, $post_id ); |
|
1933 | + |
|
1934 | + }else{ |
|
1935 | + |
|
1936 | + $sensei_user_activity_id = $sensei_user_status->comment_ID; |
|
1937 | + |
|
1938 | + } |
|
1939 | + |
|
1940 | + // store the data |
|
1941 | + $success = update_comment_meta( $sensei_user_activity_id, $data_key, $value ); |
|
1942 | + |
|
1943 | + return $success; |
|
1944 | + |
|
1945 | + }//update_user_data |
|
1946 | + |
|
1947 | + /** |
|
1948 | + * Get the user data stored on the passed in post type |
|
1949 | + * |
|
1950 | + * This function gets the comment meta on the lesson or course status |
|
1951 | + * |
|
1952 | + * @since 1.7.4 |
|
1953 | + * |
|
1954 | + * @param $data_key |
|
1955 | + * @param $post_id |
|
1956 | + * @param int $user_id |
|
1957 | + * |
|
1958 | + * @return mixed $user_data_value |
|
1959 | + */ |
|
1960 | + public static function get_user_data( $data_key, $post_id, $user_id = 0 ){ |
|
1961 | + |
|
1962 | + $user_data_value = true; |
|
1963 | + |
|
1964 | + if( ! ( $user_id > 0 ) ){ |
|
1965 | + $user_id = get_current_user_id(); |
|
1966 | + } |
|
1967 | + |
|
1968 | + $supported_post_types = array( 'course', 'lesson' ); |
|
1969 | + $post_type = get_post_type( $post_id ); |
|
1970 | + if( empty( $post_id ) || empty( $data_key ) |
|
1971 | + || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) |
|
1972 | + || ! get_userdata( $user_id ) |
|
1973 | + || !in_array( $post_type, $supported_post_types ) ){ |
|
2004 | 1974 | |
2005 | - if( ! ( $user_id > 0 ) ){ |
|
2006 | - $user_id = get_current_user_id(); |
|
2007 | - } |
|
1975 | + return false; |
|
1976 | + } |
|
2008 | 1977 | |
2009 | - $supported_post_types = array( 'course', 'lesson' ); |
|
2010 | - $post_type = get_post_type( $post_id ); |
|
2011 | - if( empty( $post_id ) || empty( $data_key ) |
|
2012 | - || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) |
|
2013 | - || ! get_userdata( $user_id ) |
|
2014 | - || !in_array( $post_type, $supported_post_types ) ){ |
|
1978 | + // check if there and existing Sensei status on this post type if not create it |
|
1979 | + // and get the activity ID |
|
1980 | + $status_function = 'user_'.$post_type.'_status'; |
|
1981 | + $sensei_user_status = self::$status_function( $post_id ,$user_id ); |
|
1982 | + if( ! isset( $sensei_user_status->comment_ID ) ){ |
|
1983 | + return false; |
|
1984 | + } |
|
2015 | 1985 | |
2016 | - return false; |
|
2017 | - } |
|
1986 | + $sensei_user_activity_id = $sensei_user_status->comment_ID; |
|
1987 | + $user_data_value = get_comment_meta( $sensei_user_activity_id , $data_key, true ); |
|
1988 | + |
|
1989 | + return $user_data_value; |
|
1990 | + |
|
1991 | + }// end get_user_data |
|
1992 | + |
|
1993 | + /** |
|
1994 | + * Delete the Sensei user data for the given key, Sensei post type and user combination. |
|
1995 | + * |
|
1996 | + * @param int $data_key |
|
1997 | + * @param int $post_id |
|
1998 | + * @param int $user_id |
|
1999 | + * |
|
2000 | + * @return bool $deleted |
|
2001 | + */ |
|
2002 | + public static function delete_user_data( $data_key, $post_id , $user_id ){ |
|
2003 | + $deleted = true; |
|
2004 | + |
|
2005 | + if( ! ( $user_id > 0 ) ){ |
|
2006 | + $user_id = get_current_user_id(); |
|
2007 | + } |
|
2008 | + |
|
2009 | + $supported_post_types = array( 'course', 'lesson' ); |
|
2010 | + $post_type = get_post_type( $post_id ); |
|
2011 | + if( empty( $post_id ) || empty( $data_key ) |
|
2012 | + || ! is_int( $post_id ) || ! ( intval( $post_id ) > 0 ) || ! ( intval( $user_id ) > 0 ) |
|
2013 | + || ! get_userdata( $user_id ) |
|
2014 | + || !in_array( $post_type, $supported_post_types ) ){ |
|
2015 | + |
|
2016 | + return false; |
|
2017 | + } |
|
2018 | 2018 | |
2019 | - // check if there and existing Sensei status on this post type if not create it |
|
2020 | - // and get the activity ID |
|
2021 | - $status_function = 'user_'.$post_type.'_status'; |
|
2022 | - $sensei_user_status = self::$status_function( $post_id ,$user_id ); |
|
2023 | - if( ! isset( $sensei_user_status->comment_ID ) ){ |
|
2024 | - return false; |
|
2025 | - } |
|
2019 | + // check if there and existing Sensei status on this post type if not create it |
|
2020 | + // and get the activity ID |
|
2021 | + $status_function = 'user_'.$post_type.'_status'; |
|
2022 | + $sensei_user_status = self::$status_function( $post_id ,$user_id ); |
|
2023 | + if( ! isset( $sensei_user_status->comment_ID ) ){ |
|
2024 | + return false; |
|
2025 | + } |
|
2026 | 2026 | |
2027 | - $sensei_user_activity_id = $sensei_user_status->comment_ID; |
|
2028 | - $deleted = delete_comment_meta( $sensei_user_activity_id , $data_key ); |
|
2027 | + $sensei_user_activity_id = $sensei_user_status->comment_ID; |
|
2028 | + $deleted = delete_comment_meta( $sensei_user_activity_id , $data_key ); |
|
2029 | 2029 | |
2030 | - return $deleted; |
|
2030 | + return $deleted; |
|
2031 | 2031 | |
2032 | - }// end delete_user_data |
|
2032 | + }// end delete_user_data |
|
2033 | 2033 | |
2034 | 2034 | |
2035 | - /** |
|
2036 | - * The function creates a drop down. Never write up a Sensei select statement again. |
|
2037 | - * |
|
2038 | - * @since 1.8.0 |
|
2039 | - * |
|
2040 | - * @param string $selected_value |
|
2041 | - * @param $options{ |
|
2042 | - * @type string $value the value saved in the database |
|
2043 | - * @type string $option what the user will see in the list of items |
|
2044 | - * } |
|
2045 | - * @param array $attributes{ |
|
2046 | - * @type string $attribute type such name or id etc. |
|
2047 | - * @type string $value |
|
2048 | - * } |
|
2049 | - * @param bool $enable_none_option |
|
2050 | - * |
|
2051 | - * @return string $drop_down_element |
|
2052 | - */ |
|
2053 | - public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) { |
|
2035 | + /** |
|
2036 | + * The function creates a drop down. Never write up a Sensei select statement again. |
|
2037 | + * |
|
2038 | + * @since 1.8.0 |
|
2039 | + * |
|
2040 | + * @param string $selected_value |
|
2041 | + * @param $options{ |
|
2042 | + * @type string $value the value saved in the database |
|
2043 | + * @type string $option what the user will see in the list of items |
|
2044 | + * } |
|
2045 | + * @param array $attributes{ |
|
2046 | + * @type string $attribute type such name or id etc. |
|
2047 | + * @type string $value |
|
2048 | + * } |
|
2049 | + * @param bool $enable_none_option |
|
2050 | + * |
|
2051 | + * @return string $drop_down_element |
|
2052 | + */ |
|
2053 | + public static function generate_drop_down( $selected_value, $options = array() , $attributes = array(), $enable_none_option = true ) { |
|
2054 | 2054 | |
2055 | - $drop_down_element = ''; |
|
2055 | + $drop_down_element = ''; |
|
2056 | 2056 | |
2057 | - // setup the basic attributes |
|
2058 | - if( !isset( $attributes['name'] ) || empty( $attributes['name'] ) ) { |
|
2057 | + // setup the basic attributes |
|
2058 | + if( !isset( $attributes['name'] ) || empty( $attributes['name'] ) ) { |
|
2059 | 2059 | |
2060 | - $attributes['name'] = 'sensei-options'; |
|
2060 | + $attributes['name'] = 'sensei-options'; |
|
2061 | 2061 | |
2062 | - } |
|
2062 | + } |
|
2063 | 2063 | |
2064 | - if( !isset( $attributes['id'] ) || empty( $attributes['id'] ) ) { |
|
2064 | + if( !isset( $attributes['id'] ) || empty( $attributes['id'] ) ) { |
|
2065 | 2065 | |
2066 | - $attributes['id'] = 'sensei-options'; |
|
2066 | + $attributes['id'] = 'sensei-options'; |
|
2067 | 2067 | |
2068 | - } |
|
2068 | + } |
|
2069 | 2069 | |
2070 | - if( !isset( $attributes['class'] ) || empty( $attributes['class'] ) ) { |
|
2070 | + if( !isset( $attributes['class'] ) || empty( $attributes['class'] ) ) { |
|
2071 | 2071 | |
2072 | - $attributes['class'] ='chosen_select widefat'; |
|
2072 | + $attributes['class'] ='chosen_select widefat'; |
|
2073 | 2073 | |
2074 | - } |
|
2074 | + } |
|
2075 | 2075 | |
2076 | - // create element attributes |
|
2077 | - $combined_attributes = ''; |
|
2078 | - foreach( $attributes as $attribute => $value ){ |
|
2076 | + // create element attributes |
|
2077 | + $combined_attributes = ''; |
|
2078 | + foreach( $attributes as $attribute => $value ){ |
|
2079 | 2079 | |
2080 | - $combined_attributes .= $attribute . '="'.$value.'"' . ' '; |
|
2080 | + $combined_attributes .= $attribute . '="'.$value.'"' . ' '; |
|
2081 | 2081 | |
2082 | - }// end for each |
|
2082 | + }// end for each |
|
2083 | 2083 | |
2084 | 2084 | |
2085 | - // create the select element |
|
2086 | - $drop_down_element .= '<select '. $combined_attributes . ' >' . "\n"; |
|
2085 | + // create the select element |
|
2086 | + $drop_down_element .= '<select '. $combined_attributes . ' >' . "\n"; |
|
2087 | 2087 | |
2088 | - // show the none option if the client requested |
|
2089 | - if( $enable_none_option ) { |
|
2090 | - $drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>'; |
|
2091 | - } |
|
2088 | + // show the none option if the client requested |
|
2089 | + if( $enable_none_option ) { |
|
2090 | + $drop_down_element .= '<option value="">' . __('None', 'woothemes-sensei') . '</option>'; |
|
2091 | + } |
|
2092 | 2092 | |
2093 | - if ( count( $options ) > 0 ) { |
|
2093 | + if ( count( $options ) > 0 ) { |
|
2094 | 2094 | |
2095 | - foreach ($options as $value => $option ){ |
|
2095 | + foreach ($options as $value => $option ){ |
|
2096 | 2096 | |
2097 | - $element = ''; |
|
2098 | - $element.= '<option value="' . esc_attr( $value ) . '"'; |
|
2099 | - $element .= selected( $value, $selected_value, false ) . '>'; |
|
2100 | - $element .= esc_html( $option ) . '</option>' . "\n"; |
|
2097 | + $element = ''; |
|
2098 | + $element.= '<option value="' . esc_attr( $value ) . '"'; |
|
2099 | + $element .= selected( $value, $selected_value, false ) . '>'; |
|
2100 | + $element .= esc_html( $option ) . '</option>' . "\n"; |
|
2101 | 2101 | |
2102 | - // add the element to the select html |
|
2103 | - $drop_down_element.= $element; |
|
2104 | - } // End For Loop |
|
2102 | + // add the element to the select html |
|
2103 | + $drop_down_element.= $element; |
|
2104 | + } // End For Loop |
|
2105 | 2105 | |
2106 | - } // End If Statement |
|
2106 | + } // End If Statement |
|
2107 | 2107 | |
2108 | - $drop_down_element .= '</select>' . "\n"; |
|
2108 | + $drop_down_element .= '</select>' . "\n"; |
|
2109 | 2109 | |
2110 | - return $drop_down_element; |
|
2110 | + return $drop_down_element; |
|
2111 | 2111 | |
2112 | - }// generate_drop_down |
|
2112 | + }// generate_drop_down |
|
2113 | 2113 | |
2114 | - /** |
|
2115 | - * Wrapper for the default php round() function. |
|
2116 | - * This allows us to give more control to a user on how they can round Sensei |
|
2117 | - * decimals passed through this function. |
|
2118 | - * |
|
2119 | - * @since 1.8.5 |
|
2120 | - * |
|
2121 | - * @param double $val |
|
2122 | - * @param int $precision |
|
2123 | - * @param $mode |
|
2124 | - * @param string $context |
|
2125 | - * |
|
2126 | - * @return double $val |
|
2127 | - */ |
|
2128 | - public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = '' ){ |
|
2114 | + /** |
|
2115 | + * Wrapper for the default php round() function. |
|
2116 | + * This allows us to give more control to a user on how they can round Sensei |
|
2117 | + * decimals passed through this function. |
|
2118 | + * |
|
2119 | + * @since 1.8.5 |
|
2120 | + * |
|
2121 | + * @param double $val |
|
2122 | + * @param int $precision |
|
2123 | + * @param $mode |
|
2124 | + * @param string $context |
|
2125 | + * |
|
2126 | + * @return double $val |
|
2127 | + */ |
|
2128 | + public static function round( $val, $precision = 0, $mode = PHP_ROUND_HALF_UP, $context = '' ){ |
|
2129 | 2129 | |
2130 | - /**å |
|
2130 | + /**å |
|
2131 | 2131 | * Change the precision for the Sensei_Utils::round function. |
2132 | 2132 | * the precision given will be passed into the php round function |
2133 | 2133 | * @since 1.8.5 |
2134 | 2134 | */ |
2135 | - $precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode ); |
|
2136 | - |
|
2137 | - /** |
|
2138 | - * Change the mode for the Sensei_Utils::round function. |
|
2139 | - * the mode given will be passed into the php round function |
|
2140 | - * |
|
2141 | - * This applies only to PHP version 5.3.0 and greater |
|
2142 | - * |
|
2143 | - * @since 1.8.5 |
|
2144 | - */ |
|
2145 | - $mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision ); |
|
2135 | + $precision = apply_filters( 'sensei_round_precision', $precision , $val, $context, $mode ); |
|
2136 | + |
|
2137 | + /** |
|
2138 | + * Change the mode for the Sensei_Utils::round function. |
|
2139 | + * the mode given will be passed into the php round function |
|
2140 | + * |
|
2141 | + * This applies only to PHP version 5.3.0 and greater |
|
2142 | + * |
|
2143 | + * @since 1.8.5 |
|
2144 | + */ |
|
2145 | + $mode = apply_filters( 'sensei_round_mode', $mode , $val, $context, $precision ); |
|
2146 | 2146 | |
2147 | - if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) { |
|
2147 | + if ( version_compare(PHP_VERSION, '5.3.0') >= 0 ) { |
|
2148 | 2148 | |
2149 | - return round( $val, $precision, $mode ); |
|
2149 | + return round( $val, $precision, $mode ); |
|
2150 | 2150 | |
2151 | - }else{ |
|
2151 | + }else{ |
|
2152 | 2152 | |
2153 | - return round( $val, $precision ); |
|
2153 | + return round( $val, $precision ); |
|
2154 | 2154 | |
2155 | - } |
|
2155 | + } |
|
2156 | 2156 | |
2157 | - } |
|
2157 | + } |
|
2158 | 2158 | |
2159 | - /** |
|
2160 | - * Returns the current url with all the query vars |
|
2161 | - * |
|
2162 | - * @since 1.9.0 |
|
2163 | - * @return string $url |
|
2164 | - */ |
|
2165 | - public static function get_current_url(){ |
|
2159 | + /** |
|
2160 | + * Returns the current url with all the query vars |
|
2161 | + * |
|
2162 | + * @since 1.9.0 |
|
2163 | + * @return string $url |
|
2164 | + */ |
|
2165 | + public static function get_current_url(){ |
|
2166 | 2166 | |
2167 | - global $wp; |
|
2168 | - $current_url = trailingslashit( home_url( $wp->request ) ); |
|
2169 | - if ( isset( $_GET ) ) { |
|
2167 | + global $wp; |
|
2168 | + $current_url = trailingslashit( home_url( $wp->request ) ); |
|
2169 | + if ( isset( $_GET ) ) { |
|
2170 | 2170 | |
2171 | - foreach ($_GET as $param => $val ) { |
|
2171 | + foreach ($_GET as $param => $val ) { |
|
2172 | 2172 | |
2173 | - $current_url = add_query_arg( $param, $val , $current_url ); |
|
2173 | + $current_url = add_query_arg( $param, $val , $current_url ); |
|
2174 | 2174 | |
2175 | - } |
|
2176 | - } |
|
2175 | + } |
|
2176 | + } |
|
2177 | 2177 | |
2178 | - return $current_url; |
|
2179 | - } |
|
2178 | + return $current_url; |
|
2179 | + } |
|
2180 | 2180 | |
2181 | - /** |
|
2182 | - * Restore the global WP_Query |
|
2183 | - * |
|
2184 | - * @since 1.9.0 |
|
2185 | - */ |
|
2186 | - public static function restore_wp_query() { |
|
2181 | + /** |
|
2182 | + * Restore the global WP_Query |
|
2183 | + * |
|
2184 | + * @since 1.9.0 |
|
2185 | + */ |
|
2186 | + public static function restore_wp_query() { |
|
2187 | 2187 | |
2188 | - wp_reset_query(); |
|
2188 | + wp_reset_query(); |
|
2189 | 2189 | |
2190 | - } |
|
2190 | + } |
|
2191 | 2191 | |
2192 | - /** |
|
2193 | - * Merge two arrays in a zip like fashion. |
|
2194 | - * If one array is longer than the other the elements will be apended |
|
2195 | - * to the end of the resulting array. |
|
2196 | - * |
|
2197 | - * @since 1.9.0 |
|
2198 | - * |
|
2199 | - * @param array $array_a |
|
2200 | - * @param array $array_b |
|
2201 | - * @return array $merged_array |
|
2202 | - */ |
|
2203 | - public static function array_zip_merge( $array_a, $array_b ){ |
|
2192 | + /** |
|
2193 | + * Merge two arrays in a zip like fashion. |
|
2194 | + * If one array is longer than the other the elements will be apended |
|
2195 | + * to the end of the resulting array. |
|
2196 | + * |
|
2197 | + * @since 1.9.0 |
|
2198 | + * |
|
2199 | + * @param array $array_a |
|
2200 | + * @param array $array_b |
|
2201 | + * @return array $merged_array |
|
2202 | + */ |
|
2203 | + public static function array_zip_merge( $array_a, $array_b ){ |
|
2204 | 2204 | |
2205 | - if( ! isset( $array_a[0] ) || ! isset( $array_b[0] ) ){ |
|
2206 | - trigger_error('array_zip_merge requires both arrays to be indexed arrays '); |
|
2207 | - } |
|
2205 | + if( ! isset( $array_a[0] ) || ! isset( $array_b[0] ) ){ |
|
2206 | + trigger_error('array_zip_merge requires both arrays to be indexed arrays '); |
|
2207 | + } |
|
2208 | 2208 | |
2209 | - $merged_array = array(); |
|
2210 | - $total_elements = count( $array_a ) + count( $array_b ); |
|
2209 | + $merged_array = array(); |
|
2210 | + $total_elements = count( $array_a ) + count( $array_b ); |
|
2211 | 2211 | |
2212 | - // Zip arrays |
|
2213 | - for ( $i = 0; $i < $total_elements; $i++) { |
|
2212 | + // Zip arrays |
|
2213 | + for ( $i = 0; $i < $total_elements; $i++) { |
|
2214 | 2214 | |
2215 | - // if has an element at current index push a on top |
|
2216 | - if( isset( $array_a[ $i ] ) ){ |
|
2217 | - $merged_array[] = $array_a[ $i ] ; |
|
2218 | - } |
|
2215 | + // if has an element at current index push a on top |
|
2216 | + if( isset( $array_a[ $i ] ) ){ |
|
2217 | + $merged_array[] = $array_a[ $i ] ; |
|
2218 | + } |
|
2219 | 2219 | |
2220 | - // next if $array_b has an element at current index push a on top of the element |
|
2221 | - // from a if there was one, if not the element before that. |
|
2222 | - if( isset( $array_b[ $i ] ) ){ |
|
2223 | - $merged_array[] = $array_b[ $i ] ; |
|
2224 | - } |
|
2220 | + // next if $array_b has an element at current index push a on top of the element |
|
2221 | + // from a if there was one, if not the element before that. |
|
2222 | + if( isset( $array_b[ $i ] ) ){ |
|
2223 | + $merged_array[] = $array_b[ $i ] ; |
|
2224 | + } |
|
2225 | 2225 | |
2226 | - } |
|
2226 | + } |
|
2227 | 2227 | |
2228 | - return $merged_array; |
|
2229 | - } |
|
2228 | + return $merged_array; |
|
2229 | + } |
|
2230 | 2230 | |
2231 | 2231 | } // End Class |
2232 | 2232 |
@@ -15,91 +15,91 @@ |
||
15 | 15 | */ |
16 | 16 | class Sensei_Shortcode_User_Messages implements Sensei_Shortcode_Interface { |
17 | 17 | |
18 | - /** |
|
19 | - * @var WP_Query |
|
20 | - * messages for the current user |
|
21 | - */ |
|
22 | - protected $messages_query; |
|
23 | - |
|
24 | - /** |
|
25 | - * Setup the shortcode object |
|
26 | - * |
|
27 | - * @since 1.9.0 |
|
28 | - * @param array $attributes |
|
29 | - * @param string $content |
|
30 | - * @param string $shortcode the shortcode that was called for this instance |
|
31 | - */ |
|
32 | - public function __construct( $attributes, $content, $shortcode ){ |
|
33 | - |
|
34 | - $this->setup_messages_query(); |
|
35 | - |
|
36 | - } |
|
37 | - |
|
38 | - /** |
|
39 | - * create the messages query . |
|
40 | - * |
|
41 | - * @return mixed |
|
42 | - */ |
|
43 | - public function setup_messages_query(){ |
|
44 | - |
|
45 | - $user = wp_get_current_user(); |
|
46 | - |
|
47 | - $args = array( |
|
48 | - 'post_type' => 'sensei_message', |
|
49 | - 'posts_per_page' => 500, |
|
50 | - 'orderby' => 'date', |
|
51 | - 'order' => 'DESC', |
|
52 | - 'post_status' => 'publish', |
|
53 | - 'meta_query' => array( |
|
54 | - array( |
|
55 | - 'key' => '_sender', |
|
56 | - 'value' => $user->user_login, |
|
57 | - 'compare' => '=', |
|
58 | - ), |
|
59 | - ), |
|
60 | - ); |
|
61 | - |
|
62 | - $this->messages_query = new WP_Query( $args ); |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * Rendering the shortcode this class is responsible for. |
|
67 | - * |
|
68 | - * @return string $content |
|
69 | - */ |
|
70 | - public function render(){ |
|
71 | - |
|
72 | - if( !is_user_logged_in() ){ |
|
73 | - |
|
74 | - Sensei()->notices->add_notice( __('Please login to view your messages.','woothemes-sensei') , 'alert' ); |
|
75 | - |
|
76 | - } elseif( 0 == $this->messages_query->post_count ){ |
|
77 | - |
|
78 | - Sensei()->notices->add_notice( __( 'You do not have any messages.', 'woothemes-sensei') , 'alert' ); |
|
79 | - } |
|
80 | - |
|
81 | - $messages_disabled_in_settings = ! ( ! isset( Sensei()->settings->settings['messages_disable'] ) |
|
82 | - || ! Sensei()->settings->settings['messages_disable'] ) ; |
|
83 | - |
|
84 | - // don't show anything if messages are disable |
|
85 | - if( $messages_disabled_in_settings ){ |
|
86 | - return ''; |
|
87 | - } |
|
88 | - |
|
89 | - //set the wp_query to the current messages query |
|
90 | - global $wp_query; |
|
91 | - $wp_query = $this->messages_query; |
|
92 | - |
|
93 | - ob_start(); |
|
94 | - Sensei()->notices->print_notices(); |
|
95 | - Sensei_Templates::get_part('loop', 'message'); |
|
96 | - $messages_html = ob_get_clean(); |
|
97 | - |
|
98 | - // set back the global query |
|
99 | - wp_reset_query(); |
|
100 | - |
|
101 | - return $messages_html; |
|
102 | - |
|
103 | - }// end render |
|
18 | + /** |
|
19 | + * @var WP_Query |
|
20 | + * messages for the current user |
|
21 | + */ |
|
22 | + protected $messages_query; |
|
23 | + |
|
24 | + /** |
|
25 | + * Setup the shortcode object |
|
26 | + * |
|
27 | + * @since 1.9.0 |
|
28 | + * @param array $attributes |
|
29 | + * @param string $content |
|
30 | + * @param string $shortcode the shortcode that was called for this instance |
|
31 | + */ |
|
32 | + public function __construct( $attributes, $content, $shortcode ){ |
|
33 | + |
|
34 | + $this->setup_messages_query(); |
|
35 | + |
|
36 | + } |
|
37 | + |
|
38 | + /** |
|
39 | + * create the messages query . |
|
40 | + * |
|
41 | + * @return mixed |
|
42 | + */ |
|
43 | + public function setup_messages_query(){ |
|
44 | + |
|
45 | + $user = wp_get_current_user(); |
|
46 | + |
|
47 | + $args = array( |
|
48 | + 'post_type' => 'sensei_message', |
|
49 | + 'posts_per_page' => 500, |
|
50 | + 'orderby' => 'date', |
|
51 | + 'order' => 'DESC', |
|
52 | + 'post_status' => 'publish', |
|
53 | + 'meta_query' => array( |
|
54 | + array( |
|
55 | + 'key' => '_sender', |
|
56 | + 'value' => $user->user_login, |
|
57 | + 'compare' => '=', |
|
58 | + ), |
|
59 | + ), |
|
60 | + ); |
|
61 | + |
|
62 | + $this->messages_query = new WP_Query( $args ); |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * Rendering the shortcode this class is responsible for. |
|
67 | + * |
|
68 | + * @return string $content |
|
69 | + */ |
|
70 | + public function render(){ |
|
71 | + |
|
72 | + if( !is_user_logged_in() ){ |
|
73 | + |
|
74 | + Sensei()->notices->add_notice( __('Please login to view your messages.','woothemes-sensei') , 'alert' ); |
|
75 | + |
|
76 | + } elseif( 0 == $this->messages_query->post_count ){ |
|
77 | + |
|
78 | + Sensei()->notices->add_notice( __( 'You do not have any messages.', 'woothemes-sensei') , 'alert' ); |
|
79 | + } |
|
80 | + |
|
81 | + $messages_disabled_in_settings = ! ( ! isset( Sensei()->settings->settings['messages_disable'] ) |
|
82 | + || ! Sensei()->settings->settings['messages_disable'] ) ; |
|
83 | + |
|
84 | + // don't show anything if messages are disable |
|
85 | + if( $messages_disabled_in_settings ){ |
|
86 | + return ''; |
|
87 | + } |
|
88 | + |
|
89 | + //set the wp_query to the current messages query |
|
90 | + global $wp_query; |
|
91 | + $wp_query = $this->messages_query; |
|
92 | + |
|
93 | + ob_start(); |
|
94 | + Sensei()->notices->print_notices(); |
|
95 | + Sensei_Templates::get_part('loop', 'message'); |
|
96 | + $messages_html = ob_get_clean(); |
|
97 | + |
|
98 | + // set back the global query |
|
99 | + wp_reset_query(); |
|
100 | + |
|
101 | + return $messages_html; |
|
102 | + |
|
103 | + }// end render |
|
104 | 104 | |
105 | 105 | }// end class |
106 | 106 | \ No newline at end of file |
@@ -17,25 +17,25 @@ discard block |
||
17 | 17 | public $slider_labels; |
18 | 18 | public $role_caps; |
19 | 19 | |
20 | - /** |
|
21 | - * @var Sensei_Course |
|
22 | - */ |
|
23 | - public $course; |
|
24 | - |
|
25 | - /** |
|
26 | - * @var Sensei_Lesson |
|
27 | - */ |
|
28 | - public $lesson; |
|
29 | - |
|
30 | - /** |
|
31 | - * @var Sensei_Question |
|
32 | - */ |
|
33 | - public $question; |
|
34 | - |
|
35 | - /** |
|
36 | - * @var Sensei_Quiz |
|
37 | - */ |
|
38 | - public $quiz; |
|
20 | + /** |
|
21 | + * @var Sensei_Course |
|
22 | + */ |
|
23 | + public $course; |
|
24 | + |
|
25 | + /** |
|
26 | + * @var Sensei_Lesson |
|
27 | + */ |
|
28 | + public $lesson; |
|
29 | + |
|
30 | + /** |
|
31 | + * @var Sensei_Question |
|
32 | + */ |
|
33 | + public $question; |
|
34 | + |
|
35 | + /** |
|
36 | + * @var Sensei_Quiz |
|
37 | + */ |
|
38 | + public $quiz; |
|
39 | 39 | |
40 | 40 | /** |
41 | 41 | * Constructor |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | // Setup Post Types |
47 | 47 | $this->labels = array(); |
48 | - $this->token = 'woothemes-sensei-posttypes'; |
|
48 | + $this->token = 'woothemes-sensei-posttypes'; |
|
49 | 49 | |
50 | 50 | $this->setup_post_type_labels_base(); |
51 | 51 | add_action( 'init', array( $this, 'setup_course_post_type' ), 100 ); |
@@ -104,94 +104,94 @@ discard block |
||
104 | 104 | /** |
105 | 105 | * Setup the "course" post type, it's admin menu item and the appropriate labels and permissions. |
106 | 106 | * @since 1.0.0 |
107 | - * @uses Sensei() |
|
107 | + * @uses Sensei() |
|
108 | 108 | * @return void |
109 | 109 | */ |
110 | 110 | public function setup_course_post_type () { |
111 | 111 | |
112 | 112 | $args = array( |
113 | - 'labels' => $this->create_post_type_labels( $this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu'] ), |
|
114 | - 'public' => true, |
|
115 | - 'publicly_queryable' => true, |
|
116 | - 'show_ui' => true, |
|
117 | - 'show_in_menu' => true, |
|
118 | - 'show_in_admin_bar' => true, |
|
119 | - 'query_var' => true, |
|
120 | - 'rewrite' => array( |
|
121 | - 'slug' => esc_attr( apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url base', 'woothemes-sensei' ) ) ) , |
|
122 | - 'with_front' => true, |
|
123 | - 'feeds' => true, |
|
124 | - 'pages' => true |
|
125 | - ), |
|
126 | - 'map_meta_cap' => true, |
|
127 | - 'capability_type' => 'course', |
|
128 | - 'has_archive' => $this->get_course_post_type_archive_slug(), |
|
129 | - 'hierarchical' => false, |
|
130 | - 'menu_position' => 51, |
|
131 | - 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ) |
|
113 | + 'labels' => $this->create_post_type_labels( $this->labels['course']['singular'], $this->labels['course']['plural'], $this->labels['course']['menu'] ), |
|
114 | + 'public' => true, |
|
115 | + 'publicly_queryable' => true, |
|
116 | + 'show_ui' => true, |
|
117 | + 'show_in_menu' => true, |
|
118 | + 'show_in_admin_bar' => true, |
|
119 | + 'query_var' => true, |
|
120 | + 'rewrite' => array( |
|
121 | + 'slug' => esc_attr( apply_filters( 'sensei_course_slug', _x( 'course', 'post type single url base', 'woothemes-sensei' ) ) ) , |
|
122 | + 'with_front' => true, |
|
123 | + 'feeds' => true, |
|
124 | + 'pages' => true |
|
125 | + ), |
|
126 | + 'map_meta_cap' => true, |
|
127 | + 'capability_type' => 'course', |
|
128 | + 'has_archive' => $this->get_course_post_type_archive_slug(), |
|
129 | + 'hierarchical' => false, |
|
130 | + 'menu_position' => 51, |
|
131 | + 'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ) |
|
132 | 132 | ); |
133 | 133 | |
134 | - /** |
|
135 | - * Filter the arguments passed in when registering the Sensei Course post type. |
|
136 | - * |
|
137 | - * @since 1.9.0 |
|
138 | - * @param array $args |
|
139 | - */ |
|
134 | + /** |
|
135 | + * Filter the arguments passed in when registering the Sensei Course post type. |
|
136 | + * |
|
137 | + * @since 1.9.0 |
|
138 | + * @param array $args |
|
139 | + */ |
|
140 | 140 | register_post_type( 'course', apply_filters( 'sensei_register_post_type_course', $args ) ); |
141 | 141 | |
142 | 142 | } // End setup_course_post_type() |
143 | 143 | |
144 | - /** |
|
145 | - * Figure out of the course post type has an archive and what it should be. |
|
146 | - * |
|
147 | - * This function should return 'courses' or the page_uri for the course page setting. |
|
148 | - * |
|
149 | - * For backward compatibility sake ( pre 1.9 )If the course page set in settings |
|
150 | - * still has any of the old shortcodes: [newcourses][featuredcourses][freecourses][paidcourses] the |
|
151 | - * page slug will not be returned. For any other pages without it the page URI will be returned. |
|
152 | - * |
|
153 | - * |
|
154 | - * @sine 1.9.0 |
|
155 | - * |
|
156 | - * |
|
157 | - * @return false|string |
|
158 | - */ |
|
159 | - public function get_course_post_type_archive_slug(){ |
|
144 | + /** |
|
145 | + * Figure out of the course post type has an archive and what it should be. |
|
146 | + * |
|
147 | + * This function should return 'courses' or the page_uri for the course page setting. |
|
148 | + * |
|
149 | + * For backward compatibility sake ( pre 1.9 )If the course page set in settings |
|
150 | + * still has any of the old shortcodes: [newcourses][featuredcourses][freecourses][paidcourses] the |
|
151 | + * page slug will not be returned. For any other pages without it the page URI will be returned. |
|
152 | + * |
|
153 | + * |
|
154 | + * @sine 1.9.0 |
|
155 | + * |
|
156 | + * |
|
157 | + * @return false|string |
|
158 | + */ |
|
159 | + public function get_course_post_type_archive_slug(){ |
|
160 | 160 | |
161 | - $settings_course_page = get_post( Sensei()->settings->get( 'course_page' ) ); |
|
161 | + $settings_course_page = get_post( Sensei()->settings->get( 'course_page' ) ); |
|
162 | 162 | |
163 | - // for a valid post that doesn't have any of the old short codes set the archive the same |
|
164 | - // as the page URI |
|
165 | - if( is_a( $settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes( $settings_course_page->post_content ) ){ |
|
163 | + // for a valid post that doesn't have any of the old short codes set the archive the same |
|
164 | + // as the page URI |
|
165 | + if( is_a( $settings_course_page, 'WP_Post') && ! $this->has_old_shortcodes( $settings_course_page->post_content ) ){ |
|
166 | 166 | |
167 | - return get_page_uri( $settings_course_page->ID ); |
|
167 | + return get_page_uri( $settings_course_page->ID ); |
|
168 | 168 | |
169 | - }else{ |
|
169 | + }else{ |
|
170 | 170 | |
171 | - return 'courses'; |
|
171 | + return 'courses'; |
|
172 | 172 | |
173 | - } |
|
173 | + } |
|
174 | 174 | |
175 | - }// end course_post_type_determine_archive |
|
175 | + }// end course_post_type_determine_archive |
|
176 | 176 | |
177 | - /** |
|
178 | - * Check if given content has any of these old shortcodes: |
|
179 | - * [newcourses][featuredcourses][freecourses][paidcourses] |
|
180 | - * |
|
181 | - * @since 1.9.0 |
|
182 | - * |
|
183 | - * @param string $content |
|
184 | - * |
|
185 | - * @return bool |
|
186 | - */ |
|
187 | - public function has_old_shortcodes( $content ){ |
|
177 | + /** |
|
178 | + * Check if given content has any of these old shortcodes: |
|
179 | + * [newcourses][featuredcourses][freecourses][paidcourses] |
|
180 | + * |
|
181 | + * @since 1.9.0 |
|
182 | + * |
|
183 | + * @param string $content |
|
184 | + * |
|
185 | + * @return bool |
|
186 | + */ |
|
187 | + public function has_old_shortcodes( $content ){ |
|
188 | 188 | |
189 | - return ( has_shortcode( $content, 'newcourses') |
|
190 | - || has_shortcode( $content, 'featuredcourses') |
|
191 | - || has_shortcode( $content, 'freecourses') |
|
192 | - || has_shortcode( $content, 'paidcourses') ); |
|
189 | + return ( has_shortcode( $content, 'newcourses') |
|
190 | + || has_shortcode( $content, 'featuredcourses') |
|
191 | + || has_shortcode( $content, 'freecourses') |
|
192 | + || has_shortcode( $content, 'paidcourses') ); |
|
193 | 193 | |
194 | - }// end has old shortcodes |
|
194 | + }// end has old shortcodes |
|
195 | 195 | |
196 | 196 | |
197 | 197 | /** |
@@ -213,32 +213,32 @@ discard block |
||
213 | 213 | } // End If Statement |
214 | 214 | |
215 | 215 | $args = array( |
216 | - 'labels' => $this->create_post_type_labels( $this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu'] ), |
|
217 | - 'public' => true, |
|
218 | - 'publicly_queryable' => true, |
|
219 | - 'show_ui' => true, |
|
220 | - 'show_in_menu' => true, |
|
221 | - 'query_var' => true, |
|
222 | - 'rewrite' => array( |
|
223 | - 'slug' => esc_attr( apply_filters( 'sensei_lesson_slug', _x( 'lesson', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
224 | - 'with_front' => true, |
|
225 | - 'feeds' => true, |
|
226 | - 'pages' => true |
|
227 | - ), |
|
228 | - 'map_meta_cap' => true, |
|
229 | - 'capability_type' => 'lesson', |
|
230 | - 'has_archive' => true, |
|
231 | - 'hierarchical' => false, |
|
232 | - 'menu_position' => 52, |
|
233 | - 'supports' => $supports_array |
|
216 | + 'labels' => $this->create_post_type_labels( $this->labels['lesson']['singular'], $this->labels['lesson']['plural'], $this->labels['lesson']['menu'] ), |
|
217 | + 'public' => true, |
|
218 | + 'publicly_queryable' => true, |
|
219 | + 'show_ui' => true, |
|
220 | + 'show_in_menu' => true, |
|
221 | + 'query_var' => true, |
|
222 | + 'rewrite' => array( |
|
223 | + 'slug' => esc_attr( apply_filters( 'sensei_lesson_slug', _x( 'lesson', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
224 | + 'with_front' => true, |
|
225 | + 'feeds' => true, |
|
226 | + 'pages' => true |
|
227 | + ), |
|
228 | + 'map_meta_cap' => true, |
|
229 | + 'capability_type' => 'lesson', |
|
230 | + 'has_archive' => true, |
|
231 | + 'hierarchical' => false, |
|
232 | + 'menu_position' => 52, |
|
233 | + 'supports' => $supports_array |
|
234 | 234 | ); |
235 | 235 | |
236 | - /** |
|
237 | - * Filter the arguments passed in when registering the Sensei Lesson post type. |
|
238 | - * |
|
239 | - * @since 1.9.0 |
|
240 | - * @param array $args |
|
241 | - */ |
|
236 | + /** |
|
237 | + * Filter the arguments passed in when registering the Sensei Lesson post type. |
|
238 | + * |
|
239 | + * @since 1.9.0 |
|
240 | + * @param array $args |
|
241 | + */ |
|
242 | 242 | register_post_type( 'lesson', apply_filters( 'sensei_register_post_type_lesson', $args ) ); |
243 | 243 | |
244 | 244 | } // End setup_lesson_post_type() |
@@ -246,45 +246,45 @@ discard block |
||
246 | 246 | /** |
247 | 247 | * Setup the "quiz" post type, it's admin menu item and the appropriate labels and permissions. |
248 | 248 | * @since 1.0.0 |
249 | - * @uses Sensei() |
|
249 | + * @uses Sensei() |
|
250 | 250 | * @return void |
251 | 251 | */ |
252 | 252 | public function setup_quiz_post_type () { |
253 | 253 | |
254 | 254 | |
255 | 255 | $args = array( |
256 | - 'labels' => $this->create_post_type_labels( |
|
257 | - $this->labels['quiz']['singular'], |
|
258 | - $this->labels['quiz']['plural'], |
|
259 | - $this->labels['quiz']['menu'] |
|
260 | - ), |
|
261 | - 'public' => true, |
|
262 | - 'publicly_queryable' => true, |
|
263 | - 'show_ui' => true, |
|
264 | - 'show_in_menu' => false, |
|
265 | - 'show_in_nav_menus' => false, |
|
266 | - 'query_var' => true, |
|
267 | - 'exclude_from_search' => true, |
|
268 | - 'rewrite' => array( |
|
269 | - 'slug' => esc_attr( apply_filters( 'sensei_quiz_slug', _x( 'quiz', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
270 | - 'with_front' => true, |
|
271 | - 'feeds' => true, |
|
272 | - 'pages' => true |
|
273 | - ), |
|
274 | - 'map_meta_cap' => true, |
|
275 | - 'capability_type' => 'quiz', |
|
276 | - 'has_archive' => false, |
|
277 | - 'hierarchical' => false, |
|
278 | - 'menu_position' => 20, // Below "Pages" |
|
279 | - 'supports' => array( '' ) |
|
256 | + 'labels' => $this->create_post_type_labels( |
|
257 | + $this->labels['quiz']['singular'], |
|
258 | + $this->labels['quiz']['plural'], |
|
259 | + $this->labels['quiz']['menu'] |
|
260 | + ), |
|
261 | + 'public' => true, |
|
262 | + 'publicly_queryable' => true, |
|
263 | + 'show_ui' => true, |
|
264 | + 'show_in_menu' => false, |
|
265 | + 'show_in_nav_menus' => false, |
|
266 | + 'query_var' => true, |
|
267 | + 'exclude_from_search' => true, |
|
268 | + 'rewrite' => array( |
|
269 | + 'slug' => esc_attr( apply_filters( 'sensei_quiz_slug', _x( 'quiz', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
270 | + 'with_front' => true, |
|
271 | + 'feeds' => true, |
|
272 | + 'pages' => true |
|
273 | + ), |
|
274 | + 'map_meta_cap' => true, |
|
275 | + 'capability_type' => 'quiz', |
|
276 | + 'has_archive' => false, |
|
277 | + 'hierarchical' => false, |
|
278 | + 'menu_position' => 20, // Below "Pages" |
|
279 | + 'supports' => array( '' ) |
|
280 | 280 | ); |
281 | 281 | |
282 | - /** |
|
283 | - * Filter the arguments passed in when registering the Sensei Quiz post type. |
|
284 | - * |
|
285 | - * @since 1.9.0 |
|
286 | - * @param array $args |
|
287 | - */ |
|
282 | + /** |
|
283 | + * Filter the arguments passed in when registering the Sensei Quiz post type. |
|
284 | + * |
|
285 | + * @since 1.9.0 |
|
286 | + * @param array $args |
|
287 | + */ |
|
288 | 288 | register_post_type( 'quiz', apply_filters( 'sensei_register_post_type_quiz', $args ) ); |
289 | 289 | |
290 | 290 | } // End setup_quiz_post_type() |
@@ -298,34 +298,34 @@ discard block |
||
298 | 298 | public function setup_question_post_type () { |
299 | 299 | |
300 | 300 | $args = array( |
301 | - 'labels' => $this->create_post_type_labels( $this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu'] ), |
|
302 | - 'public' => false, |
|
303 | - 'publicly_queryable' => true, |
|
304 | - 'show_ui' => true, |
|
305 | - 'show_in_menu' => true, |
|
306 | - 'show_in_nav_menus' => false, |
|
307 | - 'query_var' => true, |
|
308 | - 'exclude_from_search' => true, |
|
309 | - 'rewrite' => array( |
|
310 | - 'slug' => esc_attr( apply_filters( 'sensei_question_slug', _x( 'question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
311 | - 'with_front' => true, |
|
312 | - 'feeds' => true, |
|
313 | - 'pages' => true |
|
314 | - ), |
|
315 | - 'map_meta_cap' => true, |
|
316 | - 'capability_type' => 'question', |
|
317 | - 'has_archive' => true, |
|
318 | - 'hierarchical' => false, |
|
319 | - 'menu_position' => 51, |
|
320 | - 'supports' => array( 'title' ) |
|
301 | + 'labels' => $this->create_post_type_labels( $this->labels['question']['singular'], $this->labels['question']['plural'], $this->labels['question']['menu'] ), |
|
302 | + 'public' => false, |
|
303 | + 'publicly_queryable' => true, |
|
304 | + 'show_ui' => true, |
|
305 | + 'show_in_menu' => true, |
|
306 | + 'show_in_nav_menus' => false, |
|
307 | + 'query_var' => true, |
|
308 | + 'exclude_from_search' => true, |
|
309 | + 'rewrite' => array( |
|
310 | + 'slug' => esc_attr( apply_filters( 'sensei_question_slug', _x( 'question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
311 | + 'with_front' => true, |
|
312 | + 'feeds' => true, |
|
313 | + 'pages' => true |
|
314 | + ), |
|
315 | + 'map_meta_cap' => true, |
|
316 | + 'capability_type' => 'question', |
|
317 | + 'has_archive' => true, |
|
318 | + 'hierarchical' => false, |
|
319 | + 'menu_position' => 51, |
|
320 | + 'supports' => array( 'title' ) |
|
321 | 321 | ); |
322 | 322 | |
323 | - /** |
|
324 | - * Filter the arguments passed in when registering the Sensei Question post type. |
|
325 | - * |
|
326 | - * @since 1.9.0 |
|
327 | - * @param array $args |
|
328 | - */ |
|
323 | + /** |
|
324 | + * Filter the arguments passed in when registering the Sensei Question post type. |
|
325 | + * |
|
326 | + * @since 1.9.0 |
|
327 | + * @param array $args |
|
328 | + */ |
|
329 | 329 | register_post_type( 'question', apply_filters('sensei_register_post_type_question', $args ) ); |
330 | 330 | |
331 | 331 | } // End setup_question_post_type() |
@@ -338,26 +338,26 @@ discard block |
||
338 | 338 | public function setup_multiple_question_post_type () { |
339 | 339 | |
340 | 340 | $args = array( |
341 | - 'labels' => $this->create_post_type_labels( $this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu'] ), |
|
342 | - 'public' => false, |
|
343 | - 'publicly_queryable' => false, |
|
344 | - 'show_ui' => false, |
|
345 | - 'show_in_menu' => false, |
|
346 | - 'show_in_nav_menus' => false, |
|
347 | - 'query_var' => false, |
|
348 | - 'exclude_from_search' => true, |
|
349 | - 'rewrite' => array( |
|
350 | - 'slug' => esc_attr( apply_filters( 'sensei_multiple_question_slug', _x( 'multiple_question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
351 | - 'with_front' => false, |
|
352 | - 'feeds' => false, |
|
353 | - 'pages' => false |
|
354 | - ), |
|
355 | - 'map_meta_cap' => true, |
|
356 | - 'capability_type' => 'question', |
|
357 | - 'has_archive' => false, |
|
358 | - 'hierarchical' => false, |
|
359 | - 'menu_position' => 51, |
|
360 | - 'supports' => array( 'title', 'custom-fields' ) |
|
341 | + 'labels' => $this->create_post_type_labels( $this->labels['multiple_question']['singular'], $this->labels['multiple_question']['plural'], $this->labels['multiple_question']['menu'] ), |
|
342 | + 'public' => false, |
|
343 | + 'publicly_queryable' => false, |
|
344 | + 'show_ui' => false, |
|
345 | + 'show_in_menu' => false, |
|
346 | + 'show_in_nav_menus' => false, |
|
347 | + 'query_var' => false, |
|
348 | + 'exclude_from_search' => true, |
|
349 | + 'rewrite' => array( |
|
350 | + 'slug' => esc_attr( apply_filters( 'sensei_multiple_question_slug', _x( 'multiple_question', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
351 | + 'with_front' => false, |
|
352 | + 'feeds' => false, |
|
353 | + 'pages' => false |
|
354 | + ), |
|
355 | + 'map_meta_cap' => true, |
|
356 | + 'capability_type' => 'question', |
|
357 | + 'has_archive' => false, |
|
358 | + 'hierarchical' => false, |
|
359 | + 'menu_position' => 51, |
|
360 | + 'supports' => array( 'title', 'custom-fields' ) |
|
361 | 361 | ); |
362 | 362 | |
363 | 363 | register_post_type( 'multiple_question', $args ); |
@@ -374,34 +374,34 @@ discard block |
||
374 | 374 | if( ! isset( Sensei()->settings->settings['messages_disable'] ) || ! Sensei()->settings->settings['messages_disable'] ) { |
375 | 375 | |
376 | 376 | $args = array( |
377 | - 'labels' => $this->create_post_type_labels( $this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu'] ), |
|
378 | - 'public' => true, |
|
379 | - 'publicly_queryable' => true, |
|
380 | - 'show_ui' => true, |
|
381 | - 'show_in_menu' => 'sensei', |
|
382 | - 'show_in_nav_menus' => true, |
|
383 | - 'query_var' => true, |
|
384 | - 'exclude_from_search' => true, |
|
385 | - 'rewrite' => array( |
|
386 | - 'slug' => esc_attr( apply_filters( 'sensei_messages_slug', _x( 'messages', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
387 | - 'with_front' => false, |
|
388 | - 'feeds' => false, |
|
389 | - 'pages' => true |
|
390 | - ), |
|
391 | - 'map_meta_cap' => true, |
|
392 | - 'capability_type' => 'question', |
|
393 | - 'has_archive' => true, |
|
394 | - 'hierarchical' => false, |
|
395 | - 'menu_position' => 50, |
|
396 | - 'supports' => array( 'title', 'editor', 'comments' ), |
|
377 | + 'labels' => $this->create_post_type_labels( $this->labels['sensei_message']['singular'], $this->labels['sensei_message']['plural'], $this->labels['sensei_message']['menu'] ), |
|
378 | + 'public' => true, |
|
379 | + 'publicly_queryable' => true, |
|
380 | + 'show_ui' => true, |
|
381 | + 'show_in_menu' => 'sensei', |
|
382 | + 'show_in_nav_menus' => true, |
|
383 | + 'query_var' => true, |
|
384 | + 'exclude_from_search' => true, |
|
385 | + 'rewrite' => array( |
|
386 | + 'slug' => esc_attr( apply_filters( 'sensei_messages_slug', _x( 'messages', 'post type single slug', 'woothemes-sensei' ) ) ) , |
|
387 | + 'with_front' => false, |
|
388 | + 'feeds' => false, |
|
389 | + 'pages' => true |
|
390 | + ), |
|
391 | + 'map_meta_cap' => true, |
|
392 | + 'capability_type' => 'question', |
|
393 | + 'has_archive' => true, |
|
394 | + 'hierarchical' => false, |
|
395 | + 'menu_position' => 50, |
|
396 | + 'supports' => array( 'title', 'editor', 'comments' ), |
|
397 | 397 | ); |
398 | 398 | |
399 | - /** |
|
400 | - * Filter the arguments passed in when registering the Sensei sensei_message post type. |
|
401 | - * |
|
402 | - * @since 1.9.0 |
|
403 | - * @param array $args |
|
404 | - */ |
|
399 | + /** |
|
400 | + * Filter the arguments passed in when registering the Sensei sensei_message post type. |
|
401 | + * |
|
402 | + * @since 1.9.0 |
|
403 | + * @param array $args |
|
404 | + */ |
|
405 | 405 | register_post_type( 'sensei_message', apply_filters('sensei_register_post_type_sensei_message', $args ) ); |
406 | 406 | } |
407 | 407 | } // End setup_sensei_message_post_type() |
@@ -434,11 +434,11 @@ discard block |
||
434 | 434 | 'show_ui' => true, |
435 | 435 | 'query_var' => true, |
436 | 436 | 'show_in_nav_menus' => true, |
437 | - 'capabilities' => array( |
|
438 | - 'manage_terms' => 'manage_categories', |
|
439 | - 'edit_terms' => 'edit_courses', |
|
440 | - 'delete_terms' => 'manage_categories', |
|
441 | - 'assign_terms' => 'edit_courses',), |
|
437 | + 'capabilities' => array( |
|
438 | + 'manage_terms' => 'manage_categories', |
|
439 | + 'edit_terms' => 'edit_courses', |
|
440 | + 'delete_terms' => 'manage_categories', |
|
441 | + 'assign_terms' => 'edit_courses',), |
|
442 | 442 | 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_course_category_slug', _x( 'course-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
443 | 443 | ); |
444 | 444 | |
@@ -474,7 +474,7 @@ discard block |
||
474 | 474 | 'show_ui' => true, /* TO DO - future releases */ |
475 | 475 | 'query_var' => true, |
476 | 476 | 'show_in_nav_menus' => false, |
477 | - 'public' => false, |
|
477 | + 'public' => false, |
|
478 | 478 | 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_quiz_type_slug', _x( 'quiz-type', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
479 | 479 | ); |
480 | 480 | |
@@ -546,11 +546,11 @@ discard block |
||
546 | 546 | 'query_var' => false, |
547 | 547 | 'show_in_nav_menus' => false, |
548 | 548 | 'show_admin_column' => true, |
549 | - 'capabilities' => array( |
|
550 | - 'manage_terms' => 'manage_categories', |
|
551 | - 'edit_terms' => 'edit_questions', |
|
552 | - 'delete_terms' => 'manage_categories', |
|
553 | - 'assign_terms' => 'edit_questions',), |
|
549 | + 'capabilities' => array( |
|
550 | + 'manage_terms' => 'manage_categories', |
|
551 | + 'edit_terms' => 'edit_questions', |
|
552 | + 'delete_terms' => 'manage_categories', |
|
553 | + 'assign_terms' => 'edit_questions',), |
|
554 | 554 | 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_question_category_slug', _x( 'question-category', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
555 | 555 | ); |
556 | 556 | |
@@ -584,11 +584,11 @@ discard block |
||
584 | 584 | 'show_ui' => true, |
585 | 585 | 'query_var' => true, |
586 | 586 | 'show_in_nav_menus' => true, |
587 | - 'capabilities' => array( |
|
588 | - 'manage_terms' => 'manage_categories', |
|
589 | - 'edit_terms' => 'edit_lessons', |
|
590 | - 'delete_terms' => 'manage_categories', |
|
591 | - 'assign_terms' => 'edit_lessons',), |
|
587 | + 'capabilities' => array( |
|
588 | + 'manage_terms' => 'manage_categories', |
|
589 | + 'edit_terms' => 'edit_lessons', |
|
590 | + 'delete_terms' => 'manage_categories', |
|
591 | + 'assign_terms' => 'edit_lessons',), |
|
592 | 592 | 'rewrite' => array( 'slug' => esc_attr( apply_filters( 'sensei_lesson_tag_slug', _x( 'lesson-tag', 'taxonomy archive slug', 'woothemes-sensei' ) ) ) ) |
593 | 593 | ); |
594 | 594 | |
@@ -622,19 +622,19 @@ discard block |
||
622 | 622 | */ |
623 | 623 | private function create_post_type_labels ( $singular, $plural, $menu ) { |
624 | 624 | $labels = array( |
625 | - 'name' => sprintf( _x( '%s', 'post type general name', 'woothemes-sensei' ), $plural ), |
|
626 | - 'singular_name' => sprintf( _x( '%s', 'post type singular name', 'woothemes-sensei' ), $singular ), |
|
627 | - 'add_new' => __( 'Add New', 'woothemes-sensei' ), |
|
628 | - 'add_new_item' => sprintf( __( 'Add New %s', 'woothemes-sensei' ), $singular ), |
|
629 | - 'edit_item' => sprintf( __( 'Edit %s', 'woothemes-sensei' ), $singular ), |
|
630 | - 'new_item' => sprintf( __( 'New %s', 'woothemes-sensei' ), $singular ), |
|
631 | - 'all_items' => sprintf( __( 'All %s', 'woothemes-sensei' ), $plural ), |
|
632 | - 'view_item' => sprintf( __( 'View %s', 'woothemes-sensei' ), $singular ), |
|
633 | - 'search_items' => sprintf( __( 'Search %s', 'woothemes-sensei' ), $plural ), |
|
634 | - 'not_found' => sprintf( __( 'No %s found', 'woothemes-sensei' ), mb_strtolower( $plural, 'UTF-8') ), |
|
635 | - 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'woothemes-sensei' ), mb_strtolower( $plural, 'UTF-8') ), |
|
636 | - 'parent_item_colon' => '', |
|
637 | - 'menu_name' => sprintf( __( '%s', 'woothemes-sensei' ), $menu ) |
|
625 | + 'name' => sprintf( _x( '%s', 'post type general name', 'woothemes-sensei' ), $plural ), |
|
626 | + 'singular_name' => sprintf( _x( '%s', 'post type singular name', 'woothemes-sensei' ), $singular ), |
|
627 | + 'add_new' => __( 'Add New', 'woothemes-sensei' ), |
|
628 | + 'add_new_item' => sprintf( __( 'Add New %s', 'woothemes-sensei' ), $singular ), |
|
629 | + 'edit_item' => sprintf( __( 'Edit %s', 'woothemes-sensei' ), $singular ), |
|
630 | + 'new_item' => sprintf( __( 'New %s', 'woothemes-sensei' ), $singular ), |
|
631 | + 'all_items' => sprintf( __( 'All %s', 'woothemes-sensei' ), $plural ), |
|
632 | + 'view_item' => sprintf( __( 'View %s', 'woothemes-sensei' ), $singular ), |
|
633 | + 'search_items' => sprintf( __( 'Search %s', 'woothemes-sensei' ), $plural ), |
|
634 | + 'not_found' => sprintf( __( 'No %s found', 'woothemes-sensei' ), mb_strtolower( $plural, 'UTF-8') ), |
|
635 | + 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'woothemes-sensei' ), mb_strtolower( $plural, 'UTF-8') ), |
|
636 | + 'parent_item_colon' => '', |
|
637 | + 'menu_name' => sprintf( __( '%s', 'woothemes-sensei' ), $menu ) |
|
638 | 638 | ); |
639 | 639 | |
640 | 640 | return $labels; |
@@ -707,7 +707,7 @@ discard block |
||
707 | 707 | * Assigns the defaults for each user role capabilities. |
708 | 708 | * |
709 | 709 | * @since 1.1.0 |
710 | - * |
|
710 | + * |
|
711 | 711 | * @param array $post_types |
712 | 712 | * @return void |
713 | 713 | */ |
@@ -775,7 +775,7 @@ discard block |
||
775 | 775 | * Adds a 'Edit Quiz' link to the admin bar when viewing a Quiz linked to a corresponding Lesson |
776 | 776 | * |
777 | 777 | * @since 1.7.0 |
778 | - * @param WP_Admin_Bar $bar |
|
778 | + * @param WP_Admin_Bar $bar |
|
779 | 779 | * @return void |
780 | 780 | */ |
781 | 781 | public function quiz_admin_bar_menu( $bar ) { |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | * @since 1.0.0 |
22 | 22 | */ |
23 | 23 | public function __construct () { |
24 | - $this->token = 'question'; |
|
24 | + $this->token = 'question'; |
|
25 | 25 | $this->question_types = $this->question_types(); |
26 | 26 | $this->meta_fields = array( 'question_right_answer', 'question_wrong_answers' ); |
27 | 27 | if ( is_admin() ) { |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | |
119 | 119 | if( isset( $post->ID ) ) { |
120 | 120 | |
121 | - $question_type = Sensei()->question->get_question_type( $post->ID ); |
|
121 | + $question_type = Sensei()->question->get_question_type( $post->ID ); |
|
122 | 122 | |
123 | 123 | if( $question_type ) { |
124 | 124 | $type = $this->question_types[ $question_type ]; |
@@ -238,15 +238,15 @@ discard block |
||
238 | 238 | public function save_question( $post_id = 0 ) { |
239 | 239 | |
240 | 240 | if( ! isset( $_POST['post_type'] |
241 | - ) || 'question' != $_POST['post_type'] ) { |
|
242 | - return; |
|
243 | - } |
|
241 | + ) || 'question' != $_POST['post_type'] ) { |
|
242 | + return; |
|
243 | + } |
|
244 | 244 | |
245 | 245 | |
246 | 246 | |
247 | - //setup the data for saving |
|
247 | + //setup the data for saving |
|
248 | 248 | $data = $_POST ; |
249 | - $data['quiz_id'] = 0; |
|
249 | + $data['quiz_id'] = 0; |
|
250 | 250 | $data['question_id'] = $post_id; |
251 | 251 | |
252 | 252 | if ( ! wp_is_post_revision( $post_id ) ){ |
@@ -340,34 +340,34 @@ discard block |
||
340 | 340 | return $request; |
341 | 341 | } |
342 | 342 | |
343 | - /** |
|
344 | - * Get the type of question by id |
|
345 | - * |
|
346 | - * This function uses the post terms to determine which question type |
|
347 | - * the passed question id belongs to. |
|
348 | - * |
|
349 | - * @since 1.7.4 |
|
350 | - * |
|
351 | - * @param int $question_id |
|
352 | - * |
|
353 | - * @return string $question_type | bool |
|
354 | - */ |
|
355 | - public function get_question_type( $question_id ){ |
|
356 | - |
|
357 | - if( empty( $question_id ) || ! intval( $question_id ) > 0 |
|
358 | - || 'question' != get_post_type( $question_id ) ){ |
|
359 | - return false; |
|
360 | - } |
|
361 | - |
|
362 | - $question_type = 'multiple-choice'; |
|
363 | - $question_types = wp_get_post_terms( $question_id, 'question-type' ); |
|
364 | - foreach( $question_types as $type ) { |
|
365 | - $question_type = $type->slug; |
|
366 | - } |
|
367 | - |
|
368 | - return $question_type; |
|
369 | - |
|
370 | - }// end get_question_type |
|
343 | + /** |
|
344 | + * Get the type of question by id |
|
345 | + * |
|
346 | + * This function uses the post terms to determine which question type |
|
347 | + * the passed question id belongs to. |
|
348 | + * |
|
349 | + * @since 1.7.4 |
|
350 | + * |
|
351 | + * @param int $question_id |
|
352 | + * |
|
353 | + * @return string $question_type | bool |
|
354 | + */ |
|
355 | + public function get_question_type( $question_id ){ |
|
356 | + |
|
357 | + if( empty( $question_id ) || ! intval( $question_id ) > 0 |
|
358 | + || 'question' != get_post_type( $question_id ) ){ |
|
359 | + return false; |
|
360 | + } |
|
361 | + |
|
362 | + $question_type = 'multiple-choice'; |
|
363 | + $question_types = wp_get_post_terms( $question_id, 'question-type' ); |
|
364 | + foreach( $question_types as $type ) { |
|
365 | + $question_type = $type->slug; |
|
366 | + } |
|
367 | + |
|
368 | + return $question_type; |
|
369 | + |
|
370 | + }// end get_question_type |
|
371 | 371 | |
372 | 372 | /** |
373 | 373 | * Given a question ID, return the grade that can be achieved. |
@@ -399,317 +399,317 @@ discard block |
||
399 | 399 | } // end get_question_grade |
400 | 400 | |
401 | 401 | |
402 | - /** |
|
403 | - * This function simply loads the question type template |
|
404 | - * |
|
405 | - * @since 1.9.0 |
|
406 | - * @param $question_type |
|
407 | - */ |
|
408 | - public static function load_question_template( $question_type ){ |
|
409 | - |
|
410 | - Sensei_Templates::get_template ( 'single-quiz/question_type-' . $question_type . '.php' ); |
|
411 | - } |
|
412 | - |
|
413 | - /** |
|
414 | - * Echo the sensei question title. |
|
415 | - * |
|
416 | - * @uses WooThemes_Sensei_Question::get_the_question_title |
|
417 | - * |
|
418 | - * @since 1.9.0 |
|
419 | - * @param $question_id |
|
420 | - */ |
|
421 | - public static function the_question_title( $question_id ){ |
|
422 | - |
|
423 | - echo self::get_the_question_title( $question_id ); |
|
424 | - |
|
425 | - }// end the_question_title |
|
426 | - |
|
427 | - /** |
|
428 | - * Generate the question title with it's grade. |
|
429 | - * |
|
430 | - * @since 1.9.0 |
|
431 | - * |
|
432 | - * @param $question_id |
|
433 | - * @return string |
|
434 | - */ |
|
435 | - public static function get_the_question_title( $question_id ){ |
|
436 | - |
|
437 | - /** |
|
438 | - * Filter the sensei question title |
|
439 | - * |
|
440 | - * @since 1.3.0 |
|
441 | - * @param $question_title |
|
442 | - */ |
|
443 | - $title = apply_filters( 'sensei_question_title', get_the_title( $question_id ) ); |
|
444 | - |
|
445 | - /** |
|
446 | - * hook document in class-woothemes-sensei-message.php the_title() |
|
447 | - */ |
|
448 | - $title = apply_filters( 'sensei_single_title', $title, 'question'); |
|
449 | - |
|
450 | - $title_html = '<span class="question question-title">'; |
|
451 | - $title_html .= $title; |
|
452 | - $title_html .= '<span class="grade"><?php sensi_the_question_grade()?></span>'; |
|
453 | - $title_html .='</span>'; |
|
454 | - |
|
455 | - return $title_html; |
|
456 | - } |
|
457 | - |
|
458 | - /** |
|
459 | - * Tech the question description |
|
460 | - * |
|
461 | - * @param $question_id |
|
462 | - * @return string |
|
463 | - */ |
|
464 | - public static function get_the_question_description( $question_id ){ |
|
465 | - |
|
466 | - $question = get_post( $question_id ); |
|
467 | - |
|
468 | - /** |
|
469 | - * Already documented within WordPress Core |
|
470 | - */ |
|
471 | - return apply_filters( 'the_content', $question->post_content ); |
|
472 | - |
|
473 | - } |
|
474 | - |
|
475 | - /** |
|
476 | - * Output the question description |
|
477 | - * |
|
478 | - * @since 1.9.0 |
|
479 | - * @param $question_id |
|
480 | - */ |
|
481 | - public static function the_question_description( $question_id ){ |
|
482 | - |
|
483 | - echo self::get_the_question_description( $question_id ); |
|
484 | - |
|
485 | - } |
|
486 | - |
|
487 | - /** |
|
488 | - * Get the questions media markup |
|
489 | - * |
|
490 | - * @since 1.9.0 |
|
491 | - * @param $question_id |
|
492 | - * @return string |
|
493 | - */ |
|
494 | - public static function get_the_question_media( $question_id ){ |
|
495 | - |
|
496 | - $question_media = get_post_meta( $question_id, '_question_media', true ); |
|
497 | - $question_media_link = ''; |
|
498 | - if( 0 < intval( $question_media ) ) { |
|
499 | - $mimetype = get_post_mime_type( $question_media ); |
|
500 | - if( $mimetype ) { |
|
501 | - $mimetype_array = explode( '/', $mimetype); |
|
502 | - if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) { |
|
503 | - $question_media_type = $mimetype_array[0]; |
|
504 | - $question_media_url = wp_get_attachment_url( $question_media ); |
|
505 | - $attachment = get_post( $question_media ); |
|
506 | - $question_media_title = $attachment->post_title; |
|
507 | - $question_media_description = $attachment->post_content; |
|
508 | - switch( $question_media_type ) { |
|
509 | - case 'image': |
|
510 | - $image_size = apply_filters( 'sensei_question_image_size', 'medium', $question_id ); |
|
511 | - $attachment_src = wp_get_attachment_image_src( $question_media, $image_size ); |
|
512 | - $question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank"><img src="' . $attachment_src[0] . '" width="' . $attachment_src[1] . '" height="' . $attachment_src[2] . '" /></a>'; |
|
513 | - break; |
|
514 | - |
|
515 | - case 'audio': |
|
516 | - $question_media_link = wp_audio_shortcode( array( 'src' => $question_media_url ) ); |
|
517 | - break; |
|
518 | - |
|
519 | - case 'video': |
|
520 | - $question_media_link = wp_video_shortcode( array( 'src' => $question_media_url ) ); |
|
521 | - break; |
|
522 | - |
|
523 | - default: |
|
524 | - $question_media_filename = basename( $question_media_url ); |
|
525 | - $question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_filename . '</a>'; |
|
526 | - break; |
|
527 | - } |
|
528 | - } |
|
529 | - } |
|
530 | - } |
|
531 | - |
|
532 | - $output = ''; |
|
533 | - if( $question_media_link ) { |
|
534 | - |
|
535 | - $output .= '<div class="question_media_display">'; |
|
536 | - $output .= $question_media_link; |
|
537 | - $output .= '<dl>'; |
|
538 | - |
|
539 | - if( $question_media_title ) { |
|
540 | - |
|
541 | - $output .= '<dt>'. $question_media_title. '</dt>'; |
|
542 | - |
|
543 | - } |
|
544 | - |
|
545 | - if( $question_media_description ) { |
|
546 | - |
|
547 | - $output .= '<dd>' . $question_media_description . '</dd>'; |
|
548 | - |
|
549 | - } |
|
550 | - |
|
551 | - $output .= '</dl>'; |
|
552 | - $output .= '</div>'; |
|
402 | + /** |
|
403 | + * This function simply loads the question type template |
|
404 | + * |
|
405 | + * @since 1.9.0 |
|
406 | + * @param $question_type |
|
407 | + */ |
|
408 | + public static function load_question_template( $question_type ){ |
|
409 | + |
|
410 | + Sensei_Templates::get_template ( 'single-quiz/question_type-' . $question_type . '.php' ); |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * Echo the sensei question title. |
|
415 | + * |
|
416 | + * @uses WooThemes_Sensei_Question::get_the_question_title |
|
417 | + * |
|
418 | + * @since 1.9.0 |
|
419 | + * @param $question_id |
|
420 | + */ |
|
421 | + public static function the_question_title( $question_id ){ |
|
422 | + |
|
423 | + echo self::get_the_question_title( $question_id ); |
|
424 | + |
|
425 | + }// end the_question_title |
|
426 | + |
|
427 | + /** |
|
428 | + * Generate the question title with it's grade. |
|
429 | + * |
|
430 | + * @since 1.9.0 |
|
431 | + * |
|
432 | + * @param $question_id |
|
433 | + * @return string |
|
434 | + */ |
|
435 | + public static function get_the_question_title( $question_id ){ |
|
436 | + |
|
437 | + /** |
|
438 | + * Filter the sensei question title |
|
439 | + * |
|
440 | + * @since 1.3.0 |
|
441 | + * @param $question_title |
|
442 | + */ |
|
443 | + $title = apply_filters( 'sensei_question_title', get_the_title( $question_id ) ); |
|
444 | + |
|
445 | + /** |
|
446 | + * hook document in class-woothemes-sensei-message.php the_title() |
|
447 | + */ |
|
448 | + $title = apply_filters( 'sensei_single_title', $title, 'question'); |
|
449 | + |
|
450 | + $title_html = '<span class="question question-title">'; |
|
451 | + $title_html .= $title; |
|
452 | + $title_html .= '<span class="grade"><?php sensi_the_question_grade()?></span>'; |
|
453 | + $title_html .='</span>'; |
|
454 | + |
|
455 | + return $title_html; |
|
456 | + } |
|
457 | + |
|
458 | + /** |
|
459 | + * Tech the question description |
|
460 | + * |
|
461 | + * @param $question_id |
|
462 | + * @return string |
|
463 | + */ |
|
464 | + public static function get_the_question_description( $question_id ){ |
|
465 | + |
|
466 | + $question = get_post( $question_id ); |
|
467 | + |
|
468 | + /** |
|
469 | + * Already documented within WordPress Core |
|
470 | + */ |
|
471 | + return apply_filters( 'the_content', $question->post_content ); |
|
472 | + |
|
473 | + } |
|
474 | + |
|
475 | + /** |
|
476 | + * Output the question description |
|
477 | + * |
|
478 | + * @since 1.9.0 |
|
479 | + * @param $question_id |
|
480 | + */ |
|
481 | + public static function the_question_description( $question_id ){ |
|
482 | + |
|
483 | + echo self::get_the_question_description( $question_id ); |
|
484 | + |
|
485 | + } |
|
486 | + |
|
487 | + /** |
|
488 | + * Get the questions media markup |
|
489 | + * |
|
490 | + * @since 1.9.0 |
|
491 | + * @param $question_id |
|
492 | + * @return string |
|
493 | + */ |
|
494 | + public static function get_the_question_media( $question_id ){ |
|
495 | + |
|
496 | + $question_media = get_post_meta( $question_id, '_question_media', true ); |
|
497 | + $question_media_link = ''; |
|
498 | + if( 0 < intval( $question_media ) ) { |
|
499 | + $mimetype = get_post_mime_type( $question_media ); |
|
500 | + if( $mimetype ) { |
|
501 | + $mimetype_array = explode( '/', $mimetype); |
|
502 | + if( isset( $mimetype_array[0] ) && $mimetype_array[0] ) { |
|
503 | + $question_media_type = $mimetype_array[0]; |
|
504 | + $question_media_url = wp_get_attachment_url( $question_media ); |
|
505 | + $attachment = get_post( $question_media ); |
|
506 | + $question_media_title = $attachment->post_title; |
|
507 | + $question_media_description = $attachment->post_content; |
|
508 | + switch( $question_media_type ) { |
|
509 | + case 'image': |
|
510 | + $image_size = apply_filters( 'sensei_question_image_size', 'medium', $question_id ); |
|
511 | + $attachment_src = wp_get_attachment_image_src( $question_media, $image_size ); |
|
512 | + $question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank"><img src="' . $attachment_src[0] . '" width="' . $attachment_src[1] . '" height="' . $attachment_src[2] . '" /></a>'; |
|
513 | + break; |
|
514 | + |
|
515 | + case 'audio': |
|
516 | + $question_media_link = wp_audio_shortcode( array( 'src' => $question_media_url ) ); |
|
517 | + break; |
|
518 | + |
|
519 | + case 'video': |
|
520 | + $question_media_link = wp_video_shortcode( array( 'src' => $question_media_url ) ); |
|
521 | + break; |
|
522 | + |
|
523 | + default: |
|
524 | + $question_media_filename = basename( $question_media_url ); |
|
525 | + $question_media_link = '<a class="' . esc_attr( $question_media_type ) . '" title="' . esc_attr( $question_media_title ) . '" href="' . esc_url( $question_media_url ) . '" target="_blank">' . $question_media_filename . '</a>'; |
|
526 | + break; |
|
527 | + } |
|
528 | + } |
|
529 | + } |
|
530 | + } |
|
531 | + |
|
532 | + $output = ''; |
|
533 | + if( $question_media_link ) { |
|
553 | 534 | |
535 | + $output .= '<div class="question_media_display">'; |
|
536 | + $output .= $question_media_link; |
|
537 | + $output .= '<dl>'; |
|
554 | 538 | |
555 | - } |
|
556 | - |
|
557 | - return $output; |
|
558 | - |
|
559 | - } // end get_the_question_media |
|
560 | - |
|
539 | + if( $question_media_title ) { |
|
561 | 540 | |
562 | - /** |
|
563 | - * Output the question media |
|
564 | - * |
|
565 | - * @since 1.9.0 |
|
566 | - * @param string $question_id |
|
567 | - */ |
|
568 | - public static function the_question_media( $question_id ){ |
|
541 | + $output .= '<dt>'. $question_media_title. '</dt>'; |
|
569 | 542 | |
570 | - echo self::get_the_question_media( $question_id ); |
|
543 | + } |
|
571 | 544 | |
572 | - } |
|
545 | + if( $question_media_description ) { |
|
573 | 546 | |
574 | - /** |
|
575 | - * Output a special field for the question needed for question submission. |
|
576 | - * |
|
577 | - * @since 1.9.0 |
|
578 | - * |
|
579 | - * @param $question_id |
|
580 | - */ |
|
581 | - public static function the_question_hidden_fields( $question_id ){ |
|
582 | - ?> |
|
547 | + $output .= '<dd>' . $question_media_description . '</dd>'; |
|
548 | + |
|
549 | + } |
|
550 | + |
|
551 | + $output .= '</dl>'; |
|
552 | + $output .= '</div>'; |
|
553 | + |
|
554 | + |
|
555 | + } |
|
556 | + |
|
557 | + return $output; |
|
558 | + |
|
559 | + } // end get_the_question_media |
|
560 | + |
|
561 | + |
|
562 | + /** |
|
563 | + * Output the question media |
|
564 | + * |
|
565 | + * @since 1.9.0 |
|
566 | + * @param string $question_id |
|
567 | + */ |
|
568 | + public static function the_question_media( $question_id ){ |
|
569 | + |
|
570 | + echo self::get_the_question_media( $question_id ); |
|
571 | + |
|
572 | + } |
|
573 | + |
|
574 | + /** |
|
575 | + * Output a special field for the question needed for question submission. |
|
576 | + * |
|
577 | + * @since 1.9.0 |
|
578 | + * |
|
579 | + * @param $question_id |
|
580 | + */ |
|
581 | + public static function the_question_hidden_fields( $question_id ){ |
|
582 | + ?> |
|
583 | 583 | |
584 | 584 | <input type="hidden" name="question_id_<?php $question_id;?>" value="<?php $question_id;?>" /> |
585 | 585 | <input type="hidden" name="questions_asked[]" value="<?php esc_attr_e( $question_id ); ?>" /> |
586 | 586 | |
587 | 587 | <?php |
588 | - } |
|
588 | + } |
|
589 | 589 | |
590 | - /** |
|
591 | - * This function can only be run withing the single quiz question loop |
|
592 | - * |
|
593 | - * @since 1.9.0 |
|
594 | - * @param $question_id |
|
595 | - */ |
|
596 | - public static function answer_feedback_notes( $question_id ){ |
|
590 | + /** |
|
591 | + * This function can only be run withing the single quiz question loop |
|
592 | + * |
|
593 | + * @since 1.9.0 |
|
594 | + * @param $question_id |
|
595 | + */ |
|
596 | + public static function answer_feedback_notes( $question_id ){ |
|
597 | 597 | |
598 | - //IDS |
|
599 | - $quiz_id = get_the_ID(); |
|
600 | - $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
598 | + //IDS |
|
599 | + $quiz_id = get_the_ID(); |
|
600 | + $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
601 | 601 | |
602 | - // Data to check before showing feedback |
|
603 | - $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, get_current_user_id() ); |
|
604 | - $user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() ); |
|
605 | - $not_empty_user_quiz_grade = !empty( $user_quiz_grade ); |
|
606 | - $reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id ); |
|
607 | - $lesson_completed = Sensei_Utils::user_completed_lesson( $lesson_id ); |
|
608 | - $quiz_grade_type = get_post_meta( $quiz_id , '_quiz_grade_type', true ); |
|
602 | + // Data to check before showing feedback |
|
603 | + $user_lesson_status = Sensei_Utils::user_lesson_status( $lesson_id, get_current_user_id() ); |
|
604 | + $user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() ); |
|
605 | + $not_empty_user_quiz_grade = !empty( $user_quiz_grade ); |
|
606 | + $reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id ); |
|
607 | + $lesson_completed = Sensei_Utils::user_completed_lesson( $lesson_id ); |
|
608 | + $quiz_grade_type = get_post_meta( $quiz_id , '_quiz_grade_type', true ); |
|
609 | 609 | |
610 | - if( ( $lesson_completed && $not_empty_user_quiz_grade ) |
|
611 | - || ( $lesson_completed && ! $reset_quiz_allowed && 'auto' == $quiz_grade_type ) |
|
612 | - || ( 'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $not_empty_user_quiz_grade ) ) { |
|
610 | + if( ( $lesson_completed && $not_empty_user_quiz_grade ) |
|
611 | + || ( $lesson_completed && ! $reset_quiz_allowed && 'auto' == $quiz_grade_type ) |
|
612 | + || ( 'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $not_empty_user_quiz_grade ) ) { |
|
613 | 613 | |
614 | - $answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, get_current_user_id() ); |
|
614 | + $answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, get_current_user_id() ); |
|
615 | 615 | |
616 | - if( $answer_notes ) { ?> |
|
616 | + if( $answer_notes ) { ?> |
|
617 | 617 | |
618 | 618 | <div class="sensei-message info info-special answer-feedback"> |
619 | 619 | |
620 | 620 | <?php |
621 | 621 | |
622 | - /** |
|
623 | - * Filter the answer feedback |
|
624 | - * Since 1.9.0 |
|
625 | - * |
|
626 | - * @param string $answer_notes |
|
627 | - * @param string $question_id |
|
628 | - * @param string $lesson_id |
|
629 | - */ |
|
630 | - echo apply_filters( 'sensei_question_answer_notes', $answer_notes, $question_id, $lesson_id ); |
|
622 | + /** |
|
623 | + * Filter the answer feedback |
|
624 | + * Since 1.9.0 |
|
625 | + * |
|
626 | + * @param string $answer_notes |
|
627 | + * @param string $question_id |
|
628 | + * @param string $lesson_id |
|
629 | + */ |
|
630 | + echo apply_filters( 'sensei_question_answer_notes', $answer_notes, $question_id, $lesson_id ); |
|
631 | 631 | |
632 | - ?> |
|
632 | + ?> |
|
633 | 633 | |
634 | 634 | </div> |
635 | 635 | |
636 | 636 | <?php } |
637 | 637 | |
638 | - }// end if we can show answer feedback |
|
638 | + }// end if we can show answer feedback |
|
639 | 639 | |
640 | - }// end answer_feedback_notes |
|
640 | + }// end answer_feedback_notes |
|
641 | 641 | |
642 | - /** |
|
643 | - * This function has to be run inside the quiz question loop on the single quiz page. |
|
644 | - * |
|
645 | - * |
|
646 | - * @since 1.9.0 |
|
647 | - * @param string $question_id |
|
648 | - */ |
|
649 | - public static function the_answer_result_indication( $question_id ){ |
|
642 | + /** |
|
643 | + * This function has to be run inside the quiz question loop on the single quiz page. |
|
644 | + * |
|
645 | + * |
|
646 | + * @since 1.9.0 |
|
647 | + * @param string $question_id |
|
648 | + */ |
|
649 | + public static function the_answer_result_indication( $question_id ){ |
|
650 | 650 | |
651 | - global $post, $current_user, $sensei_question_loop; |
|
651 | + global $post, $current_user, $sensei_question_loop; |
|
652 | 652 | |
653 | - // Post Data |
|
654 | - $quiz_id = $sensei_question_loop['quiz_id']; |
|
655 | - $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
656 | - $question_item = $sensei_question_loop['current_question']; |
|
653 | + // Post Data |
|
654 | + $quiz_id = $sensei_question_loop['quiz_id']; |
|
655 | + $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
656 | + $question_item = $sensei_question_loop['current_question']; |
|
657 | 657 | |
658 | - // Setup variable needed to determine if the message should show and what it should show |
|
659 | - $user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() ); |
|
660 | - $lesson_complete = Sensei_Utils::user_completed_lesson( $lesson_id, get_current_user_id() ); |
|
661 | - $reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id ); |
|
662 | - $quiz_grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true ); |
|
658 | + // Setup variable needed to determine if the message should show and what it should show |
|
659 | + $user_quiz_grade = Sensei_Quiz::get_user_quiz_grade( $lesson_id, get_current_user_id() ); |
|
660 | + $lesson_complete = Sensei_Utils::user_completed_lesson( $lesson_id, get_current_user_id() ); |
|
661 | + $reset_quiz_allowed = Sensei_Quiz::is_reset_allowed( $lesson_id ); |
|
662 | + $quiz_grade_type = get_post_meta( $quiz_id, '_quiz_grade_type', true ); |
|
663 | 663 | |
664 | - // retrieve the question total grade |
|
665 | - $question_grade = Sensei()->question->get_question_grade( $question_id ); |
|
664 | + // retrieve the question total grade |
|
665 | + $question_grade = Sensei()->question->get_question_grade( $question_id ); |
|
666 | 666 | |
667 | - // retrieve grade the user achieved |
|
668 | - $user_question_grade = Sensei()->quiz->get_user_question_grade( $lesson_id, $question_id, get_current_user_id() ); |
|
667 | + // retrieve grade the user achieved |
|
668 | + $user_question_grade = Sensei()->quiz->get_user_question_grade( $lesson_id, $question_id, get_current_user_id() ); |
|
669 | 669 | |
670 | - // Question ID |
|
671 | - $question_id = $question_item->ID; |
|
670 | + // Question ID |
|
671 | + $question_id = $question_item->ID; |
|
672 | 672 | |
673 | - // conditions to check |
|
674 | - $completed_with_valid_grade = $lesson_complete && $user_quiz_grade != '' ; |
|
675 | - $completed_with_valid_grade_and_reset_not_allowed = $lesson_complete && $user_quiz_grade != '' && ! $reset_quiz_allowed ; |
|
676 | - $grade_type_auto_a_valid_grade_and_reset_not_allowed = 'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $user_quiz_grade != '' ; |
|
673 | + // conditions to check |
|
674 | + $completed_with_valid_grade = $lesson_complete && $user_quiz_grade != '' ; |
|
675 | + $completed_with_valid_grade_and_reset_not_allowed = $lesson_complete && $user_quiz_grade != '' && ! $reset_quiz_allowed ; |
|
676 | + $grade_type_auto_a_valid_grade_and_reset_not_allowed = 'auto' == $quiz_grade_type && ! $reset_quiz_allowed && $user_quiz_grade != '' ; |
|
677 | 677 | |
678 | - if ( $completed_with_valid_grade |
|
679 | - || $completed_with_valid_grade_and_reset_not_allowed |
|
680 | - || $grade_type_auto_a_valid_grade_and_reset_not_allowed ) { |
|
678 | + if ( $completed_with_valid_grade |
|
679 | + || $completed_with_valid_grade_and_reset_not_allowed |
|
680 | + || $grade_type_auto_a_valid_grade_and_reset_not_allowed ) { |
|
681 | 681 | |
682 | - $user_correct = false; |
|
683 | - $answer_message = __( 'Incorrect', 'woothemes-sensei' ); |
|
684 | - $answer_message_class = 'user_wrong'; |
|
685 | - // For zero grade mark as 'correct' but add no classes |
|
686 | - if ( 0 == $question_grade ) { |
|
682 | + $user_correct = false; |
|
683 | + $answer_message = __( 'Incorrect', 'woothemes-sensei' ); |
|
684 | + $answer_message_class = 'user_wrong'; |
|
685 | + // For zero grade mark as 'correct' but add no classes |
|
686 | + if ( 0 == $question_grade ) { |
|
687 | 687 | |
688 | - $user_correct = true; |
|
689 | - $answer_message = ''; |
|
690 | - $answer_message_class = ''; |
|
688 | + $user_correct = true; |
|
689 | + $answer_message = ''; |
|
690 | + $answer_message_class = ''; |
|
691 | 691 | |
692 | - } else if( $user_question_grade > 0 ) { |
|
692 | + } else if( $user_question_grade > 0 ) { |
|
693 | 693 | |
694 | - $user_correct = true; |
|
695 | - $answer_message = sprintf( __( 'Grade: %d', 'woothemes-sensei' ), $user_question_grade ); |
|
696 | - $answer_message_class = 'user_right'; |
|
694 | + $user_correct = true; |
|
695 | + $answer_message = sprintf( __( 'Grade: %d', 'woothemes-sensei' ), $user_question_grade ); |
|
696 | + $answer_message_class = 'user_right'; |
|
697 | 697 | |
698 | - } |
|
698 | + } |
|
699 | 699 | |
700 | - // attach the correct answer if the question is auto gradable and user got it wrong |
|
701 | - if( !$reset_quiz_allowed && !$user_correct ){ |
|
700 | + // attach the correct answer if the question is auto gradable and user got it wrong |
|
701 | + if( !$reset_quiz_allowed && !$user_correct ){ |
|
702 | 702 | |
703 | - $answer_message .= ' - '. __('Right Answer:','woothemes-sensei') . ' ' . self::get_correct_answer( $question_item->ID ); |
|
703 | + $answer_message .= ' - '. __('Right Answer:','woothemes-sensei') . ' ' . self::get_correct_answer( $question_item->ID ); |
|
704 | 704 | |
705 | - } |
|
705 | + } |
|
706 | 706 | |
707 | - // answer feedback |
|
708 | - $answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, $current_user->ID ); |
|
709 | - if( $answer_notes ) { |
|
710 | - $answer_message_class .= ' has_notes'; |
|
711 | - } |
|
712 | - ?> |
|
707 | + // answer feedback |
|
708 | + $answer_notes = Sensei()->quiz->get_user_question_feedback( $lesson_id, $question_id, $current_user->ID ); |
|
709 | + if( $answer_notes ) { |
|
710 | + $answer_message_class .= ' has_notes'; |
|
711 | + } |
|
712 | + ?> |
|
713 | 713 | |
714 | 714 | <div class="answer_message <?php esc_attr_e( $answer_message_class ); ?>"> |
715 | 715 | |
@@ -719,387 +719,387 @@ discard block |
||
719 | 719 | |
720 | 720 | <?php |
721 | 721 | |
722 | - } // end if user can see all the goodies |
|
723 | - |
|
724 | - }// end the_answer_result_indication |
|
725 | - |
|
726 | - /** |
|
727 | - * Generate the question template data and return it as an array. |
|
728 | - * |
|
729 | - * @since 1.9.0 |
|
730 | - * |
|
731 | - * @param string $question_id |
|
732 | - * @param $quiz_id |
|
733 | - * @return array $question_data |
|
734 | - */ |
|
735 | - public static function get_template_data( $question_id, $quiz_id ){ |
|
736 | - |
|
737 | - $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
738 | - |
|
739 | - $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true ); |
|
740 | - //backwards compatibility |
|
741 | - if( 'on' == $reset_allowed ) { |
|
742 | - $reset_allowed = 1; |
|
743 | - } |
|
744 | - |
|
745 | - // Check again that the lesson is complete |
|
746 | - $user_lesson_end = Sensei_Utils::user_completed_lesson( Sensei()->quiz->get_lesson_id( $quiz_id), get_current_user_id() ); |
|
747 | - $user_lesson_complete = false; |
|
748 | - if ( $user_lesson_end ) { |
|
749 | - $user_lesson_complete = true; |
|
750 | - } |
|
751 | - |
|
752 | - //setup the question data |
|
753 | - $data[ 'ID' ] = $question_id; |
|
754 | - $data[ 'title' ] = get_the_title( $question_id ); |
|
755 | - $data[ 'content' ] = get_post( $question_id )->post_content; |
|
756 | - $data[ 'quiz_id' ] = $quiz_id; |
|
757 | - $data[ 'lesson_id' ] = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
758 | - $data[ 'type' ] = Sensei()->question->get_question_type( $question_id ); |
|
759 | - $data[ 'question_grade' ] = Sensei()->question->get_question_grade( $question_id ); |
|
760 | - $data[ 'user_question_grade' ] = Sensei()->quiz->get_user_question_grade( $lesson_id, $question_id , get_current_user_id()); |
|
761 | - $data[ 'question_right_answer' ] = get_post_meta( $question_id , '_question_right_answer', true ); |
|
762 | - $data[ 'question_wrong_answers' ] = get_post_meta( $question_id , '_question_wrong_answers', true ); |
|
763 | - $data[ 'user_answer_entry' ] = Sensei()->quiz->get_user_question_answer( $lesson_id, $question_id , get_current_user_id() ); |
|
764 | - $data[ 'lesson_completed' ] = Sensei_Utils::user_completed_course( $lesson_id, get_current_user_id( ) ); |
|
765 | - $data[ 'quiz_grade_type' ] = get_post_meta( $quiz_id , '_quiz_grade_type', true ); |
|
766 | - $data[ 'reset_quiz_allowed' ] = $reset_allowed; |
|
767 | - $data[ 'lesson_complete' ] = $user_lesson_complete; |
|
768 | - |
|
769 | - /** |
|
770 | - * Filter the question template data. This filter fires in |
|
771 | - * the get_template_data function |
|
772 | - * |
|
773 | - * @hooked self::boolean_load_question_data |
|
774 | - * |
|
775 | - * @since 1.9.0 |
|
776 | - * |
|
777 | - * @param array $data |
|
778 | - * @param string $question_id |
|
779 | - * @param string $quiz_id |
|
780 | - */ |
|
781 | - return apply_filters( 'sensei_get_question_template_data', $data, $question_id, $quiz_id ); |
|
722 | + } // end if user can see all the goodies |
|
782 | 723 | |
783 | - } |
|
724 | + }// end the_answer_result_indication |
|
784 | 725 | |
785 | - /** |
|
786 | - * Load multiple choice question data on the sensei_get_question_template_data |
|
787 | - * filter. |
|
788 | - * |
|
789 | - * @since 1.9.0 |
|
790 | - * |
|
791 | - * @param $question_data |
|
792 | - * @param $question_id |
|
793 | - * @param $quiz_id |
|
794 | - * |
|
795 | - * @return array() |
|
796 | - */ |
|
797 | - public static function file_upload_load_question_data ( $question_data, $question_id, $quiz_id ){ |
|
726 | + /** |
|
727 | + * Generate the question template data and return it as an array. |
|
728 | + * |
|
729 | + * @since 1.9.0 |
|
730 | + * |
|
731 | + * @param string $question_id |
|
732 | + * @param $quiz_id |
|
733 | + * @return array $question_data |
|
734 | + */ |
|
735 | + public static function get_template_data( $question_id, $quiz_id ){ |
|
798 | 736 | |
737 | + $lesson_id = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
799 | 738 | |
800 | - if( 'file-upload' == Sensei()->question->get_question_type( $question_id ) ) { |
|
739 | + $reset_allowed = get_post_meta( $quiz_id, '_enable_quiz_reset', true ); |
|
740 | + //backwards compatibility |
|
741 | + if( 'on' == $reset_allowed ) { |
|
742 | + $reset_allowed = 1; |
|
743 | + } |
|
801 | 744 | |
802 | - // Get uploaded file |
|
803 | - $attachment_id = $question_data[ 'user_answer_entry' ]; |
|
804 | - $answer_media_url = $answer_media_filename = ''; |
|
745 | + // Check again that the lesson is complete |
|
746 | + $user_lesson_end = Sensei_Utils::user_completed_lesson( Sensei()->quiz->get_lesson_id( $quiz_id), get_current_user_id() ); |
|
747 | + $user_lesson_complete = false; |
|
748 | + if ( $user_lesson_end ) { |
|
749 | + $user_lesson_complete = true; |
|
750 | + } |
|
805 | 751 | |
752 | + //setup the question data |
|
753 | + $data[ 'ID' ] = $question_id; |
|
754 | + $data[ 'title' ] = get_the_title( $question_id ); |
|
755 | + $data[ 'content' ] = get_post( $question_id )->post_content; |
|
756 | + $data[ 'quiz_id' ] = $quiz_id; |
|
757 | + $data[ 'lesson_id' ] = Sensei()->quiz->get_lesson_id( $quiz_id ); |
|
758 | + $data[ 'type' ] = Sensei()->question->get_question_type( $question_id ); |
|
759 | + $data[ 'question_grade' ] = Sensei()->question->get_question_grade( $question_id ); |
|
760 | + $data[ 'user_question_grade' ] = Sensei()->quiz->get_user_question_grade( $lesson_id, $question_id , get_current_user_id()); |
|
761 | + $data[ 'question_right_answer' ] = get_post_meta( $question_id , '_question_right_answer', true ); |
|
762 | + $data[ 'question_wrong_answers' ] = get_post_meta( $question_id , '_question_wrong_answers', true ); |
|
763 | + $data[ 'user_answer_entry' ] = Sensei()->quiz->get_user_question_answer( $lesson_id, $question_id , get_current_user_id() ); |
|
764 | + $data[ 'lesson_completed' ] = Sensei_Utils::user_completed_course( $lesson_id, get_current_user_id( ) ); |
|
765 | + $data[ 'quiz_grade_type' ] = get_post_meta( $quiz_id , '_quiz_grade_type', true ); |
|
766 | + $data[ 'reset_quiz_allowed' ] = $reset_allowed; |
|
767 | + $data[ 'lesson_complete' ] = $user_lesson_complete; |
|
768 | + |
|
769 | + /** |
|
770 | + * Filter the question template data. This filter fires in |
|
771 | + * the get_template_data function |
|
772 | + * |
|
773 | + * @hooked self::boolean_load_question_data |
|
774 | + * |
|
775 | + * @since 1.9.0 |
|
776 | + * |
|
777 | + * @param array $data |
|
778 | + * @param string $question_id |
|
779 | + * @param string $quiz_id |
|
780 | + */ |
|
781 | + return apply_filters( 'sensei_get_question_template_data', $data, $question_id, $quiz_id ); |
|
806 | 782 | |
807 | - $question_helptext = ''; |
|
808 | - if( isset( $question_data['question_wrong_answers'][0] ) ) { |
|
783 | + } |
|
809 | 784 | |
810 | - $question_helptext = $question_data['question_wrong_answers'][0]; |
|
785 | + /** |
|
786 | + * Load multiple choice question data on the sensei_get_question_template_data |
|
787 | + * filter. |
|
788 | + * |
|
789 | + * @since 1.9.0 |
|
790 | + * |
|
791 | + * @param $question_data |
|
792 | + * @param $question_id |
|
793 | + * @param $quiz_id |
|
794 | + * |
|
795 | + * @return array() |
|
796 | + */ |
|
797 | + public static function file_upload_load_question_data ( $question_data, $question_id, $quiz_id ){ |
|
811 | 798 | |
812 | - } |
|
813 | 799 | |
800 | + if( 'file-upload' == Sensei()->question->get_question_type( $question_id ) ) { |
|
814 | 801 | |
815 | - if( 0 < intval( $attachment_id ) ) { |
|
802 | + // Get uploaded file |
|
803 | + $attachment_id = $question_data[ 'user_answer_entry' ]; |
|
804 | + $answer_media_url = $answer_media_filename = ''; |
|
816 | 805 | |
817 | - $answer_media_url = wp_get_attachment_url( $attachment_id ); |
|
818 | - $answer_media_filename = basename( $answer_media_url ); |
|
819 | 806 | |
820 | - } |
|
807 | + $question_helptext = ''; |
|
808 | + if( isset( $question_data['question_wrong_answers'][0] ) ) { |
|
821 | 809 | |
810 | + $question_helptext = $question_data['question_wrong_answers'][0]; |
|
822 | 811 | |
823 | - // Get max upload file size, formatted for display |
|
824 | - // Code copied from wp-admin/includes/media.php:1515 |
|
825 | - $upload_size_unit = $max_upload_size = wp_max_upload_size(); |
|
826 | - $sizes = array( 'KB', 'MB', 'GB' ); |
|
827 | - for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) { |
|
828 | - $upload_size_unit /= 1024; |
|
829 | - } |
|
830 | - if ( $u < 0 ) { |
|
812 | + } |
|
831 | 813 | |
832 | - $upload_size_unit = 0; |
|
833 | - $u = 0; |
|
834 | 814 | |
835 | - } else { |
|
815 | + if( 0 < intval( $attachment_id ) ) { |
|
836 | 816 | |
837 | - $upload_size_unit = (int) $upload_size_unit; |
|
817 | + $answer_media_url = wp_get_attachment_url( $attachment_id ); |
|
818 | + $answer_media_filename = basename( $answer_media_url ); |
|
838 | 819 | |
839 | - } |
|
840 | - $max_upload_size = sprintf( __( 'Maximum upload file size: %d%s' ), esc_html( $upload_size_unit ), esc_html( $sizes[ $u ] ) ); |
|
820 | + } |
|
841 | 821 | |
842 | - // Assemble all the data needed by the file upload template |
|
843 | - $question_data[ 'answer_media_url' ] = $answer_media_url; |
|
844 | - $question_data[ 'answer_media_filename' ] = $answer_media_filename; |
|
845 | - $question_data[ 'max_upload_size' ] = $max_upload_size; |
|
846 | 822 | |
847 | - $question_data[ 'question_helptext' ] = $question_helptext; |
|
823 | + // Get max upload file size, formatted for display |
|
824 | + // Code copied from wp-admin/includes/media.php:1515 |
|
825 | + $upload_size_unit = $max_upload_size = wp_max_upload_size(); |
|
826 | + $sizes = array( 'KB', 'MB', 'GB' ); |
|
827 | + for ( $u = -1; $upload_size_unit > 1024 && $u < count( $sizes ) - 1; $u++ ) { |
|
828 | + $upload_size_unit /= 1024; |
|
829 | + } |
|
830 | + if ( $u < 0 ) { |
|
848 | 831 | |
849 | - }// end if is file upload type |
|
832 | + $upload_size_unit = 0; |
|
833 | + $u = 0; |
|
850 | 834 | |
851 | - return $question_data; |
|
835 | + } else { |
|
852 | 836 | |
853 | - }// end file_upload_load_question_data |
|
837 | + $upload_size_unit = (int) $upload_size_unit; |
|
854 | 838 | |
855 | - /** |
|
856 | - * Load multiple choice question data on the sensei_get_question_template_data |
|
857 | - * filter. |
|
858 | - * |
|
859 | - * @since 1.9.0 |
|
860 | - * |
|
861 | - * @param $question_data |
|
862 | - * @param $question_id |
|
863 | - * @param $quiz_id |
|
864 | - * |
|
865 | - * @return array() |
|
866 | - */ |
|
867 | - public static function multiple_choice_load_question_data( $question_data, $question_id, $quiz_id ){ |
|
839 | + } |
|
840 | + $max_upload_size = sprintf( __( 'Maximum upload file size: %d%s' ), esc_html( $upload_size_unit ), esc_html( $sizes[ $u ] ) ); |
|
868 | 841 | |
869 | - if( 'multiple-choice' == Sensei()->question->get_question_type( $question_id ) ) { |
|
842 | + // Assemble all the data needed by the file upload template |
|
843 | + $question_data[ 'answer_media_url' ] = $answer_media_url; |
|
844 | + $question_data[ 'answer_media_filename' ] = $answer_media_filename; |
|
845 | + $question_data[ 'max_upload_size' ] = $max_upload_size; |
|
870 | 846 | |
847 | + $question_data[ 'question_helptext' ] = $question_helptext; |
|
871 | 848 | |
872 | - $answer_type = 'radio'; |
|
873 | - if ( is_array( $question_data[ 'question_right_answer' ] ) && ( 1 < count( $question_data[ 'question_right_answer' ] ) ) ) { |
|
849 | + }// end if is file upload type |
|
874 | 850 | |
875 | - $answer_type = 'checkbox'; |
|
851 | + return $question_data; |
|
876 | 852 | |
877 | - } |
|
853 | + }// end file_upload_load_question_data |
|
878 | 854 | |
879 | - // Merge right and wrong answers |
|
880 | - if ( is_array( $question_data[ 'question_right_answer' ] ) ) { |
|
855 | + /** |
|
856 | + * Load multiple choice question data on the sensei_get_question_template_data |
|
857 | + * filter. |
|
858 | + * |
|
859 | + * @since 1.9.0 |
|
860 | + * |
|
861 | + * @param $question_data |
|
862 | + * @param $question_id |
|
863 | + * @param $quiz_id |
|
864 | + * |
|
865 | + * @return array() |
|
866 | + */ |
|
867 | + public static function multiple_choice_load_question_data( $question_data, $question_id, $quiz_id ){ |
|
881 | 868 | |
882 | - $merged_options = array_merge( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] ); |
|
869 | + if( 'multiple-choice' == Sensei()->question->get_question_type( $question_id ) ) { |
|
883 | 870 | |
884 | - } else { |
|
885 | 871 | |
886 | - array_push( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] ); |
|
887 | - $merged_options = $question_data[ 'question_wrong_answers' ]; |
|
872 | + $answer_type = 'radio'; |
|
873 | + if ( is_array( $question_data[ 'question_right_answer' ] ) && ( 1 < count( $question_data[ 'question_right_answer' ] ) ) ) { |
|
888 | 874 | |
889 | - } |
|
875 | + $answer_type = 'checkbox'; |
|
890 | 876 | |
891 | - // Setup answer options array. |
|
892 | - $question_answers_options = array(); |
|
893 | - $count = 0; |
|
877 | + } |
|
894 | 878 | |
895 | - foreach( $merged_options as $answer ) { |
|
879 | + // Merge right and wrong answers |
|
880 | + if ( is_array( $question_data[ 'question_right_answer' ] ) ) { |
|
896 | 881 | |
897 | - $count++; |
|
898 | - $question_option = array(); |
|
882 | + $merged_options = array_merge( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] ); |
|
899 | 883 | |
900 | - if( ( $question_data[ 'lesson_completed' ] && $question_data[ 'user_quiz_grade' ] != '' ) |
|
901 | - || ( $question_data[ 'lesson_completed' ] && ! $question_data[ 'reset_quiz_allowed' ] && $question_data[ 'user_quiz_grade' ] != '' ) |
|
902 | - || ( 'auto' == $question_data[ 'quiz_grade_type' ] && ! $question_data[ 'reset_quiz_allowed' ] && ! empty( $question_data[ 'user_quiz_grade' ] ) ) ) { |
|
884 | + } else { |
|
903 | 885 | |
904 | - $user_correct = false; |
|
886 | + array_push( $question_data[ 'question_wrong_answers' ], $question_data[ 'question_right_answer' ] ); |
|
887 | + $merged_options = $question_data[ 'question_wrong_answers' ]; |
|
905 | 888 | |
889 | + } |
|
906 | 890 | |
907 | - // For zero grade mark as 'correct' but add no classes |
|
908 | - if ( 0 == $question_data[ 'question_grade' ] ) { |
|
891 | + // Setup answer options array. |
|
892 | + $question_answers_options = array(); |
|
893 | + $count = 0; |
|
909 | 894 | |
910 | - $user_correct = true; |
|
895 | + foreach( $merged_options as $answer ) { |
|
911 | 896 | |
912 | - } else if( $question_data[ 'user_question_grade' ] > 0 ) { |
|
897 | + $count++; |
|
898 | + $question_option = array(); |
|
913 | 899 | |
914 | - $user_correct = true; |
|
900 | + if( ( $question_data[ 'lesson_completed' ] && $question_data[ 'user_quiz_grade' ] != '' ) |
|
901 | + || ( $question_data[ 'lesson_completed' ] && ! $question_data[ 'reset_quiz_allowed' ] && $question_data[ 'user_quiz_grade' ] != '' ) |
|
902 | + || ( 'auto' == $question_data[ 'quiz_grade_type' ] && ! $question_data[ 'reset_quiz_allowed' ] && ! empty( $question_data[ 'user_quiz_grade' ] ) ) ) { |
|
915 | 903 | |
916 | - } |
|
904 | + $user_correct = false; |
|
917 | 905 | |
918 | - } |
|
919 | 906 | |
920 | - // setup the option specific classes |
|
921 | - $answer_class = ''; |
|
922 | - if( isset( $user_correct ) && 0 < $question_data[ 'question_grade' ] ) { |
|
923 | - if ( is_array( $question_data['question_right_answer'] ) && in_array($answer, $question_data['question_right_answer']) ) { |
|
907 | + // For zero grade mark as 'correct' but add no classes |
|
908 | + if ( 0 == $question_data[ 'question_grade' ] ) { |
|
924 | 909 | |
925 | - $answer_class .= ' right_answer'; |
|
910 | + $user_correct = true; |
|
926 | 911 | |
927 | - } elseif( !is_array($question_data['question_right_answer']) && $question_data['question_right_answer'] == $answer ) { |
|
912 | + } else if( $question_data[ 'user_question_grade' ] > 0 ) { |
|
928 | 913 | |
929 | - $answer_class .= ' right_answer'; |
|
914 | + $user_correct = true; |
|
930 | 915 | |
931 | - } elseif( ( is_array( $question_data['user_answer_entry'] ) && in_array($answer, $question_data['user_answer_entry'] ) ) |
|
932 | - || ( ! $question_data['user_answer_entry'] && $question_data['user_answer_entry'] == $answer ) ) { |
|
916 | + } |
|
933 | 917 | |
934 | - $answer_class = 'user_wrong'; |
|
935 | - if( $user_correct ) { |
|
918 | + } |
|
936 | 919 | |
937 | - $answer_class = 'user_right'; |
|
920 | + // setup the option specific classes |
|
921 | + $answer_class = ''; |
|
922 | + if( isset( $user_correct ) && 0 < $question_data[ 'question_grade' ] ) { |
|
923 | + if ( is_array( $question_data['question_right_answer'] ) && in_array($answer, $question_data['question_right_answer']) ) { |
|
938 | 924 | |
939 | - } |
|
925 | + $answer_class .= ' right_answer'; |
|
940 | 926 | |
941 | - } |
|
927 | + } elseif( !is_array($question_data['question_right_answer']) && $question_data['question_right_answer'] == $answer ) { |
|
942 | 928 | |
943 | - } |
|
929 | + $answer_class .= ' right_answer'; |
|
944 | 930 | |
945 | - // determine if the current option must be checked |
|
946 | - $checked = ''; |
|
947 | - if ( isset( $question_data['user_answer_entry'] ) && 0 < count( $question_data['user_answer_entry'] ) ) { |
|
948 | - if ( is_array( $question_data['user_answer_entry'] ) && in_array( $answer, $question_data['user_answer_entry'] ) ) { |
|
931 | + } elseif( ( is_array( $question_data['user_answer_entry'] ) && in_array($answer, $question_data['user_answer_entry'] ) ) |
|
932 | + || ( ! $question_data['user_answer_entry'] && $question_data['user_answer_entry'] == $answer ) ) { |
|
949 | 933 | |
950 | - $checked = 'checked="checked"'; |
|
934 | + $answer_class = 'user_wrong'; |
|
935 | + if( $user_correct ) { |
|
951 | 936 | |
952 | - } elseif ( !is_array( $question_data['user_answer_entry'] ) ) { |
|
937 | + $answer_class = 'user_right'; |
|
953 | 938 | |
954 | - $checked = checked( $answer, $question_data['user_answer_entry'] , false ); |
|
939 | + } |
|
955 | 940 | |
956 | - } |
|
941 | + } |
|
957 | 942 | |
958 | - } // End If Statement |
|
943 | + } |
|
959 | 944 | |
960 | - //Load the answer option data |
|
961 | - $question_option[ 'ID' ] = Sensei()->lesson->get_answer_id( $answer ); |
|
962 | - $question_option[ 'answer' ] = $answer; |
|
963 | - $question_option[ 'option_class'] = $answer_class; |
|
964 | - $question_option[ 'checked'] = $checked; |
|
965 | - $question_option[ 'count' ] = $count; |
|
966 | - $question_option[ 'type' ] = $answer_type; |
|
945 | + // determine if the current option must be checked |
|
946 | + $checked = ''; |
|
947 | + if ( isset( $question_data['user_answer_entry'] ) && 0 < count( $question_data['user_answer_entry'] ) ) { |
|
948 | + if ( is_array( $question_data['user_answer_entry'] ) && in_array( $answer, $question_data['user_answer_entry'] ) ) { |
|
967 | 949 | |
968 | - // add the speci fic option to the list of options for this question |
|
969 | - $question_answers_options[] = $question_option; |
|
950 | + $checked = 'checked="checked"'; |
|
970 | 951 | |
971 | - } // end for each option |
|
952 | + } elseif ( !is_array( $question_data['user_answer_entry'] ) ) { |
|
972 | 953 | |
954 | + $checked = checked( $answer, $question_data['user_answer_entry'] , false ); |
|
973 | 955 | |
974 | - // Shuffle the array depending on the settings |
|
975 | - $answer_options_sorted = array(); |
|
976 | - $random_order = get_post_meta( $question_data['ID'], '_random_order', true ); |
|
977 | - if( $random_order && $random_order == 'yes' ) { |
|
956 | + } |
|
978 | 957 | |
979 | - $answer_options_sorted = $question_answers_options; |
|
980 | - shuffle( $answer_options_sorted ); |
|
958 | + } // End If Statement |
|
981 | 959 | |
982 | - } else { |
|
960 | + //Load the answer option data |
|
961 | + $question_option[ 'ID' ] = Sensei()->lesson->get_answer_id( $answer ); |
|
962 | + $question_option[ 'answer' ] = $answer; |
|
963 | + $question_option[ 'option_class'] = $answer_class; |
|
964 | + $question_option[ 'checked'] = $checked; |
|
965 | + $question_option[ 'count' ] = $count; |
|
966 | + $question_option[ 'type' ] = $answer_type; |
|
983 | 967 | |
984 | - $answer_order = array(); |
|
985 | - $answer_order_string = get_post_meta( $question_data['ID'], '_answer_order', true ); |
|
986 | - if( $answer_order_string ) { |
|
968 | + // add the speci fic option to the list of options for this question |
|
969 | + $question_answers_options[] = $question_option; |
|
987 | 970 | |
988 | - $answer_order = array_filter( explode( ',', $answer_order_string ) ); |
|
989 | - if( count( $answer_order ) > 0 ) { |
|
971 | + } // end for each option |
|
990 | 972 | |
991 | - foreach( $answer_order as $answer_id ) { |
|
992 | 973 | |
993 | - if( isset( $question_answers_options[ $answer_id ] ) ) { |
|
974 | + // Shuffle the array depending on the settings |
|
975 | + $answer_options_sorted = array(); |
|
976 | + $random_order = get_post_meta( $question_data['ID'], '_random_order', true ); |
|
977 | + if( $random_order && $random_order == 'yes' ) { |
|
994 | 978 | |
995 | - $answer_options_sorted[ $answer_id ] = $question_answers_options[ $answer_id ]; |
|
996 | - unset( $question_answers_options[ $answer_id ] ); |
|
979 | + $answer_options_sorted = $question_answers_options; |
|
980 | + shuffle( $answer_options_sorted ); |
|
997 | 981 | |
998 | - } |
|
982 | + } else { |
|
999 | 983 | |
1000 | - } |
|
984 | + $answer_order = array(); |
|
985 | + $answer_order_string = get_post_meta( $question_data['ID'], '_answer_order', true ); |
|
986 | + if( $answer_order_string ) { |
|
1001 | 987 | |
1002 | - if( count( $question_answers_options ) > 0 ) { |
|
1003 | - foreach( $question_answers_options as $id => $answer ) { |
|
988 | + $answer_order = array_filter( explode( ',', $answer_order_string ) ); |
|
989 | + if( count( $answer_order ) > 0 ) { |
|
1004 | 990 | |
1005 | - $answer_options_sorted[ $id ] = $answer; |
|
991 | + foreach( $answer_order as $answer_id ) { |
|
1006 | 992 | |
1007 | - } |
|
1008 | - } |
|
993 | + if( isset( $question_answers_options[ $answer_id ] ) ) { |
|
1009 | 994 | |
1010 | - }else{ |
|
995 | + $answer_options_sorted[ $answer_id ] = $question_answers_options[ $answer_id ]; |
|
996 | + unset( $question_answers_options[ $answer_id ] ); |
|
1011 | 997 | |
1012 | - $answer_options_sorted = $question_answers_options; |
|
998 | + } |
|
1013 | 999 | |
1014 | - } |
|
1000 | + } |
|
1015 | 1001 | |
1016 | - }else{ |
|
1002 | + if( count( $question_answers_options ) > 0 ) { |
|
1003 | + foreach( $question_answers_options as $id => $answer ) { |
|
1017 | 1004 | |
1018 | - $answer_options_sorted = $question_answers_options; |
|
1005 | + $answer_options_sorted[ $id ] = $answer; |
|
1019 | 1006 | |
1020 | - } // end if $answer_order_string |
|
1007 | + } |
|
1008 | + } |
|
1021 | 1009 | |
1022 | - } // end if random order |
|
1010 | + }else{ |
|
1023 | 1011 | |
1012 | + $answer_options_sorted = $question_answers_options; |
|
1024 | 1013 | |
1025 | - // assemble and setup the data for the templates data array |
|
1026 | - $question_data[ 'answer_options' ] = $answer_options_sorted; |
|
1014 | + } |
|
1027 | 1015 | |
1028 | - } |
|
1016 | + }else{ |
|
1029 | 1017 | |
1030 | - return $question_data; |
|
1018 | + $answer_options_sorted = $question_answers_options; |
|
1031 | 1019 | |
1032 | - }// end multiple_choice_load_question_data |
|
1020 | + } // end if $answer_order_string |
|
1033 | 1021 | |
1034 | - /** |
|
1035 | - * Load the gap fill question data on the sensei_get_question_template_data |
|
1036 | - * filter. |
|
1037 | - * |
|
1038 | - * @since 1.9.0 |
|
1039 | - * |
|
1040 | - * @param $question_data |
|
1041 | - * @param $question_id |
|
1042 | - * @param $quiz_id |
|
1043 | - * |
|
1044 | - * @return array() |
|
1045 | - */ |
|
1046 | - public static function gap_fill_load_question_data( $question_data, $question_id, $quiz_id ){ |
|
1022 | + } // end if random order |
|
1047 | 1023 | |
1048 | - if( 'gap-fill' == Sensei()->question->get_question_type( $question_id ) ) { |
|
1049 | 1024 | |
1050 | - $gapfill_array = explode( '||', $question_data[ 'question_right_answer' ] ); |
|
1051 | - $question_data[ 'gapfill_pre' ] = isset( $gapfill_array[0] ) ? $gapfill_array[0] : ''; |
|
1052 | - $question_data[ 'gapfill_gap' ] = isset( $gapfill_array[1] ) ? $gapfill_array[1] : ''; |
|
1053 | - $question_data[ 'gapfill_post' ] = isset( $gapfill_array[2] ) ? $gapfill_array[2] : ''; |
|
1025 | + // assemble and setup the data for the templates data array |
|
1026 | + $question_data[ 'answer_options' ] = $answer_options_sorted; |
|
1054 | 1027 | |
1055 | - } |
|
1028 | + } |
|
1056 | 1029 | |
1057 | - return $question_data; |
|
1030 | + return $question_data; |
|
1058 | 1031 | |
1059 | - }// end gap_fill_load_question_data |
|
1032 | + }// end multiple_choice_load_question_data |
|
1033 | + |
|
1034 | + /** |
|
1035 | + * Load the gap fill question data on the sensei_get_question_template_data |
|
1036 | + * filter. |
|
1037 | + * |
|
1038 | + * @since 1.9.0 |
|
1039 | + * |
|
1040 | + * @param $question_data |
|
1041 | + * @param $question_id |
|
1042 | + * @param $quiz_id |
|
1043 | + * |
|
1044 | + * @return array() |
|
1045 | + */ |
|
1046 | + public static function gap_fill_load_question_data( $question_data, $question_id, $quiz_id ){ |
|
1047 | + |
|
1048 | + if( 'gap-fill' == Sensei()->question->get_question_type( $question_id ) ) { |
|
1049 | + |
|
1050 | + $gapfill_array = explode( '||', $question_data[ 'question_right_answer' ] ); |
|
1051 | + $question_data[ 'gapfill_pre' ] = isset( $gapfill_array[0] ) ? $gapfill_array[0] : ''; |
|
1052 | + $question_data[ 'gapfill_gap' ] = isset( $gapfill_array[1] ) ? $gapfill_array[1] : ''; |
|
1053 | + $question_data[ 'gapfill_post' ] = isset( $gapfill_array[2] ) ? $gapfill_array[2] : ''; |
|
1054 | + |
|
1055 | + } |
|
1056 | + |
|
1057 | + return $question_data; |
|
1058 | + |
|
1059 | + }// end gap_fill_load_question_data |
|
1060 | 1060 | |
1061 | 1061 | |
1062 | - /** |
|
1063 | - * Get the correct answer for a question |
|
1064 | - * |
|
1065 | - * @param $question_id |
|
1066 | - * @return string $correct_answer or empty |
|
1067 | - */ |
|
1068 | - public static function get_correct_answer( $question_id ){ |
|
1062 | + /** |
|
1063 | + * Get the correct answer for a question |
|
1064 | + * |
|
1065 | + * @param $question_id |
|
1066 | + * @return string $correct_answer or empty |
|
1067 | + */ |
|
1068 | + public static function get_correct_answer( $question_id ){ |
|
1069 | 1069 | |
1070 | - $right_answer = get_post_meta( $question_id, '_question_right_answer', true ); |
|
1071 | - $type = Sensei()->question->get_question_type( $question_id ); |
|
1072 | - $type_name = __( 'Multiple Choice', 'woothemes-sensei' ); |
|
1073 | - $grade_type = 'manual-grade'; |
|
1070 | + $right_answer = get_post_meta( $question_id, '_question_right_answer', true ); |
|
1071 | + $type = Sensei()->question->get_question_type( $question_id ); |
|
1072 | + $type_name = __( 'Multiple Choice', 'woothemes-sensei' ); |
|
1073 | + $grade_type = 'manual-grade'; |
|
1074 | 1074 | |
1075 | - if ('boolean'== $type ) { |
|
1075 | + if ('boolean'== $type ) { |
|
1076 | 1076 | |
1077 | - $right_answer = ucfirst($right_answer); |
|
1077 | + $right_answer = ucfirst($right_answer); |
|
1078 | 1078 | |
1079 | - }elseif( 'multiple-choice' == $type ) { |
|
1079 | + }elseif( 'multiple-choice' == $type ) { |
|
1080 | 1080 | |
1081 | - $right_answer = (array) $right_answer; |
|
1082 | - $right_answer = implode( ', ', $right_answer ); |
|
1081 | + $right_answer = (array) $right_answer; |
|
1082 | + $right_answer = implode( ', ', $right_answer ); |
|
1083 | 1083 | |
1084 | - }elseif( 'gap-fill' == $type ) { |
|
1084 | + }elseif( 'gap-fill' == $type ) { |
|
1085 | 1085 | |
1086 | - $right_answer_array = explode( '||', $right_answer ); |
|
1087 | - if ( isset( $right_answer_array[0] ) ) { $gapfill_pre = $right_answer_array[0]; } else { $gapfill_pre = ''; } |
|
1088 | - if ( isset( $right_answer_array[1] ) ) { $gapfill_gap = $right_answer_array[1]; } else { $gapfill_gap = ''; } |
|
1089 | - if ( isset( $right_answer_array[2] ) ) { $gapfill_post = $right_answer_array[2]; } else { $gapfill_post = ''; } |
|
1086 | + $right_answer_array = explode( '||', $right_answer ); |
|
1087 | + if ( isset( $right_answer_array[0] ) ) { $gapfill_pre = $right_answer_array[0]; } else { $gapfill_pre = ''; } |
|
1088 | + if ( isset( $right_answer_array[1] ) ) { $gapfill_gap = $right_answer_array[1]; } else { $gapfill_gap = ''; } |
|
1089 | + if ( isset( $right_answer_array[2] ) ) { $gapfill_post = $right_answer_array[2]; } else { $gapfill_post = ''; } |
|
1090 | 1090 | |
1091 | - $right_answer = $gapfill_pre . ' <span class="highlight">' . $gapfill_gap . '</span> ' . $gapfill_post; |
|
1091 | + $right_answer = $gapfill_pre . ' <span class="highlight">' . $gapfill_gap . '</span> ' . $gapfill_post; |
|
1092 | 1092 | |
1093 | - }else{ |
|
1093 | + }else{ |
|
1094 | 1094 | |
1095 | - // for non auto gradable question types no answer should be returned. |
|
1096 | - $right_answer = ''; |
|
1095 | + // for non auto gradable question types no answer should be returned. |
|
1096 | + $right_answer = ''; |
|
1097 | 1097 | |
1098 | - } |
|
1098 | + } |
|
1099 | 1099 | |
1100 | - return $right_answer; |
|
1100 | + return $right_answer; |
|
1101 | 1101 | |
1102 | - } // get_correct_answer |
|
1102 | + } // get_correct_answer |
|
1103 | 1103 | |
1104 | 1104 | } // End Class |
1105 | 1105 |
@@ -21,43 +21,43 @@ discard block |
||
21 | 21 | * @return void |
22 | 22 | */ |
23 | 23 | public function __construct () { |
24 | - parent::__construct(); // Required in extended classes. |
|
24 | + parent::__construct(); // Required in extended classes. |
|
25 | 25 | |
26 | - $this->token = 'woothemes-sensei-settings'; |
|
27 | - add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
26 | + $this->token = 'woothemes-sensei-settings'; |
|
27 | + add_action('init', array( __CLASS__, 'flush_rewrite_rules' ) ); |
|
28 | 28 | |
29 | - // Setup Admin Settings data |
|
30 | - if ( is_admin() ) { |
|
29 | + // Setup Admin Settings data |
|
30 | + if ( is_admin() ) { |
|
31 | 31 | |
32 | - $this->has_tabs = true; |
|
33 | - $this->name = __( 'Sensei Settings', 'woothemes-sensei' ); |
|
34 | - $this->menu_label = __( 'Settings', 'woothemes-sensei' ); |
|
35 | - $this->page_slug = 'woothemes-sensei-settings'; |
|
32 | + $this->has_tabs = true; |
|
33 | + $this->name = __( 'Sensei Settings', 'woothemes-sensei' ); |
|
34 | + $this->menu_label = __( 'Settings', 'woothemes-sensei' ); |
|
35 | + $this->page_slug = 'woothemes-sensei-settings'; |
|
36 | 36 | |
37 | - } // End If Statement |
|
37 | + } // End If Statement |
|
38 | 38 | |
39 | - $this->register_hook_listener(); |
|
40 | - $this->get_settings(); |
|
39 | + $this->register_hook_listener(); |
|
40 | + $this->get_settings(); |
|
41 | 41 | |
42 | 42 | } // End __construct() |
43 | 43 | |
44 | - /** |
|
45 | - * Get settings value |
|
46 | - * |
|
47 | - * @since 1.9.0 |
|
48 | - * @param string $setting_name |
|
49 | - * @return mixed |
|
50 | - */ |
|
51 | - public function get( $setting_name ){ |
|
44 | + /** |
|
45 | + * Get settings value |
|
46 | + * |
|
47 | + * @since 1.9.0 |
|
48 | + * @param string $setting_name |
|
49 | + * @return mixed |
|
50 | + */ |
|
51 | + public function get( $setting_name ){ |
|
52 | 52 | |
53 | - if( isset( $this->settings[ $setting_name ] ) ){ |
|
53 | + if( isset( $this->settings[ $setting_name ] ) ){ |
|
54 | 54 | |
55 | - return $this->settings[ $setting_name ]; |
|
55 | + return $this->settings[ $setting_name ]; |
|
56 | 56 | |
57 | - } |
|
57 | + } |
|
58 | 58 | |
59 | - return false; |
|
60 | - } |
|
59 | + return false; |
|
60 | + } |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Register the settings screen within the WordPress admin. |
@@ -145,7 +145,7 @@ discard block |
||
145 | 145 | $complete_settings = array( 'passed' => __( 'Once all the course lessons have been completed', 'woothemes-sensei' ), 'complete' => __( 'At any time (by clicking the \'Complete Course\' button)', 'woothemes-sensei' ) ); |
146 | 146 | $course_display_settings = array( 'excerpt' => __( 'Course Excerpt', 'woothemes-sensei' ), 'full' => __( 'Full Course Content', 'woothemes-sensei' ) ); |
147 | 147 | |
148 | - $fields = array(); |
|
148 | + $fields = array(); |
|
149 | 149 | |
150 | 150 | $fields['access_permission'] = array( |
151 | 151 | 'name' => __( 'Access Permissions', 'woothemes-sensei' ), |
@@ -207,9 +207,9 @@ discard block |
||
207 | 207 | 'section' => 'default-settings' |
208 | 208 | ); |
209 | 209 | |
210 | - // Course Settings |
|
210 | + // Course Settings |
|
211 | 211 | |
212 | - $fields['course_completion'] = array( |
|
212 | + $fields['course_completion'] = array( |
|
213 | 213 | 'name' => __( 'Courses are complete:', 'woothemes-sensei' ), |
214 | 214 | 'description' => __( 'This will determine when courses are marked as complete.', 'woothemes-sensei' ), |
215 | 215 | 'type' => 'select', |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | 'options' => $complete_settings |
220 | 220 | ); |
221 | 221 | |
222 | - $fields['course_author'] = array( |
|
222 | + $fields['course_author'] = array( |
|
223 | 223 | 'name' => __( 'Display Course Author', 'woothemes-sensei' ), |
224 | 224 | 'description' => __( 'Output the Course Author on Course archive and My Courses page.', 'woothemes-sensei' ), |
225 | 225 | 'type' => 'checkbox', |
@@ -447,10 +447,10 @@ discard block |
||
447 | 447 | ); |
448 | 448 | |
449 | 449 | $teacher_email_options = array( |
450 | - 'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), |
|
451 | - 'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), |
|
452 | - 'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), |
|
453 | - 'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), |
|
450 | + 'teacher-started-course' => __( 'A learner starts their course', 'woothemes-sensei' ), |
|
451 | + 'teacher-completed-course' => __( 'A learner completes their course', 'woothemes-sensei' ), |
|
452 | + 'teacher-completed-lesson' => __( 'A learner completes a lesson', 'woothemes-sensei' ), |
|
453 | + 'teacher-quiz-submitted' => __( 'A learner submits a quiz for grading', 'woothemes-sensei' ), |
|
454 | 454 | 'teacher-new-message' => __( 'A learner sends a private message to a teacher', 'woothemes-sensei' ), |
455 | 455 | ); |
456 | 456 | |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | |
560 | 560 | if ( Sensei_WC::is_woocommerce_active() ) { |
561 | 561 | // WooCommerce Settings |
562 | - $fields['woocommerce_enabled'] = array( |
|
562 | + $fields['woocommerce_enabled'] = array( |
|
563 | 563 | 'name' => __( 'Enable WooCommerce Courses', 'woothemes-sensei' ), |
564 | 564 | 'description' => __( 'Use WooCommerce to sell Courses by linking a Product to a Course.', 'woothemes-sensei' ), |
565 | 565 | 'type' => 'checkbox', |
@@ -647,14 +647,14 @@ discard block |
||
647 | 647 | $page_items[] = __( 'Select a Page:', 'woothemes-sensei' ); |
648 | 648 | |
649 | 649 | foreach ( $pages_split as $k => $v ) { |
650 | - $id = ''; |
|
651 | - // Get the ID value. |
|
652 | - preg_match( '/value="(.*?)"/i', $v, $matches ); |
|
653 | - |
|
654 | - if ( isset( $matches[1] ) ) { |
|
655 | - $id = $matches[1]; |
|
656 | - $page_items[$id] = trim( strip_tags( $v ) ); |
|
657 | - } // End If Statement |
|
650 | + $id = ''; |
|
651 | + // Get the ID value. |
|
652 | + preg_match( '/value="(.*?)"/i', $v, $matches ); |
|
653 | + |
|
654 | + if ( isset( $matches[1] ) ) { |
|
655 | + $id = $matches[1]; |
|
656 | + $page_items[$id] = trim( strip_tags( $v ) ); |
|
657 | + } // End If Statement |
|
658 | 658 | } // End For Loop |
659 | 659 | |
660 | 660 | $pages_array = $page_items; |
@@ -671,22 +671,22 @@ discard block |
||
671 | 671 | Sensei_Language_Pack_Manager::messages(); |
672 | 672 | } |
673 | 673 | |
674 | - /** |
|
675 | - * Flush the rewrite rules after the settings have been updated. |
|
676 | - * This is to ensure that the |
|
677 | - * |
|
678 | - * @since 1.9.0 |
|
679 | - */ |
|
680 | - public static function flush_rewrite_rules(){ |
|
674 | + /** |
|
675 | + * Flush the rewrite rules after the settings have been updated. |
|
676 | + * This is to ensure that the |
|
677 | + * |
|
678 | + * @since 1.9.0 |
|
679 | + */ |
|
680 | + public static function flush_rewrite_rules(){ |
|
681 | 681 | |
682 | - if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] |
|
683 | - && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { |
|
682 | + if ( isset( $_POST[ 'option_page' ] ) && 'woothemes-sensei-settings' == $_POST[ 'option_page' ] |
|
683 | + && isset( $_POST[ 'action' ] ) && 'update' == $_POST[ 'action' ] ) { |
|
684 | 684 | |
685 | - Sensei()->initiate_rewrite_rules_flush(); |
|
685 | + Sensei()->initiate_rewrite_rules_flush(); |
|
686 | 686 | |
687 | - } |
|
687 | + } |
|
688 | 688 | |
689 | - }//end flush_cache |
|
689 | + }//end flush_cache |
|
690 | 690 | } // End Class |
691 | 691 | |
692 | 692 | /** |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | */ |
21 | 21 | public function __construct () { |
22 | 22 | |
23 | - //register admin styles |
|
23 | + //register admin styles |
|
24 | 24 | add_action( 'admin_enqueue_scripts', array( $this, 'admin_styles_global' ) ); |
25 | 25 | |
26 | - //register admin scripts |
|
27 | - add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
26 | + //register admin scripts |
|
27 | + add_action( 'admin_enqueue_scripts', array( $this, 'register_scripts' ) ); |
|
28 | 28 | |
29 | 29 | add_action( 'admin_print_styles', array( $this, 'admin_notices_styles' ) ); |
30 | 30 | add_action( 'settings_before_form', array( $this, 'install_pages_output' ) ); |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | add_action( 'admin_head', array( $this, 'admin_menu_highlight' ) ); |
34 | 34 | add_action( 'admin_init', array( $this, 'page_redirect' ) ); |
35 | 35 | add_action( 'admin_init', array( $this, 'sensei_add_custom_menu_items' ) ); |
36 | - add_action( 'admin_init', array( __CLASS__, 'install_pages' )); |
|
36 | + add_action( 'admin_init', array( __CLASS__, 'install_pages' )); |
|
37 | 37 | |
38 | 38 | // Duplicate lesson & courses |
39 | 39 | add_filter( 'post_row_actions', array( $this, 'duplicate_action_link' ), 10, 2 ); |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | |
85 | 85 | if( $menu_cap ) { |
86 | 86 | $menu[] = array( '', 'read', 'separator-sensei', '', 'wp-menu-separator sensei' ); |
87 | - add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' ); |
|
87 | + add_menu_page( 'Sensei', 'Sensei', $menu_cap, 'sensei' , array( Sensei()->analysis, 'analysis_page' ) , '', '50' ); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | add_submenu_page( 'edit.php?post_type=course', __( 'Order Courses', 'woothemes-sensei' ), __( 'Order Courses', 'woothemes-sensei' ), 'manage_sensei', 'course-order', array( $this, 'course_order_screen' ) ); |
@@ -141,14 +141,14 @@ discard block |
||
141 | 141 | $submenu_file = 'edit-tags.php?taxonomy=course-category&post_type=course'; |
142 | 142 | $parent_file = 'edit.php?post_type=course'; |
143 | 143 | |
144 | - } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) { |
|
144 | + } elseif ( $screen->base == 'edit-tags' && $taxonomy == 'module' ) { |
|
145 | 145 | |
146 | - $submenu_file = 'edit-tags.php?taxonomy=module'; |
|
147 | - $parent_file = 'edit.php?post_type=course'; |
|
146 | + $submenu_file = 'edit-tags.php?taxonomy=module'; |
|
147 | + $parent_file = 'edit.php?post_type=course'; |
|
148 | 148 | |
149 | 149 | } elseif ( in_array( $screen->id, array( 'sensei_message', 'edit-sensei_message' ) ) ) { |
150 | 150 | |
151 | - $submenu_file = 'edit.php?post_type=sensei_message'; |
|
151 | + $submenu_file = 'edit.php?post_type=sensei_message'; |
|
152 | 152 | $parent_file = 'sensei'; |
153 | 153 | |
154 | 154 | } |
@@ -176,9 +176,9 @@ discard block |
||
176 | 176 | */ |
177 | 177 | function install_pages_output() { |
178 | 178 | |
179 | - if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { |
|
179 | + if( isset($_GET['sensei_install_complete']) && 'true' == $_GET['sensei_install_complete']) { |
|
180 | 180 | |
181 | - ?> |
|
181 | + ?> |
|
182 | 182 | <div id="message" class="updated sensei-message sensei-connect"> |
183 | 183 | <p><?php _e( '<strong>Congratulations!</strong> – Sensei has been installed and set up.', 'woothemes-sensei' ); ?></p> |
184 | 184 | <p><a href="https://twitter.com/share" class="twitter-share-button" data-url="http://www.woothemes.com/sensei/" data-text="A premium Learning Management plugin for #WordPress that helps you create courses. Beautifully." data-via="WooThemes" data-size="large" data-hashtags="Sensei">Tweet</a> |
@@ -186,7 +186,7 @@ discard block |
||
186 | 186 | </div> |
187 | 187 | <?php |
188 | 188 | |
189 | - } |
|
189 | + } |
|
190 | 190 | |
191 | 191 | } // End install_pages_output() |
192 | 192 | |
@@ -218,18 +218,18 @@ discard block |
||
218 | 218 | endif; |
219 | 219 | |
220 | 220 | $page_data = array( |
221 | - 'post_status' => 'publish', |
|
222 | - 'post_type' => 'page', |
|
223 | - 'post_author' => 1, |
|
224 | - 'post_name' => $slug, |
|
225 | - 'post_title' => $page_title, |
|
226 | - 'post_content' => $page_content, |
|
227 | - 'post_parent' => $post_parent, |
|
228 | - 'comment_status' => 'closed' |
|
229 | - ); |
|
230 | - $page_id = wp_insert_post( $page_data ); |
|
231 | - |
|
232 | - update_option( $option, $page_id ); |
|
221 | + 'post_status' => 'publish', |
|
222 | + 'post_type' => 'page', |
|
223 | + 'post_author' => 1, |
|
224 | + 'post_name' => $slug, |
|
225 | + 'post_title' => $page_title, |
|
226 | + 'post_content' => $page_content, |
|
227 | + 'post_parent' => $post_parent, |
|
228 | + 'comment_status' => 'closed' |
|
229 | + ); |
|
230 | + $page_id = wp_insert_post( $page_data ); |
|
231 | + |
|
232 | + update_option( $option, $page_id ); |
|
233 | 233 | } // End create_page() |
234 | 234 | |
235 | 235 | |
@@ -242,10 +242,10 @@ discard block |
||
242 | 242 | function create_pages() { |
243 | 243 | |
244 | 244 | // Courses page |
245 | - $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_courses_page_id', __('Courses', 'woothemes-sensei'), '[newcourses][featuredcourses][freecourses][paidcourses]' ); |
|
245 | + $this->create_page( esc_sql( _x('courses-overview', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_courses_page_id', __('Courses', 'woothemes-sensei'), '[newcourses][featuredcourses][freecourses][paidcourses]' ); |
|
246 | 246 | |
247 | 247 | // User Dashboard page |
248 | - $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_user_dashboard_page_id', __('My Courses', 'woothemes-sensei'), '[usercourses]' ); |
|
248 | + $this->create_page( esc_sql( _x('my-courses', 'page_slug', 'woothemes-sensei') ), 'woothemes-sensei_user_dashboard_page_id', __('My Courses', 'woothemes-sensei'), '[usercourses]' ); |
|
249 | 249 | |
250 | 250 | } // End create_pages() |
251 | 251 | |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | wp_register_style( 'woothemes-sensei-global', Sensei()->plugin_url . 'assets/css/global.css', '', Sensei()->version, 'screen' ); |
267 | 267 | wp_enqueue_style( 'woothemes-sensei-global' ); |
268 | 268 | |
269 | - // Select 2 styles |
|
270 | - wp_enqueue_style( 'select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' ); |
|
269 | + // Select 2 styles |
|
270 | + wp_enqueue_style( 'select2', Sensei()->plugin_url . 'assets/css/select2/select2.css', '', Sensei()->version, 'screen' ); |
|
271 | 271 | |
272 | 272 | // Test for Write Panel Pages |
273 | 273 | if ( ( ( isset( $post_type ) && in_array( $post_type, $allowed_post_types ) ) && ( isset( $hook ) && in_array( $hook, $allowed_post_type_pages ) ) ) || ( isset( $_GET['page'] ) && in_array( $_GET['page'], $allowed_pages ) ) ) { |
@@ -280,32 +280,32 @@ discard block |
||
280 | 280 | } // End admin_styles_global() |
281 | 281 | |
282 | 282 | |
283 | - /** |
|
284 | - * Globally register all scripts needed in admin. |
|
285 | - * |
|
286 | - * The script users should enqueue the script when needed. |
|
287 | - * |
|
288 | - * @since 1.8.2 |
|
289 | - * @access public |
|
290 | - */ |
|
291 | - public function register_scripts( $hook ){ |
|
283 | + /** |
|
284 | + * Globally register all scripts needed in admin. |
|
285 | + * |
|
286 | + * The script users should enqueue the script when needed. |
|
287 | + * |
|
288 | + * @since 1.8.2 |
|
289 | + * @access public |
|
290 | + */ |
|
291 | + public function register_scripts( $hook ){ |
|
292 | 292 | |
293 | - $screen = get_current_screen(); |
|
293 | + $screen = get_current_screen(); |
|
294 | 294 | |
295 | - // Allow developers to load non-minified versions of scripts |
|
296 | - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
295 | + // Allow developers to load non-minified versions of scripts |
|
296 | + $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; |
|
297 | 297 | |
298 | - // Select2 script used to enhance all select boxes |
|
299 | - wp_register_script( 'select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); |
|
298 | + // Select2 script used to enhance all select boxes |
|
299 | + wp_register_script( 'select2', Sensei()->plugin_url . '/assets/js/select2/select2' . $suffix . '.js', array( 'jquery' ), Sensei()->version ); |
|
300 | 300 | |
301 | - // load edit module scripts |
|
302 | - if( 'edit-module' == $screen->id ){ |
|
301 | + // load edit module scripts |
|
302 | + if( 'edit-module' == $screen->id ){ |
|
303 | 303 | |
304 | - wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true ); |
|
304 | + wp_enqueue_script( 'sensei-chosen-ajax', Sensei()->plugin_url . 'assets/chosen/ajax-chosen.jquery.min.js', array( 'jquery', 'sensei-chosen' ), Sensei()->version, true ); |
|
305 | 305 | |
306 | - } |
|
306 | + } |
|
307 | 307 | |
308 | - } |
|
308 | + } |
|
309 | 309 | |
310 | 310 | |
311 | 311 | /** |
@@ -315,7 +315,7 @@ discard block |
||
315 | 315 | * @return void |
316 | 316 | */ |
317 | 317 | function admin_install_notice() { |
318 | - ?> |
|
318 | + ?> |
|
319 | 319 | <div id="message" class="updated sensei-message sensei-connect"> |
320 | 320 | |
321 | 321 | <p> |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @return void |
351 | 351 | */ |
352 | 352 | function admin_installed_notice() { |
353 | - ?> |
|
353 | + ?> |
|
354 | 354 | <div id="message" class="updated sensei-message sensei-connect"> |
355 | 355 | |
356 | 356 | <p> |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | </div> |
379 | 379 | <?php |
380 | 380 | |
381 | - // Set installed option |
|
382 | - update_option('sensei_installed', 0); |
|
381 | + // Set installed option |
|
382 | + update_option('sensei_installed', 0); |
|
383 | 383 | } // End admin_installed_notice() |
384 | 384 | |
385 | 385 | |
@@ -411,21 +411,21 @@ discard block |
||
411 | 411 | function admin_notices_styles() { |
412 | 412 | |
413 | 413 | // Installed notices |
414 | - if ( 1 == get_option( 'sensei_installed' ) ) { |
|
414 | + if ( 1 == get_option( 'sensei_installed' ) ) { |
|
415 | 415 | |
416 | - wp_enqueue_style( 'sensei-activation', plugins_url( '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version ); |
|
416 | + wp_enqueue_style( 'sensei-activation', plugins_url( '/assets/css/activation.css', dirname( __FILE__ ) ), '', Sensei()->version ); |
|
417 | 417 | |
418 | - if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) { |
|
419 | - add_action( 'admin_notices', array( $this, 'admin_install_notice' ) ); |
|
420 | - } elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) { |
|
421 | - add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) ); |
|
422 | - } // End If Statement |
|
418 | + if (get_option('skip_install_sensei_pages')!=1 && Sensei()->get_page_id('course')<1 && !isset($_GET['install_sensei_pages']) && !isset($_GET['skip_install_sensei_pages'])) { |
|
419 | + add_action( 'admin_notices', array( $this, 'admin_install_notice' ) ); |
|
420 | + } elseif ( !isset($_GET['page']) || $_GET['page']!='woothemes-sensei-settings' ) { |
|
421 | + add_action( 'admin_notices', array( $this, 'admin_installed_notice' ) ); |
|
422 | + } // End If Statement |
|
423 | 423 | |
424 | - } // End If Statement |
|
424 | + } // End If Statement |
|
425 | 425 | |
426 | - if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) { |
|
427 | - add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) ); |
|
428 | - } |
|
426 | + if ( Sensei_Language_Pack_Manager::has_language_pack_available() ) { |
|
427 | + add_action( 'admin_notices', array( $this, 'language_pack_install_notice' ) ); |
|
428 | + } |
|
429 | 429 | |
430 | 430 | } // End admin_notices_styles() |
431 | 431 | |
@@ -541,30 +541,30 @@ discard block |
||
541 | 541 | */ |
542 | 542 | private function duplicate_lesson_quizzes( $old_lesson_id, $new_lesson_id ) { |
543 | 543 | |
544 | - $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id ); |
|
545 | - $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id ); |
|
544 | + $old_quiz_id = Sensei()->lesson->lesson_quizzes( $old_lesson_id ); |
|
545 | + $old_quiz_questions = Sensei()->lesson->lesson_quiz_questions( $old_quiz_id ); |
|
546 | 546 | |
547 | - // duplicate the generic wp post information |
|
547 | + // duplicate the generic wp post information |
|
548 | 548 | $new_quiz = $this->duplicate_post( get_post( $old_quiz_id ), '' ); |
549 | 549 | |
550 | 550 | //update the new lesson data |
551 | - add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID ); |
|
551 | + add_post_meta( $new_lesson_id, '_lesson_quiz', $new_quiz->ID ); |
|
552 | 552 | |
553 | 553 | //update the new quiz data |
554 | - add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id ); |
|
555 | - wp_update_post( |
|
556 | - array( |
|
557 | - 'ID' => $new_quiz->ID, |
|
558 | - 'post_parent' => $new_lesson_id |
|
559 | - ) |
|
560 | - ); |
|
554 | + add_post_meta( $new_quiz->ID, '_quiz_lesson', $new_lesson_id ); |
|
555 | + wp_update_post( |
|
556 | + array( |
|
557 | + 'ID' => $new_quiz->ID, |
|
558 | + 'post_parent' => $new_lesson_id |
|
559 | + ) |
|
560 | + ); |
|
561 | 561 | |
562 | 562 | foreach( $old_quiz_questions as $question ) { |
563 | 563 | |
564 | 564 | // copy the question order over to the new quiz |
565 | 565 | $old_question_order = get_post_meta( $question->ID, '_quiz_question_order'. $old_quiz_id, true ); |
566 | - $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order ); |
|
567 | - add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order ); |
|
566 | + $new_question_order = str_ireplace( $old_quiz_id, $new_quiz->ID , $old_question_order ); |
|
567 | + add_post_meta( $question->ID, '_quiz_question_order' . $new_quiz->ID, $new_question_order ); |
|
568 | 568 | |
569 | 569 | // Add question to quiz |
570 | 570 | add_post_meta( $question->ID, '_quiz_id', $new_quiz->ID, false ); |
@@ -886,21 +886,21 @@ discard block |
||
886 | 886 | break; |
887 | 887 | |
888 | 888 | case 'checkbox': |
889 | - //backwards compatibility |
|
890 | - if( empty( $data ) || 'on' == $data ){ |
|
891 | - $checked_value = 'on'; |
|
892 | - }elseif( 'yes' == $data ) { |
|
889 | + //backwards compatibility |
|
890 | + if( empty( $data ) || 'on' == $data ){ |
|
891 | + $checked_value = 'on'; |
|
892 | + }elseif( 'yes' == $data ) { |
|
893 | 893 | |
894 | - $checked_value = 'yes'; |
|
894 | + $checked_value = 'yes'; |
|
895 | 895 | |
896 | - }elseif( 'auto' == $data ) { |
|
896 | + }elseif( 'auto' == $data ) { |
|
897 | 897 | |
898 | - $checked_value = 'auto'; |
|
898 | + $checked_value = 'auto'; |
|
899 | 899 | |
900 | - } else { |
|
901 | - $checked_value = 1; |
|
902 | - $data = intval( $data ); |
|
903 | - } |
|
900 | + } else { |
|
901 | + $checked_value = 1; |
|
902 | + $data = intval( $data ); |
|
903 | + } |
|
904 | 904 | $checked = checked( $checked_value, $data, false ); |
905 | 905 | $html .= '<input id="' . esc_attr( $field['id'] ) . '" type="' . $field['type'] . '" name="' . esc_attr( $field['id'] ) . '" ' . $checked . ' ' . $disabled . '/>' . "\n"; |
906 | 906 | break; |
@@ -1004,26 +1004,26 @@ discard block |
||
1004 | 1004 | |
1005 | 1005 | if( 0 < count( $courses ) ) { |
1006 | 1006 | |
1007 | - // order the courses as set by the users |
|
1008 | - $all_course_ids = array(); |
|
1009 | - foreach( $courses as $course ){ |
|
1007 | + // order the courses as set by the users |
|
1008 | + $all_course_ids = array(); |
|
1009 | + foreach( $courses as $course ){ |
|
1010 | 1010 | |
1011 | - $all_course_ids[] = (string)$course->ID; |
|
1011 | + $all_course_ids[] = (string)$course->ID; |
|
1012 | 1012 | |
1013 | - } |
|
1014 | - $order_string = $this->get_course_order(); |
|
1013 | + } |
|
1014 | + $order_string = $this->get_course_order(); |
|
1015 | 1015 | |
1016 | - if( !empty( $order_string ) ){ |
|
1017 | - $ordered_course_ids = explode(',' , $order_string ); |
|
1018 | - $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) ); |
|
1019 | - } |
|
1016 | + if( !empty( $order_string ) ){ |
|
1017 | + $ordered_course_ids = explode(',' , $order_string ); |
|
1018 | + $all_course_ids = array_unique( array_merge( $ordered_course_ids , $all_course_ids ) ); |
|
1019 | + } |
|
1020 | 1020 | |
1021 | 1021 | |
1022 | 1022 | $html .= '<form id="editgrouping" method="post" action="" class="validate">' . "\n"; |
1023 | 1023 | $html .= '<ul class="sortable-course-list">' . "\n"; |
1024 | 1024 | $count = 0; |
1025 | 1025 | foreach ( $all_course_ids as $course_id ) { |
1026 | - $course = get_post( $course_id ); |
|
1026 | + $course = get_post( $course_id ); |
|
1027 | 1027 | $count++; |
1028 | 1028 | $class = 'course'; |
1029 | 1029 | if ( $count == 1 ) { $class .= ' first'; } |
@@ -1138,73 +1138,73 @@ discard block |
||
1138 | 1138 | |
1139 | 1139 | $displayed_lessons = array(); |
1140 | 1140 | |
1141 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
1142 | - |
|
1143 | - foreach( $modules as $module ) { |
|
1144 | - |
|
1145 | - $args = array( |
|
1146 | - 'post_type' => 'lesson', |
|
1147 | - 'post_status' => 'publish', |
|
1148 | - 'posts_per_page' => -1, |
|
1149 | - 'meta_query' => array( |
|
1150 | - array( |
|
1151 | - 'key' => '_lesson_course', |
|
1152 | - 'value' => intval( $course_id ), |
|
1153 | - 'compare' => '=' |
|
1154 | - ) |
|
1155 | - ), |
|
1156 | - 'tax_query' => array( |
|
1157 | - array( |
|
1158 | - 'taxonomy' => Sensei()->modules->taxonomy, |
|
1159 | - 'field' => 'id', |
|
1160 | - 'terms' => intval( $module->term_id ) |
|
1161 | - ) |
|
1162 | - ), |
|
1163 | - 'meta_key' => '_order_module_' . $module->term_id, |
|
1164 | - 'orderby' => 'meta_value_num date', |
|
1165 | - 'order' => 'ASC', |
|
1166 | - 'suppress_filters' => 0 |
|
1167 | - ); |
|
1168 | - |
|
1169 | - $lessons = get_posts( $args ); |
|
1170 | - |
|
1171 | - if( count( $lessons ) > 0 ) { |
|
1172 | - $html .= '<h3>' . $module->name . '</h3>' . "\n"; |
|
1173 | - $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n"; |
|
1174 | - |
|
1175 | - $count = 0; |
|
1176 | - foreach( $lessons as $lesson ) { |
|
1177 | - $count++; |
|
1178 | - $class = 'lesson'; |
|
1179 | - if ( $count == 1 ) { $class .= ' first'; } |
|
1180 | - if ( $count == count( $lesson ) ) { $class .= ' last'; } |
|
1181 | - if ( $count % 2 != 0 ) { |
|
1182 | - $class .= ' alternate'; |
|
1183 | - } |
|
1184 | - |
|
1185 | - $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; |
|
1186 | - |
|
1187 | - $displayed_lessons[] = $lesson->ID; |
|
1188 | - } |
|
1189 | - |
|
1190 | - $html .= '</ul>' . "\n"; |
|
1191 | - |
|
1192 | - $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n"; |
|
1193 | - } |
|
1194 | - } |
|
1195 | - |
|
1196 | - |
|
1197 | - $lessons = Sensei()->course->course_lessons( $course_id ); |
|
1141 | + $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
1142 | + |
|
1143 | + foreach( $modules as $module ) { |
|
1144 | + |
|
1145 | + $args = array( |
|
1146 | + 'post_type' => 'lesson', |
|
1147 | + 'post_status' => 'publish', |
|
1148 | + 'posts_per_page' => -1, |
|
1149 | + 'meta_query' => array( |
|
1150 | + array( |
|
1151 | + 'key' => '_lesson_course', |
|
1152 | + 'value' => intval( $course_id ), |
|
1153 | + 'compare' => '=' |
|
1154 | + ) |
|
1155 | + ), |
|
1156 | + 'tax_query' => array( |
|
1157 | + array( |
|
1158 | + 'taxonomy' => Sensei()->modules->taxonomy, |
|
1159 | + 'field' => 'id', |
|
1160 | + 'terms' => intval( $module->term_id ) |
|
1161 | + ) |
|
1162 | + ), |
|
1163 | + 'meta_key' => '_order_module_' . $module->term_id, |
|
1164 | + 'orderby' => 'meta_value_num date', |
|
1165 | + 'order' => 'ASC', |
|
1166 | + 'suppress_filters' => 0 |
|
1167 | + ); |
|
1168 | + |
|
1169 | + $lessons = get_posts( $args ); |
|
1170 | + |
|
1171 | + if( count( $lessons ) > 0 ) { |
|
1172 | + $html .= '<h3>' . $module->name . '</h3>' . "\n"; |
|
1173 | + $html .= '<ul class="sortable-lesson-list" data-module_id="' . $module->term_id . '">' . "\n"; |
|
1174 | + |
|
1175 | + $count = 0; |
|
1176 | + foreach( $lessons as $lesson ) { |
|
1177 | + $count++; |
|
1178 | + $class = 'lesson'; |
|
1179 | + if ( $count == 1 ) { $class .= ' first'; } |
|
1180 | + if ( $count == count( $lesson ) ) { $class .= ' last'; } |
|
1181 | + if ( $count % 2 != 0 ) { |
|
1182 | + $class .= ' alternate'; |
|
1183 | + } |
|
1184 | + |
|
1185 | + $html .= '<li class="' . esc_attr( $class ) . '"><span rel="' . esc_attr( $lesson->ID ) . '" style="width: 100%;"> ' . $lesson->post_title . '</span></li>' . "\n"; |
|
1186 | + |
|
1187 | + $displayed_lessons[] = $lesson->ID; |
|
1188 | + } |
|
1189 | + |
|
1190 | + $html .= '</ul>' . "\n"; |
|
1191 | + |
|
1192 | + $html .= '<input type="hidden" name="lesson-order-module-' . $module->term_id . '" value="" />' . "\n"; |
|
1193 | + } |
|
1194 | + } |
|
1195 | + |
|
1196 | + |
|
1197 | + $lessons = Sensei()->course->course_lessons( $course_id ); |
|
1198 | 1198 | |
1199 | 1199 | if( 0 < count( $lessons ) ) { |
1200 | 1200 | |
1201 | - //get module term ids, will be used to exclude lessons |
|
1202 | - $module_items_ids = array(); |
|
1203 | - if( ! empty( $modules ) ) { |
|
1204 | - foreach ($modules as $module) { |
|
1205 | - $module_items_ids[] = $module->term_id; |
|
1206 | - } |
|
1207 | - } |
|
1201 | + //get module term ids, will be used to exclude lessons |
|
1202 | + $module_items_ids = array(); |
|
1203 | + if( ! empty( $modules ) ) { |
|
1204 | + foreach ($modules as $module) { |
|
1205 | + $module_items_ids[] = $module->term_id; |
|
1206 | + } |
|
1207 | + } |
|
1208 | 1208 | |
1209 | 1209 | if( 0 < count( $displayed_lessons ) ) { |
1210 | 1210 | $html .= '<h3>' . __( 'Other Lessons', 'woothemes-sensei' ) . '</h3>' . "\n"; |
@@ -1214,13 +1214,13 @@ discard block |
||
1214 | 1214 | $count = 0; |
1215 | 1215 | foreach ( $lessons as $lesson ) { |
1216 | 1216 | |
1217 | - // if lesson belongs to one fo the course modules then exclude it here |
|
1218 | - // as it is listed above |
|
1219 | - if( has_term( $module_items_ids, 'module', $lesson->ID ) ){ |
|
1217 | + // if lesson belongs to one fo the course modules then exclude it here |
|
1218 | + // as it is listed above |
|
1219 | + if( has_term( $module_items_ids, 'module', $lesson->ID ) ){ |
|
1220 | 1220 | |
1221 | - continue; |
|
1221 | + continue; |
|
1222 | 1222 | |
1223 | - } |
|
1223 | + } |
|
1224 | 1224 | |
1225 | 1225 | $count++; |
1226 | 1226 | $class = 'lesson'; |
@@ -1264,23 +1264,23 @@ discard block |
||
1264 | 1264 | |
1265 | 1265 | if( $course_id ) { |
1266 | 1266 | |
1267 | - $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
1267 | + $modules = Sensei()->modules->get_course_modules( intval( $course_id ) ); |
|
1268 | 1268 | |
1269 | - foreach( $modules as $module ) { |
|
1269 | + foreach( $modules as $module ) { |
|
1270 | 1270 | |
1271 | - $module_order_string = $_POST[ 'lesson-order-module-' . $module->term_id ]; |
|
1271 | + $module_order_string = $_POST[ 'lesson-order-module-' . $module->term_id ]; |
|
1272 | 1272 | |
1273 | - if( $module_order_string ) { |
|
1274 | - $order = explode( ',', $module_order_string ); |
|
1275 | - $i = 1; |
|
1276 | - foreach( $order as $lesson_id ) { |
|
1277 | - if( $lesson_id ) { |
|
1278 | - update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i ); |
|
1279 | - ++$i; |
|
1280 | - } |
|
1281 | - } |
|
1282 | - } |
|
1283 | - } |
|
1273 | + if( $module_order_string ) { |
|
1274 | + $order = explode( ',', $module_order_string ); |
|
1275 | + $i = 1; |
|
1276 | + foreach( $order as $lesson_id ) { |
|
1277 | + if( $lesson_id ) { |
|
1278 | + update_post_meta( $lesson_id, '_order_module_' . $module->term_id, $i ); |
|
1279 | + ++$i; |
|
1280 | + } |
|
1281 | + } |
|
1282 | + } |
|
1283 | + } |
|
1284 | 1284 | |
1285 | 1285 | |
1286 | 1286 | if( $order_string ) { |
@@ -1363,47 +1363,47 @@ discard block |
||
1363 | 1363 | |
1364 | 1364 | /** |
1365 | 1365 | * Adding admin notice if the current |
1366 | - * installed theme is not compatible |
|
1367 | - * |
|
1366 | + * installed theme is not compatible |
|
1367 | + * |
|
1368 | 1368 | * @return void |
1369 | 1369 | */ |
1370 | 1370 | public function theme_compatibility_notices() { |
1371 | 1371 | |
1372 | - if( isset( $_GET['sensei_hide_notice'] ) ) { |
|
1373 | - switch( esc_attr( $_GET['sensei_hide_notice'] ) ) { |
|
1372 | + if( isset( $_GET['sensei_hide_notice'] ) ) { |
|
1373 | + switch( esc_attr( $_GET['sensei_hide_notice'] ) ) { |
|
1374 | 1374 | case 'menu_settings': add_user_meta( get_current_user_id(), 'sensei_hide_menu_settings_notice', true ); break; |
1375 | 1375 | case 'theme_check': add_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); break; |
1376 | 1376 | } |
1377 | - } |
|
1377 | + } |
|
1378 | 1378 | |
1379 | - // white list templates that are already support by default and do not show notice for them |
|
1380 | - $template = get_option( 'template' ); |
|
1379 | + // white list templates that are already support by default and do not show notice for them |
|
1380 | + $template = get_option( 'template' ); |
|
1381 | 1381 | |
1382 | - $white_list = array( 'twentyeleven', |
|
1383 | - 'twentytwelve', |
|
1384 | - 'twentyfourteen', |
|
1385 | - 'twentyfifteen', |
|
1386 | - 'twentysixteen', |
|
1387 | - 'storefront', |
|
1388 | - ); |
|
1382 | + $white_list = array( 'twentyeleven', |
|
1383 | + 'twentytwelve', |
|
1384 | + 'twentyfourteen', |
|
1385 | + 'twentyfifteen', |
|
1386 | + 'twentysixteen', |
|
1387 | + 'storefront', |
|
1388 | + ); |
|
1389 | 1389 | |
1390 | - if ( in_array( $template, $white_list ) ) { |
|
1390 | + if ( in_array( $template, $white_list ) ) { |
|
1391 | 1391 | |
1392 | - return; |
|
1392 | + return; |
|
1393 | 1393 | |
1394 | - } |
|
1394 | + } |
|
1395 | 1395 | |
1396 | - // don't show the notice if the user chose to hide it |
|
1397 | - $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); |
|
1398 | - if( $hide_theme_check_notice ) { |
|
1396 | + // don't show the notice if the user chose to hide it |
|
1397 | + $hide_theme_check_notice = get_user_meta( get_current_user_id(), 'sensei_hide_theme_check_notice', true ); |
|
1398 | + if( $hide_theme_check_notice ) { |
|
1399 | 1399 | |
1400 | - return; |
|
1400 | + return; |
|
1401 | 1401 | |
1402 | - } |
|
1402 | + } |
|
1403 | 1403 | |
1404 | - // show the notice for themes not supporting sensei |
|
1405 | - if ( ! current_theme_supports( 'sensei' ) ) { |
|
1406 | - ?> |
|
1404 | + // show the notice for themes not supporting sensei |
|
1405 | + if ( ! current_theme_supports( 'sensei' ) ) { |
|
1406 | + ?> |
|
1407 | 1407 | |
1408 | 1408 | <div id="message" class="error sensei-message sensei-connect"> |
1409 | 1409 | <p> |
@@ -1439,7 +1439,7 @@ discard block |
||
1439 | 1439 | public function reset_theme_check_notices() { |
1440 | 1440 | global $current_user; |
1441 | 1441 | wp_get_current_user(); |
1442 | - $user_id = $current_user->ID; |
|
1442 | + $user_id = $current_user->ID; |
|
1443 | 1443 | |
1444 | 1444 | delete_user_meta( $user_id, 'sensei_hide_theme_check_notice' ); |
1445 | 1445 | } |
@@ -1459,60 +1459,60 @@ discard block |
||
1459 | 1459 | return $prevent_access; |
1460 | 1460 | } |
1461 | 1461 | |
1462 | - /** |
|
1463 | - * Hooked onto admin_init. Listens for install_sensei_pages and skip_install_sensei_pages query args |
|
1464 | - * on the sensei settings page. |
|
1465 | - * |
|
1466 | - * The function |
|
1467 | - * |
|
1468 | - * @since 1.8.7 |
|
1469 | - */ |
|
1470 | - public static function install_pages(){ |
|
1462 | + /** |
|
1463 | + * Hooked onto admin_init. Listens for install_sensei_pages and skip_install_sensei_pages query args |
|
1464 | + * on the sensei settings page. |
|
1465 | + * |
|
1466 | + * The function |
|
1467 | + * |
|
1468 | + * @since 1.8.7 |
|
1469 | + */ |
|
1470 | + public static function install_pages(){ |
|
1471 | 1471 | |
1472 | - // only fire on the settings page |
|
1473 | - if( ! isset( $_GET['page'] ) |
|
1474 | - || 'woothemes-sensei-settings' != $_GET['page'] |
|
1475 | - || 1 == get_option('skip_install_sensei_pages') ){ |
|
1472 | + // only fire on the settings page |
|
1473 | + if( ! isset( $_GET['page'] ) |
|
1474 | + || 'woothemes-sensei-settings' != $_GET['page'] |
|
1475 | + || 1 == get_option('skip_install_sensei_pages') ){ |
|
1476 | 1476 | |
1477 | - return; |
|
1477 | + return; |
|
1478 | 1478 | |
1479 | - } |
|
1479 | + } |
|
1480 | 1480 | |
1481 | - // Install/page installer |
|
1482 | - $install_complete = false; |
|
1481 | + // Install/page installer |
|
1482 | + $install_complete = false; |
|
1483 | 1483 | |
1484 | - // Add pages button |
|
1485 | - $settings_url = ''; |
|
1486 | - if (isset($_GET['install_sensei_pages']) && $_GET['install_sensei_pages']) { |
|
1484 | + // Add pages button |
|
1485 | + $settings_url = ''; |
|
1486 | + if (isset($_GET['install_sensei_pages']) && $_GET['install_sensei_pages']) { |
|
1487 | 1487 | |
1488 | - Sensei()->admin->create_pages(); |
|
1489 | - update_option('skip_install_sensei_pages', 1); |
|
1490 | - $install_complete = true; |
|
1491 | - $settings_url = remove_query_arg('install_sensei_pages'); |
|
1488 | + Sensei()->admin->create_pages(); |
|
1489 | + update_option('skip_install_sensei_pages', 1); |
|
1490 | + $install_complete = true; |
|
1491 | + $settings_url = remove_query_arg('install_sensei_pages'); |
|
1492 | 1492 | |
1493 | - // Skip button |
|
1494 | - } elseif (isset($_GET['skip_install_sensei_pages']) && $_GET['skip_install_sensei_pages']) { |
|
1493 | + // Skip button |
|
1494 | + } elseif (isset($_GET['skip_install_sensei_pages']) && $_GET['skip_install_sensei_pages']) { |
|
1495 | 1495 | |
1496 | - update_option('skip_install_sensei_pages', 1); |
|
1497 | - $install_complete = true; |
|
1498 | - $settings_url = remove_query_arg('skip_install_sensei_pages'); |
|
1496 | + update_option('skip_install_sensei_pages', 1); |
|
1497 | + $install_complete = true; |
|
1498 | + $settings_url = remove_query_arg('skip_install_sensei_pages'); |
|
1499 | 1499 | |
1500 | - } |
|
1500 | + } |
|
1501 | 1501 | |
1502 | - if ($install_complete) { |
|
1502 | + if ($install_complete) { |
|
1503 | 1503 | |
1504 | - // Flush rules after install |
|
1505 | - flush_rewrite_rules( true ); |
|
1504 | + // Flush rules after install |
|
1505 | + flush_rewrite_rules( true ); |
|
1506 | 1506 | |
1507 | - // Set installed option |
|
1508 | - update_option('sensei_installed', 0); |
|
1507 | + // Set installed option |
|
1508 | + update_option('sensei_installed', 0); |
|
1509 | 1509 | |
1510 | - $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url ); |
|
1511 | - wp_redirect( $complete_url ); |
|
1510 | + $complete_url = add_query_arg( 'sensei_install_complete', 'true', $settings_url ); |
|
1511 | + wp_redirect( $complete_url ); |
|
1512 | 1512 | |
1513 | - } |
|
1513 | + } |
|
1514 | 1514 | |
1515 | - }// end install_pages |
|
1515 | + }// end install_pages |
|
1516 | 1516 | |
1517 | 1517 | } // End Class |
1518 | 1518 |
@@ -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 |
@@ -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 | } |
@@ -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){ |