Skip to content

Commit

Permalink
Fix(🛠️) : Multilingual slug issue in course details page.
Browse files Browse the repository at this point in the history
  • Loading branch information
sanjana4khan committed Jan 9, 2025
1 parent 1760b51 commit 13ee829
Showing 1 changed file with 25 additions and 28 deletions.
53 changes: 25 additions & 28 deletions classes/Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
}

use stdClass;
use Tutor\Ecommerce\Ecommerce;
use Tutor\Helpers\HttpHelper;
use Tutor\Helpers\ValidationHelper;
use TUTOR\Input;
use Tutor\Helpers\HttpHelper;
use Tutor\Models\CourseModel;
use Tutor\Ecommerce\Ecommerce;
use Tutor\Traits\JsonResponse;
use Tutor\Helpers\ValidationHelper;
use TutorPro\CourseBundle\Models\BundleModel;

/**
Expand Down Expand Up @@ -268,6 +268,16 @@ public function __construct( $register_hooks = true ) {
add_filter( 'tutor_user_list_args', array( $this, 'user_list_args_for_instructor' ) );

add_filter( 'template_include', array( $this, 'handle_password_protected' ) );

// Add a filter to override the default sanitization of slugs(post_name) in WordPress.
add_filter(
'sanitize_title',
function ( $title ) {
return urldecode( $title );
},
10,
2
);
}

/**
Expand Down Expand Up @@ -373,10 +383,8 @@ public function validate_video_source( $params, &$errors ) {

if ( '' === $video_source ) {
$errors['video_source'] = __( 'Video source is required', 'tutor' );
} else {
if ( ! $this->is_valid_video_source_type( $video_source ) ) {
} elseif ( ! $this->is_valid_video_source_type( $video_source ) ) {
$errors['video_source'] = __( 'Invalid video source', 'tutor' );
}
}
}
}
Expand Down Expand Up @@ -808,7 +816,7 @@ public function ajax_course_list() {
if ( count( $exclude ) ) {
$exclude = array_filter(
$exclude,
function( $id ) {
function ( $id ) {
return is_numeric( $id );
}
);
Expand Down Expand Up @@ -1587,7 +1595,7 @@ private function save_course_content_order() {
if ( is_array( $order ) && count( $order ) ) {
$i = 0;
foreach ( $order as $topic ) {
$i++;
++$i;
$wpdb->update(
$wpdb->posts,
array( 'menu_order' => $i ),
Expand Down Expand Up @@ -1670,37 +1678,29 @@ public function save_course_meta( $post_ID, $post ) {
if ( ! empty( $_POST['course_benefits'] ) ) {
$course_benefits = Input::post( 'course_benefits', '', Input::TYPE_KSES_POST );
update_post_meta( $post_ID, '_tutor_course_benefits', $course_benefits );
} else {
if ( ! tutor_is_rest() ) {
} elseif ( ! tutor_is_rest() ) {
delete_post_meta( $post_ID, '_tutor_course_benefits' );
}
}

if ( ! empty( $_POST['course_requirements'] ) ) {
$requirements = Input::post( 'course_requirements', '', Input::TYPE_KSES_POST );
update_post_meta( $post_ID, '_tutor_course_requirements', $requirements );
} else {
if ( ! tutor_is_rest() ) {
} elseif ( ! tutor_is_rest() ) {
delete_post_meta( $post_ID, '_tutor_course_requirements' );
}
}

if ( ! empty( $_POST['course_target_audience'] ) ) {
$target_audience = Input::post( 'course_target_audience', '', Input::TYPE_KSES_POST );
update_post_meta( $post_ID, '_tutor_course_target_audience', $target_audience );
} else {
if ( ! tutor_is_rest() ) {
} elseif ( ! tutor_is_rest() ) {
delete_post_meta( $post_ID, '_tutor_course_target_audience' );
}
}

if ( ! empty( $_POST['course_material_includes'] ) ) {
$material_includes = Input::post( 'course_material_includes', '', Input::TYPE_KSES_POST );
update_post_meta( $post_ID, '_tutor_course_material_includes', $material_includes );
} else {
if ( ! tutor_is_rest() ) {
} elseif ( ! tutor_is_rest() ) {
delete_post_meta( $post_ID, '_tutor_course_material_includes' );
}
}
//phpcs:enable WordPress.Security.NonceVerification.Missing
}
Expand All @@ -1724,10 +1724,8 @@ public function save_course_meta( $post_ID, $post ) {
$video_source = tutor_utils()->array_get( 'source', $video );
if ( -1 !== $video_source ) {
update_post_meta( $post_ID, '_video', $video );
} else {
if ( ! tutor_is_rest() ) {
} elseif ( ! tutor_is_rest() ) {
delete_post_meta( $post_ID, '_video' );
}
}
}

Expand Down Expand Up @@ -2620,10 +2618,10 @@ public function tutor_lms_hide_course_complete_btn( $html ) {
$given_mark = get_comment_meta( $submitted_assignment->comment_ID, 'assignment_mark', true );

if ( $given_mark < $pass_mark ) {
$required_assignment_pass++;
++$required_assignment_pass;
}
} else {
$required_assignment_pass++;
++$required_assignment_pass;
}
}

Expand All @@ -2639,11 +2637,11 @@ public function tutor_lms_hide_course_complete_btn( $html ) {
$earned_percentage = $attempt->earned_marks > 0 ? ( number_format( ( $attempt->earned_marks * 100 ) / $attempt->total_marks ) ) : 0;

if ( $earned_percentage < $passing_grade ) {
$required_quiz_pass++;
++$required_quiz_pass;
$is_quiz_pass = false;
}
} else {
$required_quiz_pass++;
++$required_quiz_pass;
$is_quiz_pass = false;
}
}
Expand Down Expand Up @@ -3010,5 +3008,4 @@ public function user_list_args_for_instructor( $args ) {

return $args;
}

}

0 comments on commit 13ee829

Please sign in to comment.