Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code review changes #5

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,10 @@ public function ld_custom_autocomplete_lesson( $post_id, $course_id, $user_id )
*/
public function ld_custom_autocomplete_timer() {
if ( isset( $_POST['nonce'] ) && ! wp_verify_nonce( sanitize_key( $_POST['nonce'] ), 'ld_custom_mark_complete_nonce' ) ) {
$nonce_error_message = apply_filters( 'ld_custom_autocomplete_timer_nonce_error_message', __( 'Please provide proper nonce', 'ld_custom_auto_complete' ) );
wp_send_json_error(
array(
'message' => __( 'Please provide proper nonce', 'ld_custom_auto_complete' ),
'message' => $nonce_error_message,
'type' => 'error',
),
403
Expand All @@ -99,21 +100,22 @@ public function ld_custom_autocomplete_timer() {
$is_complete = learndash_process_mark_complete( $user_id, intval( $_POST['post_id'] ), false, intval( $_POST['course_id'] ) );
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sanitize input before function call

}
if ( true === $is_complete ) {
$success_message = apply_filters( 'ld_custom_autocomplete_timer_success_message', __( 'Mark complete successfully done.', 'ld_custom_auto_complete' ) );
wp_send_json_success(
array(
'message' => __( 'Mark complete Sucessfully done.', 'ld_custom_auto_complete' ),
'message' => $success_message,
'type' => 'success',
)
);
} else {
}
$error_message = apply_filters( 'ld_custom_autocomplete_timer_failure_message', __( 'Mark complete failed due to insufficient permissions.', 'ld_custom_auto_complete' ) );
wp_send_json_error(
array(
'message' => __( 'Mark complete Failed due to insufficient permissions.', 'ld_custom_auto_complete' ),
'message' => $error_message,
'type' => 'error',
),
403
);
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
/**
* Handles the LearnDash timer countdown and completion process.
*/
jQuery(
function () {
if (jQuery( '.learndash_timer' ).length) {
jQuery( '.learndash_timer' ).each(
function (idx, item) {
const timer_el = jQuery( item );
function (index, timer_element) {
const timer_el = jQuery( timer_element );
let timer_seconds = timer_el.data( 'timer-seconds' );
const button_ref = timer_el.data( 'button' );
const button_selector = timer_el.data( 'button' );

if (typeof button_ref !== 'undefined' && jQuery( button_ref ).length) {
const timer_button_el = jQuery( button_ref );
if (typeof button_selector !== 'undefined' && jQuery( button_selector ).length) {
const timer_button_el = jQuery( button_selector );

if (typeof timer_seconds !== 'undefined' && typeof timer_button_el !== 'undefined') {
timer_seconds = parseInt( timer_seconds );
Expand Down
Loading