Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions classes/Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@
global $wp_query;
$course_coming_soon_enabled = (int) get_post_meta( $content->ID, '_tutor_course_enable_coming_soon', true );
$is_instructor = tutor_utils()->is_instructor_of_this_course( get_current_user_id(), $content->ID, true );
if ( ! CourseModel::get_post_types( $content ) || current_user_can( 'administrator' ) || $is_instructor || $course_coming_soon_enabled ) {

Check failure on line 318 in classes/Course.php

View workflow job for this annotation

GitHub Actions / WPCS

Capabilities should be used instead of roles. Found "administrator" in function call to current_user_can()
return $content;
}

Expand Down Expand Up @@ -623,7 +623,7 @@
} else {
$errors['pricing'] = __( 'Invalid product', 'tutor' );
}
} else {

Check failure on line 626 in classes/Course.php

View workflow job for this annotation

GitHub Actions / WPCS

If control structure block found as the only statement within an "else" block. Use elseif instead.
/**
* If user does not select WC product
* Then automatic WC product will be create name with course title.
Expand Down Expand Up @@ -760,7 +760,7 @@
update_post_meta( $post_id, self::COURSE_PRICE_TYPE_META, $params['pricing']['type'] );
}
} catch ( \Throwable $th ) {
throw new \Exception( $th->getMessage() );

Check failure on line 763 in classes/Course.php

View workflow job for this annotation

GitHub Actions / WPCS

All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '$th'.
}
}

Expand Down Expand Up @@ -1174,6 +1174,19 @@
delete_post_meta( $course_id, '_elementor_edit_mode' );
} elseif ( 'droip' === $builder ) {
delete_post_meta( $course_id, 'droip_editor_mode' );
} elseif ( 'divi' === $builder ) {
$old_post_content = get_post_meta( $course_id, '_et_pb_old_content', true );
$course = get_post( $course_id );
$course->post_content = $old_post_content;
$result = wp_update_post( $course );

if ( $result && ! is_wp_error( $result ) ) {
update_post_meta( $course_id, '_et_pb_use_builder', 'off' );
update_post_meta( $course_id, '_et_pb_old_content', '' );
delete_post_meta( $course_id, '_et_dynamic_cached_shortcodes' );
delete_post_meta( $course_id, '_et_dynamic_cached_attributes' );
delete_post_meta( $course_id, '_et_builder_module_features_cache' );
}
}

$this->json_response(
Expand Down Expand Up @@ -2229,7 +2242,7 @@
}

// Check if user is only an instructor.
if ( ! current_user_can( 'administrator' ) ) {

Check failure on line 2245 in classes/Course.php

View workflow job for this annotation

GitHub Actions / WPCS

Capabilities should be used instead of roles. Found "administrator" in function call to current_user_can()
// Check if instructor can trash course.
$can_trash_post = tutor_utils()->get_option( 'instructor_can_delete_course' );

Expand Down Expand Up @@ -2273,7 +2286,7 @@
/**
* Only admin can change main author
*/
if ( $courses_post_type === $post_type && ! current_user_can( 'administrator' ) ) {

Check failure on line 2289 in classes/Course.php

View workflow job for this annotation

GitHub Actions / WPCS

Capabilities should be used instead of roles. Found "administrator" in function call to current_user_can()
global $wpdb;
$post_ID = (int) tutor_utils()->avalue_dot( 'ID', $postarr );
$post_author = (int) $wpdb->get_var( $wpdb->prepare( "SELECT post_author FROM {$wpdb->posts} WHERE ID = %d ", $post_ID ) );
Expand Down
Loading