Skip to content

Commit

Permalink
Merged in pre-release (pull request #52)
Browse files Browse the repository at this point in the history
Pre release
  • Loading branch information
saad-siddique committed Feb 11, 2021
2 parents fb9c648 + c0c7a6d commit 99a4d09
Show file tree
Hide file tree
Showing 15 changed files with 923 additions and 581 deletions.
212 changes: 106 additions & 106 deletions languages/uncanny-learndash-toolkit.pot

Large diffs are not rendered by default.

30 changes: 24 additions & 6 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,18 @@
Contributors: uncannyowl
Tags: LearnDash, eLearning, LMS, education, learning, courseware
Requires at least: 4.6
Tested up to: 5.6
Tested up to: 5.6.1
Requires PHP: 7.0
Stable tag: 3.4.1
License: This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or any later version. LearnDash Groups in User Profiles is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with LearnDash Groups in User Profiles. If not, see {URI to Plugin License}.
License URI: https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html
Stable tag: 3.4.2
License: This plugin is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or any later version. Uncanny Toolkit for LearnDash is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Uncanny Toolkit for LearnDash. If not, see https://www.gnu.org/licenses/gpl-3.0.html.
License URI: https://www.gnu.org/licenses/gpl-3.0.html

Extend LearnDash with a variety of useful functions that make it even easier to build great learner experiences with LearnDash.

== Description ==
**Important: This plugin requires PHP 7.0 or higher and LearnDash 3.0 or higher.**

The Uncanny Toolkit for LearnDash adds 15 modules that every elearning site needs, including a login form, login redirect, resume capabilities and more. Trusted to power over 20,000 LearnDash sites, it's the easiest way to improve the learning experience for your students. Translation ready and multisite capable!
The Uncanny Toolkit for LearnDash adds 16 modules that every elearning site needs, including a login form, login redirect, resume capabilities and more. Trusted to power over **30,000+** LearnDash sites, it's the easiest way to improve the learning experience for your students. Translation ready and multisite capable!

https://www.youtube.com/watch?v=o0MWoyR5Sos

Expand All @@ -40,7 +40,7 @@ We welcome contributions to the Uncanny Toolkit! The plugin is managed in a [Bit

**Ready to take your LearnDash site even further?**

The [Pro version of the Uncanny Toolkit](https://www.uncannyowl.com/downloads/uncanny-learndash-toolkit-pro/?utm_medium=ldtoolkitreadme) adds a continuously expanding list of powerful features (20 at last count!) to the Toolkit. With the Pro modules, you can:
The [Pro version of the Uncanny Toolkit](https://www.uncannyowl.com/downloads/uncanny-learndash-toolkit-pro/?utm_medium=ldtoolkitreadme) adds a continuously expanding list of powerful features (29 at last count!) to the Toolkit. With the Pro modules, you can:

* Autocomplete lessons and topics (no more "Mark Complete" buttons!)
* Track the time users spend completing courses
Expand Down Expand Up @@ -76,6 +76,24 @@ Follow Uncanny Owl for updates about our latest LearnDash enhancements on [Twitt

== Changelog ==

= 3.4.2 [2021-02-11] =
**Added:**

* New parameters to settings array to support future functionality

**Updated:**

* Quiz completion advances to next step: "Click here to continue" button on last quiz of a course will now redirect to course page instead of lesson/topic
* Not Enrolled Redirect: Now detects if users are enrolled via group access

**Fixed:**

* User Switching: Could not switch users on some site if Front End Login is enabled
* Deprecated: Function get_magic_quotes_gpc()
* Notices on module page when LearnDash is not active
* Disable Emails: PHP notice: Constant DISABLE_EMAILS_OPTIONS already defined
* Front End Login: Users that become unverified and then are reverified will now receive a notification email

= 3.4.1 [2021-01-04] =
**Added:**

Expand Down
92 changes: 61 additions & 31 deletions src/admin-menu.php

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion src/assets/backend/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ html.noscroll .ult-modal {

.ult-modal-box {
width: 100%;
max-width: 450px;
max-width: 500px;
max-height: 80vh;

border-radius: 4px;
Expand Down Expand Up @@ -1264,6 +1264,15 @@ html.noscroll .ult-modal {
position: relative;
}

.ult-modal-form-row--children {
padding-left: 15px;
border-left: 10px solid #eee;
}

.ult-modal-form-row--hide {
display: none;
}

.ult-modal-form-row:not(:last-child){
margin-bottom: 15px;
}
Expand Down
143 changes: 135 additions & 8 deletions src/assets/backend/js/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,10 @@ jQuery( function($){

// Bind buttons
this.bindButtons();

// Set the visibility of fields depending on
// the values of other fields
this.conditionalVisibility();
},

bindButtons: function(){
Expand Down Expand Up @@ -618,6 +622,36 @@ jQuery( function($){
},

fillFields: function( $modal, data ){
// Get the default values
let $fieldsWithDefaultValues = $modal.find( '.ult-modal-form-row:not([data-default=""])[data-id][data-type]' );
let fieldDefaultValues = {};
$.each( $fieldsWithDefaultValues, ( index, field ) => {
// Get the jQuery element
field = $( field );
// Add the default value
fieldDefaultValues[ field.data( 'id' ) ] = field.data( 'default' );
});

// Convert the array with the data from an array with objects
// to and object
let fieldData = {};
$.each( data, ( index, field ) => {
fieldData[ field.name ] = field.value;
});

// Merge the default values with the field data
fieldData = $.extend( fieldDefaultValues, fieldData );

// Convert the field data from an object to an
// array with objects
data = [];
$.each( fieldData, ( key, value ) => {
data.push({
name: key,
value: value
});
});

// Iterate each option
$.each( data, ( index, field ) => {
// Get field info
Expand All @@ -637,7 +671,7 @@ jQuery( function($){
case 'text':
case 'textarea':
case 'tinymce':
field.$element.val( field.value );
field.$element.val( field.value ).trigger( 'input' );

if ( field.type == 'tinymce' ){
let editor = tinymce.get( field.name );
Expand All @@ -660,7 +694,7 @@ jQuery( function($){
case 'checkbox':
// Check if the checkbox is selected
if ( field.value == 'on' ){
field.$element.prop( 'checked', true );
field.$element.prop( 'checked', true ).trigger( 'change' );
}
break;

Expand All @@ -670,21 +704,25 @@ jQuery( function($){
let $radio = $(this);

if ( $radio.val() == field.value ){
$radio.prop( 'checked', true );
$radio.prop( 'checked', true ).trigger( 'change' );
}
});
break;
};
})
});
},

getFieldByName: function( $modal, fieldName ){
// Find field
let $field = $modal.find( `*[name="${fieldName}"]` );
let $field = $modal.find( `*[name="${ fieldName }"]` );
let $fieldRow = $field.closest( '.ult-modal-form-row' );

return {
$element: $field,
type: $field.data( 'type' )
$row: $fieldRow,
$element: $field,
type: $field.data( 'type' ),
showIf: $fieldRow.data( 'show-if' ),
defaultValue: $fieldRow.data( 'default' ),
};
},

Expand Down Expand Up @@ -728,6 +766,70 @@ jQuery( function($){
return formData;
},

conditionalVisibility: function(){
// Get all the fields with conditional visibility rules
const $fieldsWithShowIf = $( '.ult-modal-form-row:not([data-show-if=""])' );

// Get the modals that have a field that's shown dynamically
let $modals = $fieldsWithShowIf.closest( '.ult-modal' );

// Iterate the modals
$.each( $modals, ( index, $modal ) => {
$modal = $( $modal );

// Get the fields with conditional visibility in the modal
const $fieldsWithShowIfInModal = $modal.find( '.ult-modal-form-row:not([data-show-if=""])' );

// Get the visibility conditions of each field
let fieldsWithShowIfInModal = {};
$.each( $fieldsWithShowIfInModal, ( index, $field ) => {
$field = $( $field );

// Get the field row
const $fieldRow = $field.closest( '.ult-modal-form-row' );

// Try to get the show-if conditions
let showIf = $fieldRow.data( 'show-if' );

try {
showIf = JSON.parse( showIf );
} catch ( e ){}

fieldsWithShowIfInModal[ $fieldRow.data( 'id' ) ] = {
$fieldRow: $fieldRow,
conditions: showIf
};
});

// Listen changes in the fields
$modal.find( 'input, textarea, select' ).on( 'change input', ULT_Utility.debounce(() => {
// Get the value of all the fields
let fieldsValuesArray = $modal.find( 'form' ).serializeArray();
fieldsValues = {};
$.each( fieldsValuesArray, ( index, $field ) => {
fieldsValues[ $field.name ] = $field.value;
});

// Iterate the fields with conditional visibility
$.each( fieldsWithShowIfInModal, ( fieldID, field ) => {
// Check if it matches the condition
let shouldShow = Object.entries( field.conditions ).reduce(( accumulator, [ conditionKey, conditionValue ]) => {
return accumulator && fieldsValues[ conditionKey ] == conditionValue;
}, true );

// Check if it should show the field
if ( shouldShow ){
field.$fieldRow.removeClass( 'ult-modal-form-row--hide' );
}
else {
// Hide it
field.$fieldRow.addClass( 'ult-modal-form-row--hide' );
}
});
}, 20 ));
});
},

disableScroll: function(){
// Add "noscroll" class to the html element
$( 'html' ).addClass( 'noscroll' );
Expand Down Expand Up @@ -829,6 +931,31 @@ jQuery( function($){
}

return fieldType;
}
},

throttle( func, interval ){
var lastCall = 0;

return function(){
var now = Date.now();
if ( lastCall + interval < now ){
lastCall = now;
return func.apply( this, arguments );
}
};
},

debounce( func, interval ){
var lastCall = -1;

return function(){
clearTimeout( lastCall );
var args = arguments;
var self = this;
lastCall = setTimeout( function(){
func.apply( self, args );
}, interval );
};
},
}
});
2 changes: 1 addition & 1 deletion src/boot.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Boot extends Config {

/**
* class constructor
* class constructor
*/
public function __construct() {

Expand Down
6 changes: 3 additions & 3 deletions src/classes/disable-emails.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ public function __construct() {
if ( ! defined( 'DISABLE_EMAILS_PLUGIN_ROOT' ) ) {

add_action( 'admin_bar_menu', array( __CLASS__, 'admin_bar_emails_disabled' ), 999 );

define( 'DISABLE_EMAILS_OPTIONS', 'disable_emails' );

if ( ! defined( 'DISABLE_EMAILS_OPTIONS' ) ) {
define( 'DISABLE_EMAILS_OPTIONS', 'disable_emails' );
}
include_once UNCANNY_TOOLKIT_DIR . '/src/includes/class.DisableEmailsPlugin.php';

DisableEmailsPlugin::getInstance();
Expand Down
20 changes: 19 additions & 1 deletion src/classes/frontend-login-plus.php
Original file line number Diff line number Diff line change
Expand Up @@ -853,9 +853,16 @@ public static function my_save_extra_profile_fields( $user_id ) {

// convert status into integers from boolean.
$is_verified = intval( $is_verified );

// Update the user's metadata with verification status.
update_user_meta( $user_id, 'uo_is_verified', $is_verified );

// Reset verification email if already sent and user unverified
$is_verification_email_sent = get_user_meta( $user_id, 'uo_verified_email_sent', true );

if ( 'yes' === $is_verification_email_sent && $is_verified !== 1 ) {
update_user_meta( $user_id, 'uo_verified_email_sent', 'no' );
}

// if the user was verified, run action hook.
if ( $is_verified ) {
Expand Down Expand Up @@ -1551,6 +1558,7 @@ public static function fetch_inner_text() {
*/
public static function redirect_login_page() {


$login_page = get_permalink( self::get_login_redirect_page_id() );
$page_viewed = $_SERVER['REQUEST_URI'];

Expand All @@ -1569,6 +1577,16 @@ public static function redirect_login_page() {
if ( isset( $_REQUEST['action'] ) && 'logout' === $_REQUEST['action'] ) {
return;
}

// if User Switching is on, add exceptions
$active_classes = get_option( 'uncanny_toolkit_active_classes', 0 );
if ( 0 !== $active_classes ) {
if ( is_array( $active_classes ) && isset( $active_classes['uncanny_learndash_toolkit\UserSwitching'] ) ) {
if ( isset( $_REQUEST['action'] ) && ( 'switch_to_user' === $_REQUEST['action'] ) || 'switch_to_olduser' === $_REQUEST['action'] ) {
return;
}
}
}
if ( isset( $_REQUEST['redirect_to'] ) ) {
if ( is_user_logged_in() ) {
$redirect = apply_filters( 'login_redirect', $_REQUEST['redirect_to'], $_REQUEST, get_current_user() );
Expand Down
2 changes: 1 addition & 1 deletion src/classes/login-redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,4 @@ public static function logout_redirect() {

}

}
}
Loading

0 comments on commit 99a4d09

Please sign in to comment.