@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * Sensei Utilities Class |
@@ -176,8 +179,7 @@ discard block |
||
| 176 | 179 | // ...use a filter to switch the encoding back |
| 177 | 180 | add_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) ); |
| 178 | 181 | } |
| 179 | - } |
|
| 180 | - else { |
|
| 182 | + } else { |
|
| 181 | 183 | $args['status'] = 'any'; // 'log' == 'sensei_user_answer' |
| 182 | 184 | } |
| 183 | 185 | |
@@ -302,8 +304,12 @@ discard block |
||
| 302 | 304 | } |
| 303 | 305 | |
| 304 | 306 | foreach( $activities as $activity ) { |
| 305 | - if( '' == $activity->comment_type ) continue; |
|
| 306 | - if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue; |
|
| 307 | + if( '' == $activity->comment_type ) { |
|
| 308 | + continue; |
|
| 309 | + } |
|
| 310 | + if( strpos( 'sensei_', $activity->comment_type ) != 0 ) { |
|
| 311 | + continue; |
|
| 312 | + } |
|
| 307 | 313 | $dataset_changes = wp_delete_comment( intval( $activity->comment_ID ), true ); |
| 308 | 314 | wp_cache_flush(); |
| 309 | 315 | } |
@@ -354,11 +360,13 @@ discard block |
||
| 354 | 360 | $emails[] = $user->user_email; |
| 355 | 361 | } |
| 356 | 362 | |
| 357 | - if ( is_email( $customer_email ) ) |
|
| 358 | - $emails[] = $customer_email; |
|
| 363 | + if ( is_email( $customer_email ) ) { |
|
| 364 | + $emails[] = $customer_email; |
|
| 365 | + } |
|
| 359 | 366 | |
| 360 | - if ( sizeof( $emails ) == 0 ) |
|
| 361 | - return false; |
|
| 367 | + if ( sizeof( $emails ) == 0 ) { |
|
| 368 | + return false; |
|
| 369 | + } |
|
| 362 | 370 | |
| 363 | 371 | return Sensei_WC::has_customer_bought_product( $user_id, $product_id ); |
| 364 | 372 | |
@@ -373,7 +381,9 @@ discard block |
||
| 373 | 381 | */ |
| 374 | 382 | public static function sensei_text_editor( $content = '', $editor_id = 'senseitexteditor', $input_name = '' ) { |
| 375 | 383 | |
| 376 | - if( ! $input_name ) $input_name = $editor_id; |
|
| 384 | + if( ! $input_name ) { |
|
| 385 | + $input_name = $editor_id; |
|
| 386 | + } |
|
| 377 | 387 | |
| 378 | 388 | $buttons = 'bold,italic,underline,strikethrough,blockquote,bullist,numlist,justifyleft,justifycenter,justifyright,undo,redo,pastetext'; |
| 379 | 389 | |
@@ -687,8 +697,7 @@ discard block |
||
| 687 | 697 | if ( $has_questions ) { |
| 688 | 698 | $status = 'passed'; // Force a pass |
| 689 | 699 | $metadata['grade'] = 0; |
| 690 | - } |
|
| 691 | - else { |
|
| 700 | + } else { |
|
| 692 | 701 | $status = 'complete'; |
| 693 | 702 | } |
| 694 | 703 | } |
@@ -736,7 +745,9 @@ discard block |
||
| 736 | 745 | public static function sensei_remove_user_from_lesson( $lesson_id = 0, $user_id = 0, $from_course = false ) { |
| 737 | 746 | |
| 738 | 747 | |
| 739 | - if( ! $lesson_id ) return false; |
|
| 748 | + if( ! $lesson_id ) { |
|
| 749 | + return false; |
|
| 750 | + } |
|
| 740 | 751 | |
| 741 | 752 | if( intval( $user_id ) == 0 ) { |
| 742 | 753 | $user_id = get_current_user_id(); |
@@ -774,7 +785,9 @@ discard block |
||
| 774 | 785 | public static function sensei_remove_user_from_course( $course_id = 0, $user_id = 0 ) { |
| 775 | 786 | |
| 776 | 787 | |
| 777 | - if( ! $course_id ) return false; |
|
| 788 | + if( ! $course_id ) { |
|
| 789 | + return false; |
|
| 790 | + } |
|
| 778 | 791 | |
| 779 | 792 | if( intval( $user_id ) == 0 ) { |
| 780 | 793 | $user_id = get_current_user_id(); |
@@ -842,8 +855,7 @@ discard block |
||
| 842 | 855 | if( $question ) { |
| 843 | 856 | if ( is_object( $question ) ) { |
| 844 | 857 | $user_answer_id = $question->comment_ID; |
| 845 | - } |
|
| 846 | - else { |
|
| 858 | + } else { |
|
| 847 | 859 | if( intval( $user_id ) == 0 ) { |
| 848 | 860 | $user_id = get_current_user_id(); |
| 849 | 861 | } |
@@ -870,8 +882,7 @@ discard block |
||
| 870 | 882 | if( $question ) { |
| 871 | 883 | if ( is_object( $question ) ) { |
| 872 | 884 | $user_answer_id = $question->comment_ID; |
| 873 | - } |
|
| 874 | - else { |
|
| 885 | + } else { |
|
| 875 | 886 | if( intval( $user_id ) == 0 ) { |
| 876 | 887 | $user_id = get_current_user_id(); |
| 877 | 888 | } |
@@ -937,8 +948,7 @@ discard block |
||
| 937 | 948 | if ( !empty($notes) ) { |
| 938 | 949 | $user_lesson_id = Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); |
| 939 | 950 | $activity_logged = update_comment_meta( $user_lesson_id, 'answer_note', $notes ); |
| 940 | - } |
|
| 941 | - else { |
|
| 951 | + } else { |
|
| 942 | 952 | $activity_logged = true; |
| 943 | 953 | } |
| 944 | 954 | } |
@@ -1305,7 +1315,7 @@ discard block |
||
| 1305 | 1315 | } |
| 1306 | 1316 | } |
| 1307 | 1317 | |
| 1308 | - }else{ |
|
| 1318 | + } else{ |
|
| 1309 | 1319 | |
| 1310 | 1320 | $course_id = Sensei()->lesson->get_course_id( $lesson_id ); |
| 1311 | 1321 | $a_element = '<a href="' . esc_url( get_permalink( $course_id ) ) . '" title="' . __( 'Sign Up', 'woothemes-sensei' ) . '">'; |
@@ -1472,8 +1482,7 @@ discard block |
||
| 1472 | 1482 | $lessons_completed++; |
| 1473 | 1483 | break; |
| 1474 | 1484 | } |
| 1475 | - } |
|
| 1476 | - else { |
|
| 1485 | + } else { |
|
| 1477 | 1486 | switch ( $lesson_status->comment_approved ) { |
| 1478 | 1487 | case 'complete': // Lesson has no quiz/questions |
| 1479 | 1488 | case 'graded': // Lesson has quiz, but it's not important what the grade was |
@@ -1522,11 +1531,9 @@ discard block |
||
| 1522 | 1531 | if( $course ) { |
| 1523 | 1532 | if ( is_object( $course ) && is_a( $course,'WP_Comment') ) { |
| 1524 | 1533 | $user_course_status = $course->comment_approved; |
| 1525 | - } |
|
| 1526 | - elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) { |
|
| 1534 | + } elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) { |
|
| 1527 | 1535 | $user_course_status = $course; |
| 1528 | - } |
|
| 1529 | - else { |
|
| 1536 | + } else { |
|
| 1530 | 1537 | |
| 1531 | 1538 | // check the user_id |
| 1532 | 1539 | if( ! $user_id ) { |
@@ -1601,11 +1608,9 @@ discard block |
||
| 1601 | 1608 | if ( is_object( $lesson ) ) { |
| 1602 | 1609 | $user_lesson_status = $lesson->comment_approved; |
| 1603 | 1610 | $lesson_id = $lesson->comment_post_ID; |
| 1604 | - } |
|
| 1605 | - elseif ( ! is_numeric( $lesson ) ) { |
|
| 1611 | + } elseif ( ! is_numeric( $lesson ) ) { |
|
| 1606 | 1612 | $user_lesson_status = $lesson; |
| 1607 | - } |
|
| 1608 | - else { |
|
| 1613 | + } else { |
|
| 1609 | 1614 | if( ! $user_id ) { |
| 1610 | 1615 | $user_id = get_current_user_id(); |
| 1611 | 1616 | } |
@@ -1618,8 +1623,7 @@ discard block |
||
| 1618 | 1623 | |
| 1619 | 1624 | if ( $_user_lesson_status ) { |
| 1620 | 1625 | $user_lesson_status = $_user_lesson_status->comment_approved; |
| 1621 | - } |
|
| 1622 | - else { |
|
| 1626 | + } else { |
|
| 1623 | 1627 | return false; // No status means not complete |
| 1624 | 1628 | } |
| 1625 | 1629 | $lesson_id = $lesson; |
@@ -1720,7 +1724,9 @@ discard block |
||
| 1720 | 1724 | |
| 1721 | 1725 | public static function user_passed_quiz( $quiz_id = 0, $user_id = 0 ) { |
| 1722 | 1726 | |
| 1723 | - if( ! $quiz_id ) return false; |
|
| 1727 | + if( ! $quiz_id ) { |
|
| 1728 | + return false; |
|
| 1729 | + } |
|
| 1724 | 1730 | |
| 1725 | 1731 | if( ! $user_id ) { |
| 1726 | 1732 | $user_id = get_current_user_id(); |
@@ -1959,7 +1965,7 @@ discard block |
||
| 1959 | 1965 | $start_function = 'user_start_'.$post_type; |
| 1960 | 1966 | $sensei_user_activity_id = self::$start_function( $user_id, $post_id ); |
| 1961 | 1967 | |
| 1962 | - }else{ |
|
| 1968 | + } else{ |
|
| 1963 | 1969 | |
| 1964 | 1970 | $sensei_user_activity_id = $sensei_user_status->comment_ID; |
| 1965 | 1971 | |
@@ -2176,7 +2182,7 @@ discard block |
||
| 2176 | 2182 | |
| 2177 | 2183 | return round( $val, $precision, $mode ); |
| 2178 | 2184 | |
| 2179 | - }else{ |
|
| 2185 | + } else{ |
|
| 2180 | 2186 | |
| 2181 | 2187 | return round( $val, $precision ); |
| 2182 | 2188 | |
@@ -110,9 +110,12 @@ |
||
| 110 | 110 | ?> |
| 111 | 111 | |
| 112 | 112 | </form> |
| 113 | - <?php else: ?> |
|
| 113 | + <?php else { |
|
| 114 | + : ?> |
|
| 114 | 115 | |
| 115 | - <div class="sensei-message alert"> <?php _e( 'There are no questions for this Quiz yet. Check back soon.', 'woothemes-sensei' ); ?></div> |
|
| 116 | + <div class="sensei-message alert"> <?php _e( 'There are no questions for this Quiz yet. Check back soon.', 'woothemes-sensei' ); |
|
| 117 | +} |
|
| 118 | +?></div> |
|
| 116 | 119 | |
| 117 | 120 | <?php endif; // End If have questions ?> |
| 118 | 121 | |
@@ -1,5 +1,8 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly |
|
| 2 | +if ( ! defined( 'ABSPATH' ) ) { |
|
| 3 | + exit; |
|
| 4 | +} |
|
| 5 | +// Exit if accessed directly |
|
| 3 | 6 | |
| 4 | 7 | /** |
| 5 | 8 | * Sensei Lessons Class |
@@ -380,8 +383,7 @@ discard block |
||
| 380 | 383 | $quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id ); |
| 381 | 384 | if( 0 < count( $quiz_questions ) ) { |
| 382 | 385 | update_post_meta( $post_id, '_quiz_has_questions', '1' ); |
| 383 | - } |
|
| 384 | - else { |
|
| 386 | + } else { |
|
| 385 | 387 | delete_post_meta( $post_id, '_quiz_has_questions' ); |
| 386 | 388 | } |
| 387 | 389 | |
@@ -392,7 +394,9 @@ discard block |
||
| 392 | 394 | |
| 393 | 395 | public function get_submitted_setting_value( $field = false ) { |
| 394 | 396 | |
| 395 | - if( ! $field ) return; |
|
| 397 | + if( ! $field ) { |
|
| 398 | + return; |
|
| 399 | + } |
|
| 396 | 400 | |
| 397 | 401 | $value = false; |
| 398 | 402 | |
@@ -1509,7 +1513,7 @@ discard block |
||
| 1509 | 1513 | |
| 1510 | 1514 | $field_name = 'answer_feedback_boolean'; |
| 1511 | 1515 | |
| 1512 | - }elseif( 'multiple-choice' == $question_type ){ |
|
| 1516 | + } elseif( 'multiple-choice' == $question_type ){ |
|
| 1513 | 1517 | |
| 1514 | 1518 | $field_name = 'answer_feedback_multiple_choice'; |
| 1515 | 1519 | |
@@ -1605,7 +1609,9 @@ discard block |
||
| 1605 | 1609 | |
| 1606 | 1610 | $html = ''; |
| 1607 | 1611 | |
| 1608 | - if( ! $lesson_id && ! $quiz_id ) return $html; |
|
| 1612 | + if( ! $lesson_id && ! $quiz_id ) { |
|
| 1613 | + return $html; |
|
| 1614 | + } |
|
| 1609 | 1615 | |
| 1610 | 1616 | $settings = $this->get_quiz_settings( $quiz_id ); |
| 1611 | 1617 | |
@@ -2281,11 +2287,11 @@ discard block |
||
| 2281 | 2287 | |
| 2282 | 2288 | $answer_feedback = $data[ 'answer_feedback_boolean' ]; |
| 2283 | 2289 | |
| 2284 | - }elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){ |
|
| 2290 | + } elseif( isset( $data[ 'answer_feedback_multiple_choice' ] ) && !empty( $data[ 'answer_feedback_multiple_choice' ] ) ){ |
|
| 2285 | 2291 | |
| 2286 | 2292 | $answer_feedback = $data[ 'answer_feedback_multiple_choice' ]; |
| 2287 | 2293 | |
| 2288 | - }elseif( isset( $data[ 'answer_feedback' ] ) ){ |
|
| 2294 | + } elseif( isset( $data[ 'answer_feedback' ] ) ){ |
|
| 2289 | 2295 | |
| 2290 | 2296 | $answer_feedback = $data[ 'answer_feedback' ]; |
| 2291 | 2297 | |
@@ -2298,8 +2304,7 @@ discard block |
||
| 2298 | 2304 | // Handle the extended question text |
| 2299 | 2305 | if ( isset( $data[ 'question_description' ] ) && ( '' != $data[ 'question_description' ] ) ) { |
| 2300 | 2306 | $post_content = $data[ 'question_description' ]; |
| 2301 | - } |
|
| 2302 | - else { |
|
| 2307 | + } else { |
|
| 2303 | 2308 | $post_content = ''; |
| 2304 | 2309 | } |
| 2305 | 2310 | // Question Query Arguments |
@@ -2507,8 +2512,7 @@ discard block |
||
| 2507 | 2512 | 'key' => '_lesson_course', |
| 2508 | 2513 | 'value' => $course_id, |
| 2509 | 2514 | ); |
| 2510 | - } |
|
| 2511 | - else { |
|
| 2515 | + } else { |
|
| 2512 | 2516 | // Simple check for connection to a Course |
| 2513 | 2517 | $post_args['meta_query'][] = array( |
| 2514 | 2518 | 'key' => '_lesson_course', |
@@ -2636,9 +2640,13 @@ discard block |
||
| 2636 | 2640 | // Fetch each question in the order in which they were asked |
| 2637 | 2641 | $questions = array(); |
| 2638 | 2642 | foreach( $selected_questions as $question_id ) { |
| 2639 | - if( ! $question_id ) continue; |
|
| 2643 | + if( ! $question_id ) { |
|
| 2644 | + continue; |
|
| 2645 | + } |
|
| 2640 | 2646 | $question = get_post( $question_id ); |
| 2641 | - if( ! isset( $question ) || ! isset( $question->ID ) ) continue; |
|
| 2647 | + if( ! isset( $question ) || ! isset( $question->ID ) ) { |
|
| 2648 | + continue; |
|
| 2649 | + } |
|
| 2642 | 2650 | $questions[] = $question; |
| 2643 | 2651 | } |
| 2644 | 2652 | |
@@ -2651,7 +2659,9 @@ discard block |
||
| 2651 | 2659 | |
| 2652 | 2660 | // Set array of questions that already exist so we can prevent duplicates from appearing |
| 2653 | 2661 | foreach( $questions_array as $question ) { |
| 2654 | - if( 'question' != $question->post_type ) continue; |
|
| 2662 | + if( 'question' != $question->post_type ) { |
|
| 2663 | + continue; |
|
| 2664 | + } |
|
| 2655 | 2665 | $existing_questions[] = $question->ID; |
| 2656 | 2666 | } |
| 2657 | 2667 | |
@@ -2691,7 +2701,9 @@ discard block |
||
| 2691 | 2701 | |
| 2692 | 2702 | // Add selected questions to existing questions array to prevent duplicates from being added |
| 2693 | 2703 | foreach( $questions_array as $cat_question ) { |
| 2694 | - if( in_array( $cat_question->ID, $existing_questions ) ) continue; |
|
| 2704 | + if( in_array( $cat_question->ID, $existing_questions ) ) { |
|
| 2705 | + continue; |
|
| 2706 | + } |
|
| 2695 | 2707 | $existing_questions[] = $cat_question->ID; |
| 2696 | 2708 | } |
| 2697 | 2709 | } |
@@ -3525,7 +3537,7 @@ discard block |
||
| 3525 | 3537 | |
| 3526 | 3538 | $message = sprintf( __( 'This is a preview lesson. Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element ); |
| 3527 | 3539 | |
| 3528 | - }else{ |
|
| 3540 | + } else{ |
|
| 3529 | 3541 | |
| 3530 | 3542 | $message = sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element ); |
| 3531 | 3543 | |
@@ -3547,7 +3559,7 @@ discard block |
||
| 3547 | 3559 | |
| 3548 | 3560 | $message = sprintf( __( 'This is a preview lesson. Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element ); |
| 3549 | 3561 | |
| 3550 | - }else{ |
|
| 3562 | + } else{ |
|
| 3551 | 3563 | |
| 3552 | 3564 | $message = sprintf( __( 'Please purchase the %1$s before starting the lesson.', 'woothemes-sensei' ), $a_element ); |
| 3553 | 3565 | |