callbacks. The slms_* tags (pre-5.0.0) stay registered as aliases. */ const TAGS = array( 'accessnow_slms_course_catalog' => 'course_catalog', 'accessnow_slms_my_courses' => 'my_courses', 'accessnow_slms_student_dashboard' => 'student_dashboard', 'slms_course_catalog' => 'course_catalog', 'slms_my_courses' => 'my_courses', 'slms_student_dashboard' => 'student_dashboard', ); public static function init() { foreach ( self::TAGS as $tag => $method ) { add_shortcode( $tag, array( __CLASS__, $method ) ); } } public static function course_catalog( $atts ) { $atts = shortcode_atts( array( 'per_page' => 12, 'lang' => '', ), $atts, 'accessnow_slms_course_catalog' ); $active_lang = $atts['lang'] ? $atts['lang'] : I18n::get_requested_language(); $query_args = array( 'post_type' => 'slms_course', 'posts_per_page' => intval( $atts['per_page'] ), 'post_status' => 'publish', 'orderby' => 'title', 'order' => 'ASC', ); if ( $active_lang && isset( I18n::get_supported_languages()[ $active_lang ] ) ) { $query_args['meta_query'] = array( // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_query -- course language is stored as post meta. array( 'key' => I18n::META_KEY, 'value' => $active_lang, ), ); } $courses = get_posts( $query_args ); ob_start(); echo '
'; if ( ! $atts['lang'] ) { Template_Loader::get_partial( 'language-filter.php', array( 'active_lang' => $active_lang ) ); } if ( empty( $courses ) ) { echo '

' . esc_html__( 'No courses available yet.', 'accessnow-lms' ) . '

'; } else { echo '
'; foreach ( $courses as $course ) { Template_Loader::get_partial( 'course-card.php', array( 'course' => $course ) ); } echo '
'; } echo '
'; return ob_get_clean(); } public static function my_courses( $atts ) { if ( ! is_user_logged_in() ) { return '

' . esc_html__( 'Please log in to view your courses.', 'accessnow-lms' ) . '

'; } $user_id = get_current_user_id(); $enrollments = array(); // Completed courses stay listed. One card per course: the active run wins over an older completed one. foreach ( Enrollment::get_user_enrollments( $user_id, array( 'active', 'completed' ) ) as $e ) { if ( ! isset( $enrollments[ $e->course_id ] ) || 'active' === $e->status ) { $enrollments[ $e->course_id ] = $e; } } ob_start(); echo '
'; if ( empty( $enrollments ) ) { echo '

' . esc_html__( 'You are not enrolled in any courses yet.', 'accessnow-lms' ) . '

'; printf( '%s', esc_url( get_post_type_archive_link( 'slms_course' ) ), esc_html__( 'Browse Courses', 'accessnow-lms' ) ); } else { echo '
'; foreach ( $enrollments as $e ) { $course = get_post( $e->course_id ); if ( $course ) { Template_Loader::get_partial( 'course-card.php', array( 'course' => $course, 'show_progress' => true, ) ); } } echo '
'; } echo '
'; return ob_get_clean(); } public static function student_dashboard( $atts ) { if ( ! is_user_logged_in() ) { return '

' . esc_html__( 'Please log in to access your dashboard.', 'accessnow-lms' ) . '

'; } ob_start(); include ACCESSNOW_SLMS_PLUGIN_DIR . 'templates/dashboard.php'; return ob_get_clean(); } }