Skip to content

Commit

Permalink
Merge pull request #596 from themeum/dev
Browse files Browse the repository at this point in the history
v2.4.0 merged to master
  • Loading branch information
harunollyo authored Oct 17, 2023
2 parents 05f3d05 + a6d304e commit 8b3765e
Show file tree
Hide file tree
Showing 39 changed files with 815 additions and 296 deletions.
File renamed without changes
2 changes: 1 addition & 1 deletion assets/react/admin-dashboard/tutor-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ jQuery(document).ready(function($) {
const getProMenu = document.querySelector('span.tutor-get-pro-text')
if (getProMenu?.parentElement?.nodeName === 'A') {
const el = getProMenu.parentElement;
const link = 'https://www.themeum.com/product/tutor-lms/pricing?utm_source=tutor_plugin_get_pro_page&utm_medium=wordpress_dashboard&utm_campaign=go_premium';
const link = 'https://www.themeum.com/tutor-lms/pricing?utm_source=tutor_plugin_get_pro_page&utm_medium=wordpress_dashboard&utm_campaign=go_premium#comparison';

el.setAttribute('href', link)
el.setAttribute('target', '_blank')
Expand Down
3 changes: 2 additions & 1 deletion assets/react/front/course/_spotlight-quiz.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ window.jQuery(document).ready($ => {
var limit = $that.hasClass('question_type_short_answer')
? _tutorobject.quiz_options.short_answer_characters_limit
: _tutorobject.quiz_options.open_ended_answer_characters_limit;

var remaining = limit - value.length;

if (remaining < 1) {
Expand All @@ -265,7 +266,7 @@ window.jQuery(document).ready($ => {
}

$that
.closest('.tutor-quiz-answers-wrap')
.closest('.quiz-attempt-single-question')
.find('.characters_remaining')
.html(remaining);
});
Expand Down
50 changes: 50 additions & 0 deletions assets/react/lib/modules/instructor-review.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,36 @@ window.jQuery(document).ready($ => {
(rating && selected && selected.length>0) ? toggle_star_(selected) : $(this).find('i').removeClass('tutor-icon-star-bold').addClass('tutor-icon-star-line');
});


/**
* On review popup dismiss, clear the review popup data.
*
* @since 2.4.0
*/
$(document).on('click','.tutor-course-review-popup-form .tutor-modal-close-o, .tutor-course-review-popup-form .tutor-review-popup-cancel', function() {
let modal = $(this).closest('.tutor-modal');
let course_id = modal.find('input[name="course_id"]').val();
let data = {
action: 'tutor_clear_review_popup_data',
course_id: course_id
}

$.ajax({
url: _tutorobject.ajaxurl,
type: 'POST',
dataType: 'json',
data: data,
beforeSend: function () {
modal.removeClass('tutor-is-active');
},
success: function (res) {
if (!res.success) {
console.warn('review popup data clear error');
}
}
});
})

$(document).on('click', '.tutor_submit_review_btn', function (e) {
// Prevent normal submission to validate input
e.preventDefault();
Expand Down Expand Up @@ -70,6 +100,26 @@ window.jQuery(document).ready($ => {
// Show thank you
tutor_toast(review_id ? __('Updated successfully!', 'tutor') : __('Thank You for Rating The Course!', 'tutor'), review_id ? __('Updated rating will now be visible in the course page', 'tutor') : __('Your rating will now be visible in the course page', 'tutor'), 'success');

/**
* After review submit success, clear review popup data
*
* @since 2.4.0
*/
$.ajax({
url: _tutorobject.ajaxurl,
type: 'POST',
dataType: 'json',
data: {
action: 'tutor_clear_review_popup_data',
course_id: course_id
},
success: function (res) {
if ( ! res.success ) {
console.warn('review popup data clear error');
}
}
});

setTimeout(function(){
location.reload();
}, 3000);
Expand Down
7 changes: 0 additions & 7 deletions assets/scss/admin-dashboard/_tutor-admin.scss
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
margin-right: auto;
padding-left: 30px;
padding-right: 30px;
overflow-x: auto;

&-sm {
max-width: 760px;
Expand Down Expand Up @@ -123,12 +122,6 @@

body.tutor-backend-tutor_settings #wpbody-content {
min-height: 100vh;

@include breakpoint-min(1400) {
.tutor-admin-container {
overflow-x: unset;
}
}
}

.ui-datepicker-buttonpane.ui-widget-content {
Expand Down
6 changes: 4 additions & 2 deletions assets/scss/admin-dashboard/v2/components/_nav-tab.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
.tutor-nav {
// admin option tabs
&.tutor-option-tabs {
position: sticky;
top: 120px;
.tutor-nav-link {
color: var(--tutor-color-secondary);
border: 1px solid transparent;
Expand All @@ -32,4 +30,8 @@
}
}
}
&.tutor-is-sticky {
position: sticky;
top: 120px;
}
}
4 changes: 4 additions & 0 deletions assets/scss/front/course-spotlight/_players.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,9 @@
height: 100%;
border: none;
}

.plyr--vimeo .plyr__captions {
display: none!important;
}
}
}
16 changes: 16 additions & 0 deletions assets/scss/front/course-spotlight/_sidebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,22 @@
background-color: $color-gray-5;
}
}

// Checked for completed or passed
.tutor-form-check-circle[checked] {
border-color: var(--tutor-color-success);
background-color: var(--tutor-color-success);
}
.tutor-check-pending{
border-color: var(--tutor-color-warning)!important;
background-color: var(--tutor-color-warning)!important;
background-image: url("data:image/svg+xml,%3Csvg fill='%23FFF' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='14' height='10' viewBox='0 0 459.313 459.314' xml:space='preserve'%3E%3Cg%3E%3Cpath d='M459.313,229.648c0,22.201-17.992,40.199-40.205,40.199H40.181c-11.094,0-21.14-4.498-28.416-11.774 C4.495,250.808,0,240.76,0,229.66c-0.006-22.204,17.992-40.199,40.202-40.193h378.936 C441.333,189.472,459.308,207.456,459.313,229.648z'/%3E%3C/g%3E%3C/svg%3E");
}
.tutor-check-fail{
border-color: var(--tutor-color-danger)!important;
background-color: var(--tutor-color-danger)!important;
background-image: url("data:image/svg+xml,%3Csvg fill='white' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' version='1.1' x='0px' y='0px' viewBox='0 0 100 100' xml:space='preserve'%3E%3Cpath d='M49.9,78c-4.2,0-7.6,3.5-7.6,7.8v1.5c0,4.3,3.4,7.7,7.6,7.7c4.2,0,7.7-3.4,7.7-7.7v-1.5C57.6,81.5,54.2,78,49.9,78L49.9,78z M49.8,5c-6.3,0-11.9,6.1-11.3,12.4l3.8,47c0.2,3.7,3.1,6.9,6.9,7.2c4.3,0.3,8.1-3,8.4-7.2l3.9-47C62,11.1,56.6,5,49.8,5z'%3E%3C/path%3E%3C/svg%3E");
}
}
}
}
Expand Down
40 changes: 1 addition & 39 deletions classes/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function __construct() {

// Handle flash toast message for redirect_to util helper.
add_action( 'admin_head', array( new Utils(), 'handle_flash_message' ), 999 );
add_action( 'tutor_after_settings_menu', array( $this, 'whats_new_menu' ), 11 );
add_action( 'tutor_after_settings_menu', '\TUTOR\WhatsNew::whats_new_menu', 11 );
}

/**
Expand Down Expand Up @@ -142,44 +142,6 @@ public function register_menu() {
}
}

/**
* What's new page.
*
* @since 2.2.4
*
* @return void
*/
public function whats_new_menu() {
$transient_key = 'tutor_plugin_info';
$plugin_info = get_transient( $transient_key );

if ( false === $plugin_info ) {
$plugin_info = tutils()->get_remote_plugin_info();
$hour_in_seconds = 1800;
set_transient( $transient_key, $plugin_info, $hour_in_seconds );
}

$remote_version = $plugin_info->version ?? TUTOR_VERSION;
$installed_version = TUTOR_VERSION;
$update_required = version_compare( $remote_version, $installed_version, '>' );

$menu_text = __( "What's New", 'tutor' );
if ( $update_required ) {
$menu_text .= ' <span class="update-plugins"><span class="plugin-count">1</span></span>';
}

add_submenu_page(
'tutor',
__( "What's New", 'tutor' ),
$menu_text,
'manage_options',
'tutor-whats-new',
function() use ( $remote_version, $installed_version, $update_required ) {
include tutor()->path . 'views/pages/whats-new.php';
}
);
}

/**
* Show Course Bundle Page For Free User.
*
Expand Down
56 changes: 35 additions & 21 deletions classes/Course.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ public function __construct() {
* @since v1.9.7
*/
add_action( 'wp_footer', array( $this, 'popup_review_form' ) );
add_action( 'wp_ajax_tutor_clear_review_popup_data', array( $this, 'clear_review_popup_data' ) );

/**
* Do enroll after login if guest take enroll attempt
Expand Down Expand Up @@ -845,49 +846,62 @@ public function mark_course_complete() {
* Set data for review popup.
*
* @since 2.2.5
* @since 2.4.0 removed $permalink param. store user meta instead of option data.
*
* @param int $user_id user id.
* @param int $course_id course id.
* @param string $permalink course permalink.
* @param int $user_id user id.
* @param int $course_id course id.
*
* @return void
*/
public static function set_review_popup_data( $user_id, $course_id, $permalink ) {
public static function set_review_popup_data( $user_id, $course_id ) {
if ( get_tutor_option( 'enable_course_review' ) ) {
$rating = tutor_utils()->get_course_rating_by_user( $course_id, $user_id );
if ( ! $rating || ( empty( $rating->rating ) && empty( $rating->review ) ) ) {
update_option(
'tutor_course_complete_popup_' . $user_id,
array(
'course_id' => $course_id,
'course_url' => $permalink,
'expires' => time() + 10,
)
);
$meta_key = User::get_review_popup_meta( $course_id );
add_user_meta( $user_id, $meta_key, $course_id, true );
}
}
}

/**
* Popup review form
* Popup review form on course details
*
* @since 1.0.0
* @return void
*/
public function popup_review_form() {
if ( is_user_logged_in() ) {
$key = 'tutor_course_complete_popup_' . get_current_user_id();
$popup = get_option( $key );
$user_id = get_current_user_id();
$course_id = get_the_ID();
$meta_key = User::get_review_popup_meta( $course_id );
$review_course_id = (int) get_user_meta( $user_id, $meta_key, true );

if ( is_array( $popup ) ) {
if ( is_single() && $course_id === $review_course_id ) {
include tutor()->path . 'views/modal/review.php';
}
}
}

if ( $popup['expires'] > time() ) {
$course_id = $popup['course_id'];
include tutor()->path . 'views/modal/review.php';
}
/**
* Review popup data clear
*
* @since 2.4.0
*
* @return void
*/
public function clear_review_popup_data() {
tutils()->checking_nonce();

delete_option( $key );
if ( is_user_logged_in() ) {
$user_id = get_current_user_id();
$course_id = Input::post( 'course_id', 0, Input::TYPE_INT );

if ( $course_id ) {
$meta_key = User::get_review_popup_meta( $course_id );
delete_user_meta( $user_id, $meta_key, $course_id );
}

wp_send_json_success();
}
}

Expand Down
7 changes: 4 additions & 3 deletions classes/Course_Filter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ public function load_listing( $filters = null, $return_filter = false ) {
$courses_per_page = (int) tutils()->array_get( 'course_per_page', $sanitized_post, $default_per_page );

// Pagination arg.
$page = max( 1, Input::post( 'current_page', 0, Input::TYPE_INT ) );
$sanitized_post['current_page'] = $page;
$current_page = (int) Input::sanitize_request_data( 'current_page', 1 );
$paged = max( 1, $current_page );
$sanitized_post['current_page'] = $paged;

// Order arg.
$order_by = 'post_date';
Expand Down Expand Up @@ -110,7 +111,7 @@ public function load_listing( $filters = null, $return_filter = false ) {
'post_status' => 'publish',
'post_type' => tutor()->course_post_type,
'posts_per_page' => $courses_per_page,
'paged' => (int) $page,
'paged' => $paged,
'orderby' => $order_by,
'order' => $order,
'tax_query' => array(
Expand Down
23 changes: 23 additions & 0 deletions classes/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

namespace TUTOR;

use Tutor\Models\CourseModel;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}
Expand All @@ -34,6 +36,27 @@ public function __construct() {

// Handle flash toast message for redirect_to util helper.
add_action( 'wp_head', array( new Utils(), 'handle_flash_message' ), 999 );

add_action( 'tutor_course/single/before/wrap', array( $this, 'do_auto_course_complete' ) );
}

/**
* Do auto course complete on course details page.
*
* @return void
*/
public function do_auto_course_complete() {
if ( ! is_user_logged_in() ) {
return;
}

$course_id = get_the_ID();
$user_id = get_current_user_id();

if ( CourseModel::can_autocomplete_course( $course_id, $user_id ) ) {
CourseModel::mark_course_as_completed( $course_id, $user_id );
Course::set_review_popup_data( $user_id, $course_id );
}
}

/**
Expand Down
2 changes: 1 addition & 1 deletion classes/Instructor.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ public function add_new_instructor() {
$user_login = sanitize_text_field( tutor_utils()->input_old( 'user_login' ) );
$phone_number = sanitize_text_field( tutor_utils()->input_old( 'phone_number' ) );
$password = sanitize_text_field( tutor_utils()->input_old( 'password' ) );
$tutor_profile_bio = wp_kses_post( tutor_utils()->input_old( 'tutor_profile_bio' ) );
$tutor_profile_bio = Input::post( 'tutor_profile_bio', '', Input::TYPE_KSES_POST );
$tutor_profile_job_title = sanitize_text_field( tutor_utils()->input_old( 'tutor_profile_job_title' ) );

$userdata = apply_filters(
Expand Down
Loading

0 comments on commit 8b3765e

Please sign in to comment.