/** * Course Mandatory Message * * x of y mandatory elements completed * * @since 1.0.0 */ function course_mandatory_message($atts) { extract(shortcode_atts(array('course_id' => in_the_loop() ? get_the_ID() : '', 'unit_id' => false, 'message' => __('%d of %d mandatory elements completed.', 'cp')), $atts, 'course_mandatory_message')); if (!empty($course_id)) { $course_id = (int) $course_id; } $unit_id = (int) $unit_id; $message = sanitize_text_field($message); // $completion = new Course_Completion( $course_id ); // $completion->init_student_status(); $mandatory_required = Student_Completion::get_mandatory_steps_required($unit_id); if (0 == $mandatory_required) { return false; } $mandatory_completed = Student_Completion::get_mandatory_steps_completed(get_current_user_id(), $course_id, $unit_id); // return sprintf( $message, $completion->unit_completed_mandatory_steps( $unit_id ), $completion->unit_mandatory_steps( $unit_id ) ); return sprintf($message, $mandatory_completed, $mandatory_required); }