Skip to content

Commit

Permalink
deploy: bcd43ea
Browse files Browse the repository at this point in the history
  • Loading branch information
m1r0 committed Oct 3, 2023
1 parent e730beb commit 7c933d5
Show file tree
Hide file tree
Showing 39 changed files with 98 additions and 79 deletions.
8 changes: 4 additions & 4 deletions includes_class-sensei-admin.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ <h1 class="page-title">Source: includes/class-sensei-admin.php</h1>
}

// Persist new lesson order to course meta.
$new_lesson_order_string = join( ',', $new_lesson_order );
$new_lesson_order_string = implode( ',', $new_lesson_order );
update_post_meta( $course_id, '_lesson_order', $new_lesson_order_string );
}

Expand Down Expand Up @@ -917,7 +917,7 @@ <h1 class="page-title">Source: includes/class-sensei-admin.php</h1>
if ( ! is_wp_error( $new_post_id ) ) {

$post_meta = get_post_custom( $post->ID );
if ( $post_meta &amp;&amp; count( $post_meta ) > 0 ) {
if ( $post_meta ) {

/**
* Ignored meta fields when duplicating a post.
Expand Down Expand Up @@ -1121,7 +1121,7 @@ <h1 class="page-title">Source: includes/class-sensei-admin.php</h1>

$html = '';

if ( 0 == count( $settings ) ) {
if ( ! $settings ) {
return $html;
}

Expand Down Expand Up @@ -1412,7 +1412,7 @@ <h1 class="page-title">Source: includes/class-sensei-admin.php</h1>

$courses = Sensei()->course->get_all_courses();

if ( 0 &lt; count( $courses ) ) {
if ( $courses ) {

// order the courses as set by the users
$all_course_ids = array();
Expand Down
10 changes: 6 additions & 4 deletions includes_class-sensei-course.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -1917,7 +1917,7 @@ <h1 class="page-title">Source: includes/class-sensei-course.php</h1>
// Get Course Categories
$category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );

$active_html .= '&lt;article class="' . esc_attr( join( ' ', get_post_class( [ 'course', 'post' ], $course_item->ID ) ) ) . '">';
$active_html .= '&lt;article class="' . esc_attr( implode( ' ', get_post_class( [ 'course', 'post' ], $course_item->ID ) ) ) . '">';

// Image
$active_html .= Sensei()->course->course_image( absint( $course_item->ID ), '100', '100', true );
Expand Down Expand Up @@ -2058,7 +2058,7 @@ <h1 class="page-title">Source: includes/class-sensei-course.php</h1>
// Get Course Categories
$category_output = get_the_term_list( $course_item->ID, 'course-category', '', ', ', '' );

$complete_html .= '&lt;article class="' . esc_attr( join( ' ', get_post_class( [ 'course', 'post' ], $course_item->ID ) ) ) . '">';
$complete_html .= '&lt;article class="' . esc_attr( implode( ' ', get_post_class( [ 'course', 'post' ], $course_item->ID ) ) ) . '">';

// Image
$complete_html .= Sensei()->course->course_image( absint( $course_item->ID ), 100, 100, true );
Expand Down Expand Up @@ -4089,9 +4089,10 @@ <h1 class="page-title">Source: includes/class-sensei-course.php</h1>
public function log_initial_publish_event( $course ) {
$product_ids = get_post_meta( $course->ID, '_course_woocommerce_product', false );
$product_count = empty( $product_ids ) ? 0 : count( array_filter( $product_ids, 'is_numeric' ) );
$modules = wp_get_post_terms( $course->ID, 'module' );

$event_properties = [
'module_count' => count( wp_get_post_terms( $course->ID, 'module' ) ),
'module_count' => is_countable( $modules ) ? count( $modules ) : 0,
'lesson_count' => $this->course_lesson_count( $course->ID ),
'product_count' => $product_count,
'sample_course' => Sensei_Data_Port_Manager::SAMPLE_COURSE_SLUG === $course->post_name ? 1 : 0,
Expand Down Expand Up @@ -4181,6 +4182,7 @@ <h1 class="page-title">Source: includes/class-sensei-course.php</h1>
$content = $post->post_content;
$product_ids = get_post_meta( $course_id, '_course_woocommerce_product', false );
$product_count = empty( $product_ids ) ? 0 : count( array_filter( $product_ids, 'is_numeric' ) );
$modules = wp_get_post_terms( $course_id, 'module' );

$event_properties = [
'course_id' => $course_id,
Expand All @@ -4189,7 +4191,7 @@ <h1 class="page-title">Source: includes/class-sensei-course.php</h1>
'has_take_course_block' => has_block( 'sensei-lms/button-take-course', $content ) ? 1 : 0,
'has_contact_teacher_block' => has_block( 'sensei-lms/button-contact-teacher', $content ) ? 1 : 0,
'has_conditional_content_block' => has_block( 'sensei-lms/conditional-content', $content ) ? 1 : 0,
'module_count' => count( wp_get_post_terms( $course_id, 'module' ) ),
'module_count' => is_countable( $modules ) ? count( $modules ) : 0,
'lesson_count' => $this->course_lesson_count( $course_id ),
'product_count' => $product_count,
'sample_course' => Sensei_Data_Port_Manager::SAMPLE_COURSE_SLUG === $post->post_name ? 1 : 0,
Expand Down
4 changes: 2 additions & 2 deletions includes_class-sensei-frontend.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ <h1 class="page-title">Source: includes/class-sensei-frontend.php</h1>
public function lesson_tags_display( $lesson_id = 0 ) {
if ( $lesson_id ) {
$tags = wp_get_post_terms( $lesson_id, 'lesson-tag' );
if ( $tags &amp;&amp; count( $tags ) > 0 ) {
if ( $tags ) {
$tag_list = '';
foreach ( $tags as $tag ) {
$tag_link = get_term_link( $tag, 'lesson-tag' );
Expand Down Expand Up @@ -1031,7 +1031,7 @@ <h1 class="page-title">Source: includes/class-sensei-frontend.php</h1>
the_post();
?>

&lt;article class="&lt;?php echo esc_attr( join( ' ', get_post_class( array( 'course', 'post' ), get_the_ID() ) ) ); ?>">
&lt;article class="&lt;?php echo esc_attr( implode( ' ', get_post_class( array( 'course', 'post' ), get_the_ID() ) ) ); ?>">

&lt;?php do_action( 'sensei_course_archive_meta' ); ?>

Expand Down
2 changes: 1 addition & 1 deletion includes_class-sensei-grading-user-quiz.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ <h1 class="page-title">Source: includes/class-sensei-grading-user-quiz.php</h1>
*/
$possibly_new_args = apply_filters( 'sensei_grading_display_quiz_question', null, $type, $question_id, $right_answer, $user_answer_content );

if ( null !== $possibly_new_args &amp;&amp; 0 &lt; count( $possibly_new_args ) ) {
if ( null !== $possibly_new_args &amp;&amp; $possibly_new_args ) {
$type_name = $possibly_new_args['type_name'] ?? $type_name;
$right_answer = $possibly_new_args['right_answer'] ?? $right_answer;
$user_answer_content = $possibly_new_args['user_answer_content'] ?? $user_answer_content;
Expand Down
2 changes: 1 addition & 1 deletion includes_class-sensei-guest-user.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ <h1 class="page-title">Source: includes/class-sensei-guest-user.php</h1>
public function log_guest_user_out_before_all_actions() {
if (
is_user_logged_in() &amp;&amp;
$this->is_current_user_guest()
self::is_current_user_guest()
) {
$this->guest_user_id = get_current_user_id();
wp_set_current_user( 0 );
Expand Down
22 changes: 9 additions & 13 deletions includes_class-sensei-learner.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -781,21 +781,17 @@ <h1 class="page-title">Source: includes/class-sensei-learner.php</h1>
$learner_manager = self::instance();
$controller = new Sensei_Learners_Admin_Bulk_Actions_Controller( new Sensei_Learner_Management( '' ), $learner_manager );
$base_query_args = [ 'posts_per_page' => -1 ];
$posts = $learner_manager->get_enrolled_courses_query( $user_id, $base_query_args )->posts;
$courses = 0;
if ( $posts ) {
// We only want to show courses after the third one in the UI.
$courses = array_slice( $posts, 3 );
}
$courses_query = $learner_manager->get_enrolled_courses_query( $user_id, $base_query_args );

// We only want to show courses after the third one in the UI.
$courses = array_slice( $courses_query->posts, 3 );

$html_items = [];
if ( count( $courses ) > 0 ) {
foreach ( $courses as $course ) {
$html_items[] = '&lt;a href="' . esc_url( $controller->get_learner_management_course_url( $course->ID ) ) .
'" class="sensei-students__enrolled-course" data-course-id="' . esc_attr( $course->ID ) . '">' .
esc_html( $course->post_title ) .
'&lt;/a>';
}
foreach ( $courses as $course ) {
$html_items[] = '&lt;a href="' . esc_url( $controller->get_learner_management_course_url( $course->ID ) ) .
'" class="sensei-students__enrolled-course" data-course-id="' . intval( $course->ID ) . '">' .
esc_html( $course->post_title ) .
'&lt;/a>';
}
wp_send_json_success( $html_items );
exit();
Expand Down
40 changes: 28 additions & 12 deletions includes_class-sensei-lesson.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
$post = get_post( $post_id );
$blocks = parse_blocks( $post->post_content );

if ( 0 === count( $blocks ) || 'sensei-lms/featured-video' !== $blocks[0]['blockName'] ) {
if ( ! $blocks || 'sensei-lms/featured-video' !== $blocks[0]['blockName'] ) {
return null;
}

Expand Down Expand Up @@ -1057,7 +1057,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
update_post_meta( $post_id, '_lesson_quiz', $quiz_id );
// Mark if the Lesson Quiz has questions
$quiz_questions = Sensei()->lesson->lesson_quiz_questions( $quiz_id );
if ( 0 &lt; count( $quiz_questions ) ) {
if ( $quiz_questions ) {
update_post_meta( $post_id, '_quiz_has_questions', '1' );
} else {
delete_post_meta( $post_id, '_quiz_has_questions' );
Expand Down Expand Up @@ -1438,7 +1438,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>

$html = '';

if ( count( $questions ) > 0 ) {
if ( $questions ) {
$question_counter = 1;

foreach ( $questions as $question ) {
Expand Down Expand Up @@ -1488,9 +1488,18 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
public function quiz_panel_question( $question_type = '', $question_counter = 0, $question_id = 0, $context = 'quiz', $multiple_data = array() ) {
global $row_counter;

$html = '';
$random_order = null;
$question_grade = null;
$question_media_add_button = '';
$question_media_delete_class = '';
$question_media_link_class = '';
$question_media_link = '';
$question_media_thumb_class = '';
$question_media_thumb = '';
$question_media = '';
$html = '';
$question_class = '';

$question_class = '';
if ( 'quiz' == $context ) {
if ( ! $row_counter || ! isset( $row_counter ) ) {
$row_counter = 1;
Expand Down Expand Up @@ -1558,7 +1567,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
$question = get_post( $question_id );
$html .= '&lt;td class="table-count question-number question-count-column">&lt;span class="number">' . esc_html( $question_counter ) . '&lt;/span>&lt;/td>';
$html .= '&lt;td>' . esc_html( $question->post_title ) . '&lt;/td>';
$html .= '&lt;td class="question-grade-column">' . esc_html( $question_grade ) . '&lt;/td>';
$html .= '&lt;td class="question-grade-column">' . esc_html( (string) $question_grade ) . '&lt;/td>';
$question_types_filtered = ucwords( str_replace( array( 'boolean', 'multiple-choice', 'gap-fill', 'single-line', 'multi-line', 'file-upload' ), array( __( 'True/False', 'sensei-lms' ), __( 'Multiple Choice', 'sensei-lms' ), __( 'Gap Fill', 'sensei-lms' ), __( 'Single Line', 'sensei-lms' ), __( 'Multi Line', 'sensei-lms' ), __( 'File Upload', 'sensei-lms' ) ), $question_type ) );
$html .= '&lt;td>' . esc_html( $question_types_filtered ) . '&lt;/td>';

Expand Down Expand Up @@ -1616,7 +1625,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
// Question grade
$html .= '&lt;div>';
$html .= '&lt;label for="question_' . esc_attr( $question_counter ) . '_grade">' . esc_html__( 'Grade:', 'sensei-lms' ) . '&lt;/label> ';
$html .= '&lt;input type="number" id="question_' . esc_attr( $question_counter ) . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . esc_attr( $question_grade ) . '" />';
$html .= '&lt;input type="number" id="question_' . esc_attr( $question_counter ) . '_grade" class="question_grade small-text" name="question_grade" min="0" value="' . esc_attr( (string) $question_grade ) . '" />';
$html .= '&lt;/div>';

// Random order
Expand All @@ -1632,7 +1641,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
$html .= '&lt;button id="question_' . esc_attr( $question_counter ) . '_media_button" class="upload_media_file_button button-secondary" data-uploader-title="' . esc_attr__( 'Add file to question', 'sensei-lms' ) . '" data-uploader-button-text="' . esc_attr__( 'Add to question', 'sensei-lms' ) . '">' . esc_html( $question_media_add_button ) . '&lt;/button>';
$html .= '&lt;button id="question_' . esc_attr( $question_counter ) . '_media_button_delete" class="delete_media_file_button button-secondary ' . esc_attr( $question_media_delete_class ) . '">' . esc_html__( 'Delete file', 'sensei-lms' ) . '&lt;/button>&lt;br/>';
$html .= '&lt;span id="question_' . esc_attr( $question_counter ) . '_media_link" class="question_media_link ' . esc_attr( $question_media_link_class ) . '">' . wp_kses_post( $question_media_link ) . '&lt;/span>';
$html .= '&lt;br/>&lt;img id="question_' . esc_attr( $question_counter ) . '_media_preview" class="question_media_preview ' . esc_attr( $question_media_thumb_class ) . '" src="' . esc_url( $question_media_thumb ) . '" />&lt;br/>';
$html .= '&lt;br/>&lt;img id="question_' . esc_attr( $question_counter ) . '_media_preview" class="question_media_preview ' . esc_attr( $question_media_thumb_class ) . '" src="' . esc_url( (string) $question_media_thumb ) . '" />&lt;br/>';
$html .= '&lt;input type="hidden" id="question_' . esc_attr( $question_counter ) . '_media" class="question_media" name="question_media" value="' . esc_attr( $question_media ) . '" />';
$html .= '&lt;/div>';

Expand Down Expand Up @@ -2900,6 +2909,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
* @access public
*/
public function lesson_update_question() {
$nonce = '';
// Add nonce security to the request.
if ( isset( $_POST['lesson_update_question_nonce'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification
Expand Down Expand Up @@ -3184,6 +3194,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
}

public function lesson_update_grade_type() {
$nonce = '';
// Add nonce security to the request
if ( isset( $_POST['lesson_update_grade_type_nonce'] ) ) {

Expand All @@ -3208,6 +3219,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
}

public function lesson_update_question_order() {
$nonce = '';
// Add nonce security to the request
if ( isset( $_POST['lesson_update_question_order_nonce'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification
Expand Down Expand Up @@ -3241,6 +3253,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
}

public function lesson_update_question_order_random() {
$nonce = '';
// Add nonce security to the request
if ( isset( $_POST['lesson_update_question_order_random_nonce'] ) ) {
// phpcs:ignore WordPress.Security.NonceVerification
Expand Down Expand Up @@ -3277,6 +3290,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
$question_wrong_answers = $question_right_answers = array();
$question_type = 'multiple-choice';
$question_category = '';
$question_grade = null;

// Handle Question Type
if ( isset( $data['question_type'] ) &amp;&amp; ( '' != $data['question_type'] ) ) {
Expand Down Expand Up @@ -3398,7 +3412,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
}
}

$wrong_answer_count = count( $question_wrong_answers );
$wrong_answer_count = is_countable( $question_wrong_answers ) ? count( $question_wrong_answers ) : 0;

// Only save if there is a valid title
if ( $post_title != '' ) {
Expand Down Expand Up @@ -3695,7 +3709,7 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
// If viewing quiz on the frontend then show questions in random order if set.
if ( ! is_admin() ) {
$random_order = get_post_meta( $quiz_id, '_random_question_order', true );
if ( $random_order &amp;&amp; 'yes' === $random_order ) {
if ( 'yes' === $random_order ) {
$orderby = 'rand';
}
}
Expand Down Expand Up @@ -3821,13 +3835,15 @@ <h1 class="page-title">Source: includes/class-sensei-lesson.php</h1>
// Negative amount is considered as All (same as zero).
if ( $show_questions > 0 ) {
// Get random set of array keys from selected questions array.
$questions_count = is_countable( $questions_array ) ? count( $questions_array ) : 0;
$selected_questions = array_rand(
$questions_array,
$show_questions > count( $questions_array ) ? count( $questions_array ) : $show_questions
$show_questions > $questions_count ? $questions_count : $show_questions
);

// Loop through all questions and pick the the ones to be shown based on the random key selection.
// Loop through all questions and pick the ones to be shown based on the random key selection.
$questions = [];

foreach ( $questions_array as $k => $question ) {

// Random keys will always be an array, unless only one question is to be shown.
Expand Down
1 change: 1 addition & 0 deletions includes_class-sensei-messages.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,7 @@ <h1 class="page-title">Source: includes/class-sensei-messages.php</h1>
return false;
}

$user_login = null;
if ( $user_id == 0 ) {
global $current_user;
wp_get_current_user();
Expand Down
6 changes: 4 additions & 2 deletions includes_class-sensei-modules.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -1220,7 +1220,7 @@ <h1 class="page-title">Source: includes/class-sensei-modules.php</h1>
);
$lessons = get_posts( $args );

if ( is_wp_error( $lessons ) || 0 >= count( $lessons ) ) {
if ( is_wp_error( $lessons ) || ! $lessons ) {
return 0;
}

Expand Down Expand Up @@ -2579,10 +2579,12 @@ <h1 class="page-title">Source: includes/class-sensei-modules.php</h1>
*/
public function filter_course_selected_terms( $terms, $course_ids_array, $taxonomies ) {

$taxonomies_count = is_countable( $taxonomies ) ? count( $taxonomies ) : 0;

// dont limit for admins and other taxonomies. This should also only apply to admin
if ( current_user_can( 'manage_options' ) || ! is_admin() || empty( $terms )
// only apply this to module only taxonomy queries so 1 taxonomy only:
|| count( $taxonomies ) > 1 || ! in_array( 'module', $taxonomies ) ) {
|| $taxonomies_count > 1 || ! in_array( 'module', $taxonomies ) ) {
return $terms;
}

Expand Down
2 changes: 1 addition & 1 deletion includes_class-sensei-question.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ <h1 class="page-title">Source: includes/class-sensei-question.php</h1>
$quizzes = array_unique( array_filter( $quizzes ) );
}

if ( 0 == count( $quizzes ) ) {
if ( ! $quizzes ) {
echo wp_kses_post( $no_lessons );
return;
}
Expand Down
4 changes: 2 additions & 2 deletions includes_class-sensei-quiz.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -1706,7 +1706,7 @@ <h1 class="page-title">Source: includes/class-sensei-quiz.php</h1>
}

$sensei_question_loop['questions_asked'] = wp_list_pluck( $all_questions, 'ID' );
$sensei_question_loop['total'] = count( $all_questions );
$sensei_question_loop['total'] = is_countable( $all_questions ) ? count( $all_questions ) : 0;

// Paginate the questions.
if ( $sensei_question_loop['posts_per_page'] > 0 ) {
Expand Down Expand Up @@ -2410,7 +2410,7 @@ <h1 class="page-title">Source: includes/class-sensei-quiz.php</h1>
return;
}

$quiz_available = $this->is_quiz_available( $quiz_id, $user_id );
$quiz_available = static::is_quiz_available( $quiz_id, $user_id );
if ( ! $quiz_available ) {
return;
}
Expand Down
7 changes: 3 additions & 4 deletions includes_class-sensei-utils.php.html
Original file line number Diff line number Diff line change
Expand Up @@ -1513,11 +1513,11 @@ <h1 class="page-title">Source: includes/class-sensei-utils.php</h1>
return 0;
}

return self::as_absolute_rounded_number( doubleval( $numerator ) / ( $denominator ), $decimal_places_to_round );
return self::as_absolute_rounded_number( floatval( $numerator ) / ( $denominator ), $decimal_places_to_round );
}

public static function as_absolute_rounded_number( $number, $decimal_places_to_round = 0 ) {
return abs( round( ( doubleval( $number ) ), $decimal_places_to_round ) );
return abs( round( ( floatval( $number ) ), $decimal_places_to_round ) );
}

/**
Expand Down Expand Up @@ -2164,8 +2164,7 @@ <h1 class="page-title">Source: includes/class-sensei-utils.php</h1>
$drop_down_element .= '&lt;option value="">' . esc_html__( 'None', 'sensei-lms' ) . '&lt;/option>';
}

if ( count( $options ) > 0 ) {

if ( $options ) {
foreach ( $options as $value => $option ) {

$element = '';
Expand Down
Loading

0 comments on commit 7c933d5

Please sign in to comment.