@@ -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 |
@@ -181,8 +184,7 @@ discard block |
||
| 181 | 184 | // ...use a filter to switch the encoding back |
| 182 | 185 | add_filter( 'comments_clauses', array( __CLASS__, 'comment_multiple_status_filter' ) ); |
| 183 | 186 | } |
| 184 | - } |
|
| 185 | - else { |
|
| 187 | + } else { |
|
| 186 | 188 | $args['status'] = 'any'; // 'log' == 'sensei_user_answer' |
| 187 | 189 | } |
| 188 | 190 | |
@@ -307,8 +309,12 @@ discard block |
||
| 307 | 309 | } |
| 308 | 310 | |
| 309 | 311 | foreach( $activities as $activity ) { |
| 310 | - if( '' == $activity->comment_type ) continue; |
|
| 311 | - if( strpos( 'sensei_', $activity->comment_type ) != 0 ) continue; |
|
| 312 | + if( '' == $activity->comment_type ) { |
|
| 313 | + continue; |
|
| 314 | + } |
|
| 315 | + if( strpos( 'sensei_', $activity->comment_type ) != 0 ) { |
|
| 316 | + continue; |
|
| 317 | + } |
|
| 312 | 318 | $dataset_changes = wp_delete_comment( intval( $activity->comment_ID ), true ); |
| 313 | 319 | wp_cache_flush(); |
| 314 | 320 | } |
@@ -360,11 +366,13 @@ discard block |
||
| 360 | 366 | $emails[] = $user->user_email; |
| 361 | 367 | } |
| 362 | 368 | |
| 363 | - if ( is_email( $customer_email ) ) |
|
| 364 | - $emails[] = $customer_email; |
|
| 369 | + if ( is_email( $customer_email ) ) { |
|
| 370 | + $emails[] = $customer_email; |
|
| 371 | + } |
|
| 365 | 372 | |
| 366 | - if ( sizeof( $emails ) == 0 ) |
|
| 367 | - return false; |
|
| 373 | + if ( sizeof( $emails ) == 0 ) { |
|
| 374 | + return false; |
|
| 375 | + } |
|
| 368 | 376 | |
| 369 | 377 | return Sensei_WC::has_customer_bought_product( $user_id, $product_id ); |
| 370 | 378 | |
@@ -379,7 +387,9 @@ discard block |
||
| 379 | 387 | */ |
| 380 | 388 | public static function sensei_text_editor( $content = '', $editor_id = 'senseitexteditor', $input_name = '' ) { |
| 381 | 389 | |
| 382 | - if( ! $input_name ) $input_name = $editor_id; |
|
| 390 | + if( ! $input_name ) { |
|
| 391 | + $input_name = $editor_id; |
|
| 392 | + } |
|
| 383 | 393 | |
| 384 | 394 | $buttons = 'bold,italic,underline,strikethrough,blockquote,bullist,numlist,justifyleft,justifycenter,justifyright,undo,redo,pastetext'; |
| 385 | 395 | |
@@ -689,8 +699,7 @@ discard block |
||
| 689 | 699 | if ( $has_questions ) { |
| 690 | 700 | $status = 'passed'; // Force a pass |
| 691 | 701 | $metadata['grade'] = 0; |
| 692 | - } |
|
| 693 | - else { |
|
| 702 | + } else { |
|
| 694 | 703 | $status = 'complete'; |
| 695 | 704 | } |
| 696 | 705 | } |
@@ -738,7 +747,9 @@ discard block |
||
| 738 | 747 | public static function sensei_remove_user_from_lesson( $lesson_id = 0, $user_id = 0, $from_course = false ) { |
| 739 | 748 | |
| 740 | 749 | |
| 741 | - if( ! $lesson_id ) return false; |
|
| 750 | + if( ! $lesson_id ) { |
|
| 751 | + return false; |
|
| 752 | + } |
|
| 742 | 753 | |
| 743 | 754 | if( intval( $user_id ) == 0 ) { |
| 744 | 755 | $user_id = get_current_user_id(); |
@@ -776,7 +787,9 @@ discard block |
||
| 776 | 787 | public static function sensei_remove_user_from_course( $course_id = 0, $user_id = 0 ) { |
| 777 | 788 | |
| 778 | 789 | |
| 779 | - if( ! $course_id ) return false; |
|
| 790 | + if( ! $course_id ) { |
|
| 791 | + return false; |
|
| 792 | + } |
|
| 780 | 793 | |
| 781 | 794 | if( intval( $user_id ) == 0 ) { |
| 782 | 795 | $user_id = get_current_user_id(); |
@@ -844,8 +857,7 @@ discard block |
||
| 844 | 857 | if( $question ) { |
| 845 | 858 | if ( is_object( $question ) ) { |
| 846 | 859 | $user_answer_id = $question->comment_ID; |
| 847 | - } |
|
| 848 | - else { |
|
| 860 | + } else { |
|
| 849 | 861 | if( intval( $user_id ) == 0 ) { |
| 850 | 862 | $user_id = get_current_user_id(); |
| 851 | 863 | } |
@@ -872,8 +884,7 @@ discard block |
||
| 872 | 884 | if( $question ) { |
| 873 | 885 | if ( is_object( $question ) ) { |
| 874 | 886 | $user_answer_id = $question->comment_ID; |
| 875 | - } |
|
| 876 | - else { |
|
| 887 | + } else { |
|
| 877 | 888 | if( intval( $user_id ) == 0 ) { |
| 878 | 889 | $user_id = get_current_user_id(); |
| 879 | 890 | } |
@@ -938,8 +949,7 @@ discard block |
||
| 938 | 949 | if ( !empty($notes) ) { |
| 939 | 950 | $user_lesson_id = WooThemes_Sensei_Utils::sensei_get_activity_value( array( 'post_id' => $question_id, 'user_id' => $user_id, 'type' => 'sensei_user_answer', 'field' => 'comment_ID' ) ); |
| 940 | 951 | $activity_logged = update_comment_meta( $user_lesson_id, 'answer_note', $notes ); |
| 941 | - } |
|
| 942 | - else { |
|
| 952 | + } else { |
|
| 943 | 953 | $activity_logged = true; |
| 944 | 954 | } |
| 945 | 955 | } |
@@ -1451,8 +1461,7 @@ discard block |
||
| 1451 | 1461 | $lessons_completed++; |
| 1452 | 1462 | break; |
| 1453 | 1463 | } |
| 1454 | - } |
|
| 1455 | - else { |
|
| 1464 | + } else { |
|
| 1456 | 1465 | switch ( $lesson_status->comment_approved ) { |
| 1457 | 1466 | case 'complete': // Lesson has no quiz/questions |
| 1458 | 1467 | case 'graded': // Lesson has quiz, but it's not important what the grade was |
@@ -1500,11 +1509,9 @@ discard block |
||
| 1500 | 1509 | if( $course ) { |
| 1501 | 1510 | if ( is_object( $course ) && is_a( $course,'WP_Comment') ) { |
| 1502 | 1511 | $user_course_status = $course->comment_approved; |
| 1503 | - } |
|
| 1504 | - elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) { |
|
| 1512 | + } elseif ( !is_numeric( $course ) && ! is_a( $course,'WP_Post') ) { |
|
| 1505 | 1513 | $user_course_status = $course; |
| 1506 | - } |
|
| 1507 | - else { |
|
| 1514 | + } else { |
|
| 1508 | 1515 | if( ! $user_id ) { |
| 1509 | 1516 | $user_id = get_current_user_id(); |
| 1510 | 1517 | } |
@@ -1564,11 +1571,9 @@ discard block |
||
| 1564 | 1571 | if ( is_object( $lesson ) ) { |
| 1565 | 1572 | $user_lesson_status = $lesson->comment_approved; |
| 1566 | 1573 | $lesson_id = $lesson->comment_post_ID; |
| 1567 | - } |
|
| 1568 | - elseif ( ! is_numeric( $lesson ) ) { |
|
| 1574 | + } elseif ( ! is_numeric( $lesson ) ) { |
|
| 1569 | 1575 | $user_lesson_status = $lesson; |
| 1570 | - } |
|
| 1571 | - else { |
|
| 1576 | + } else { |
|
| 1572 | 1577 | if( ! $user_id ) { |
| 1573 | 1578 | $user_id = get_current_user_id(); |
| 1574 | 1579 | } |
@@ -1581,8 +1586,7 @@ discard block |
||
| 1581 | 1586 | |
| 1582 | 1587 | if ( $_user_lesson_status ) { |
| 1583 | 1588 | $user_lesson_status = $_user_lesson_status->comment_approved; |
| 1584 | - } |
|
| 1585 | - else { |
|
| 1589 | + } else { |
|
| 1586 | 1590 | return false; // No status means not complete |
| 1587 | 1591 | } |
| 1588 | 1592 | $lesson_id = $lesson; |
@@ -1683,7 +1687,9 @@ discard block |
||
| 1683 | 1687 | |
| 1684 | 1688 | public static function user_passed_quiz( $quiz_id = 0, $user_id = 0 ) { |
| 1685 | 1689 | |
| 1686 | - if( ! $quiz_id ) return false; |
|
| 1690 | + if( ! $quiz_id ) { |
|
| 1691 | + return false; |
|
| 1692 | + } |
|
| 1687 | 1693 | |
| 1688 | 1694 | if( ! $user_id ) { |
| 1689 | 1695 | $user_id = get_current_user_id(); |
@@ -1921,7 +1927,7 @@ discard block |
||
| 1921 | 1927 | $start_function = 'user_start_'.$post_type; |
| 1922 | 1928 | $sensei_user_activity_id = self::$start_function( $user_id, $post_id ); |
| 1923 | 1929 | |
| 1924 | - }else{ |
|
| 1930 | + } else{ |
|
| 1925 | 1931 | |
| 1926 | 1932 | $sensei_user_activity_id = $sensei_user_status->comment_ID; |
| 1927 | 1933 | |
@@ -2138,7 +2144,7 @@ discard block |
||
| 2138 | 2144 | |
| 2139 | 2145 | return round( $val, $precision, $mode ); |
| 2140 | 2146 | |
| 2141 | - }else{ |
|
| 2147 | + } else{ |
|
| 2142 | 2148 | |
| 2143 | 2149 | return round( $val, $precision ); |
| 2144 | 2150 | |
@@ -181,7 +181,9 @@ discard block |
||
| 181 | 181 | * @return void |
| 182 | 182 | */ |
| 183 | 183 | function sensei_recent_comments_widget_filter( $widget_args = array() ) { |
| 184 | - if ( ! isset( $widget_args['post_type'] ) ) $widget_args['post_type'] = array( 'post', 'page' ); |
|
| 184 | + if ( ! isset( $widget_args['post_type'] ) ) { |
|
| 185 | + $widget_args['post_type'] = array( 'post', 'page' ); |
|
| 186 | + } |
|
| 185 | 187 | return $widget_args; |
| 186 | 188 | } // End sensei_recent_comments_widget_filter() |
| 187 | 189 | add_filter( 'widget_comments_args', 'sensei_recent_comments_widget_filter', 10, 1 ); |
@@ -196,8 +198,9 @@ discard block |
||
| 196 | 198 | function sensei_course_archive_filter( $query ) { |
| 197 | 199 | |
| 198 | 200 | |
| 199 | - if ( ! $query->is_main_query() ) |
|
| 200 | - return; |
|
| 201 | + if ( ! $query->is_main_query() ) { |
|
| 202 | + return; |
|
| 203 | + } |
|
| 201 | 204 | |
| 202 | 205 | // Apply Filter only if on frontend and when course archive is running |
| 203 | 206 | $course_page_id = intval( Sensei()->settings->settings[ 'course_page' ] ); |
@@ -412,7 +415,7 @@ discard block |
||
| 412 | 415 | |
| 413 | 416 | return false; |
| 414 | 417 | |
| 415 | - }else{ |
|
| 418 | + } else{ |
|
| 416 | 419 | |
| 417 | 420 | return true; |
| 418 | 421 | |
@@ -446,7 +449,7 @@ discard block |
||
| 446 | 449 | |
| 447 | 450 | $wp_query = $modules_query; |
| 448 | 451 | |
| 449 | - }else{ |
|
| 452 | + } else{ |
|
| 450 | 453 | |
| 451 | 454 | wp_reset_query(); |
| 452 | 455 | |
@@ -478,7 +481,7 @@ discard block |
||
| 478 | 481 | |
| 479 | 482 | return have_posts(); |
| 480 | 483 | |
| 481 | - }else{ |
|
| 484 | + } else{ |
|
| 482 | 485 | |
| 483 | 486 | // if the loop has not been initiated check the first module has lessons |
| 484 | 487 | if( -1 == $sensei_modules_loop[ 'current' ] ){ |
@@ -622,7 +625,7 @@ discard block |
||
| 622 | 625 | |
| 623 | 626 | return true; |
| 624 | 627 | |
| 625 | - }else{ |
|
| 628 | + } else{ |
|
| 626 | 629 | |
| 627 | 630 | return false; |
| 628 | 631 | |
@@ -865,7 +868,9 @@ discard block |
||
| 865 | 868 | */ |
| 866 | 869 | function get_sensei_header(){ |
| 867 | 870 | |
| 868 | - if ( ! defined( 'ABSPATH' ) ) exit; |
|
| 871 | + if ( ! defined( 'ABSPATH' ) ) { |
|
| 872 | + exit; |
|
| 873 | + } |
|
| 869 | 874 | |
| 870 | 875 | get_header(); |
| 871 | 876 | |