### Install WPCS Composer Packages Source: https://github.com/themeum/tutor/blob/master/readme.md Install the required PHP CodeSniffer and WordPress Coding Standards packages globally. ```bash 1. composer global require squizlabs/php_codesniffer 2. composer global require wp-coding-standards/wpcs ``` -------------------------------- ### Install Cypress Dependencies Source: https://github.com/themeum/tutor/blob/master/readme.md Install project dependencies required for running Cypress tests. ```bash npm install ``` -------------------------------- ### Configure WPCS for WordPress Source: https://github.com/themeum/tutor/blob/master/readme.md Set the installed paths and default coding standard to WordPress. ```bash phpcs --config-set installed_paths /Users/your_username/.composer/vendor/wp-coding-standards/wpcs phpcs --config-set default_standard WordPress ``` -------------------------------- ### Run PHP Unit Tests Source: https://github.com/themeum/tutor/blob/master/readme.md Commands to install dependencies, set up the test database, and execute PHPUnit tests. ```bash 1. composer install 2. bash bin/install-wp-tests.sh db_name user_name password host latest 3. vendor/bin/phpunit --info ``` -------------------------------- ### Cypress Environment Configuration Source: https://github.com/themeum/tutor/blob/master/readme.md Example content for the .env file required for Cypress test authentication and configuration. ```text # WordPress site URL CYPRESS_base_url= # Admin credentials CYPRESS_admin_username= CYPRESS_admin_password= # Zoom credentials CYPRESS_instructor_zoom_account_id= CYPRESS_instructor_zoom_client_id= CYPRESS_instructor_zoom_client_secret= ``` -------------------------------- ### Check if Quiz is Started Source: https://context7.com/themeum/tutor/llms.txt Determine if a user has started a particular quiz. Returns attempt details if started. ```php is_started_quiz($quiz_id); ``` -------------------------------- ### Get Course Contents by Topic Source: https://context7.com/themeum/tutor/llms.txt Retrieve all content items (lessons, quizzes, etc.) belonging to a specific topic. Use -1 for limit to get all. ```php get_course_contents_by_topic($topic_id, -1); ``` -------------------------------- ### Get Raw Course Price Source: https://context7.com/themeum/tutor/llms.txt Retrieve the regular and sale prices for a course. ```php get_raw_course_price($course_id); echo "Regular Price: " . $price->regular_price; echo "Sale Price: " . $price->sale_price; ``` -------------------------------- ### GET /wp-json/tutor/v1/author-information/{user_id} Source: https://context7.com/themeum/tutor/llms.txt Retrieves instructor profile information. ```APIDOC ## GET /wp-json/tutor/v1/author-information/{user_id} ### Description Retrieve instructor profile information. ### Method GET ### Endpoint /wp-json/tutor/v1/author-information/{user_id} ### Parameters #### Path Parameters - **user_id** (integer) - Required - The ID of the instructor whose information is to be retrieved. ### Request Example ```bash curl -X GET "https://yoursite.com/wp-json/tutor/v1/author-information/42" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ``` -------------------------------- ### GET /wp-json/tutor/v1/course-rating/{course_id} Source: https://context7.com/themeum/tutor/llms.txt Retrieves ratings and reviews for a specific course. ```APIDOC ## GET /wp-json/tutor/v1/course-rating/{course_id} ### Description Retrieve ratings and reviews for a specific course. ### Method GET ### Endpoint /wp-json/tutor/v1/course-rating/{course_id} ### Parameters #### Path Parameters - **course_id** (integer) - Required - The ID of the course to retrieve ratings for. #### Query Parameters - **offset** (integer) - Optional - The number of records to skip. - **limit** (integer) - Optional - The maximum number of records to return. ### Response #### Success Response (200) - **code** (string) - Indicates the status of the request, e.g., "success". - **message** (string) - A message describing the result of the request. - **data** (object) - Contains the rating and review information. - **rating_avg** (float) - The average rating for the course. - **rating_count** (integer) - The total number of ratings. - **reviews** (array) - A list of reviews for the course. - **comment_ID** (integer) - The ID of the review comment. - **comment_content** (string) - The content of the review. - **rating** (integer) - The rating given in the review. - **user_id** (integer) - The ID of the user who submitted the review. ### Response Example ```json { "code": "success", "message": "Course rating retrieved successfully", "data": { "rating_avg": 4.5, "rating_count": 150, "reviews": [ { "comment_ID": 1, "comment_content": "Great course!", "rating": 5, "user_id": 42 } ] } } ``` ``` -------------------------------- ### Get Lessons by Topic ID Source: https://context7.com/themeum/tutor/llms.txt Retrieve lessons that belong to a specific topic within a course. Requires an API key for authorization. ```bash curl -X GET "https://yoursite.com/wp-json/tutor/v1/lessons?topic_id=456" \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Get User Profile URL Source: https://context7.com/themeum/tutor/llms.txt Generate the URL for a user's profile page, with an option to view as an instructor. ```php profile_url($user_id, $instructor_view = true); ``` -------------------------------- ### Get Author/Instructor Information Source: https://context7.com/themeum/tutor/llms.txt Retrieve profile information for a specific author or instructor using their user ID. ```bash curl -X GET "https://yoursite.com/wp-json/tutor/v1/author-information/42" \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Get and Set Tutor LMS Options Source: https://context7.com/themeum/tutor/llms.txt Use `tutor_utils()->get_option()` to retrieve configuration values and `tutor_utils()->update_option()` to modify them. Default values can be provided for `get_option` if the option does not exist. ```php get_option('monetize_by'); // 'wc', 'edd', 'tutor' $courses_per_page = tutor_utils()->get_option('courses_per_page', 12); $enable_qa = tutor_utils()->get_option('enable_q_and_a_on_course', true); // Get option with dot notation for nested values $time_type = tutor_utils()->get_option('time_limit.time_type'); // Update option tutor_utils()->update_option('courses_per_page', 16); // Check specific settings $can_publish = tutor_utils()->get_option('instructor_can_publish_course', false); $is_marketplace = tutor_utils()->get_option('enable_course_marketplace'); ``` -------------------------------- ### Get All Courses with Pagination and Filters Source: https://context7.com/themeum/tutor/llms.txt Retrieve a paginated list of published courses. Supports filtering by order, orderby, pagination, and categories. Requires an API key for authorization. ```bash # Get all courses with default pagination curl -X GET "https://yoursite.com/wp-json/tutor/v1/courses" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```bash # Get courses with filters curl -X GET "https://yoursite.com/wp-json/tutor/v1/courses?order=DESC&orderby=title&paged=1&categories=web-development,design" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```json { "code": "success", "message": "Course retrieved successfully", "data": { "posts": [ { "ID": 123, "post_title": "Complete Web Development", "post_content": "Course description...", "post_author": { "ID": 1, "user_login": "instructor", "display_name": "John Doe" }, "thumbnail_url": "https://yoursite.com/wp-content/uploads/course-thumb.jpg", "ratings": { "rating_avg": 4.5, "rating_count": 150 }, "course_category": [...], "course_tag": [...], "price": "99.00", "additional_info": {...} } ], "total_course": 50, "total_page": 5 } } ``` -------------------------------- ### Get Questions by Quiz Source: https://context7.com/themeum/tutor/llms.txt Retrieve all questions associated with a specific quiz. ```php get_questions_by_quiz($quiz_id); ``` -------------------------------- ### GET /tutor/v1/quizzes/{id} Source: https://context7.com/themeum/tutor/llms.txt Retrieve quiz information, settings, and associated questions. ```APIDOC ## GET /tutor/v1/quizzes/{id} ### Description Retrieve quiz information with settings or specific quiz details. ### Method GET ### Endpoint /wp-json/tutor/v1/quizzes/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique ID of the quiz ### Response #### Success Response (200) - **data** (object) - Quiz settings and metadata ``` -------------------------------- ### Get Instructor List Source: https://context7.com/themeum/tutor/llms.txt Retrieve a paginated list of instructors, with options for searching, filtering by course, and sorting. ```php get_instructors( $offset = 0, $limit = 10, $search_term = '', $course_id = '', $date = '', $order = 'ASC', $status = 'approved' ); ``` -------------------------------- ### GET /tutor/v1/course-contents/{id} Source: https://context7.com/themeum/tutor/llms.txt Retrieve the complete curriculum structure for a course, including topics, lessons, and quizzes. ```APIDOC ## GET /tutor/v1/course-contents/{id} ### Description Retrieve the complete curriculum structure for a course. ### Method GET ### Endpoint /wp-json/tutor/v1/course-contents/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique ID of the course ### Response #### Success Response (200) - **data** (array) - List of topics containing lessons and quizzes ``` -------------------------------- ### Get Enrolled Courses by User Source: https://context7.com/themeum/tutor/llms.txt Retrieve a list of all courses a specific user is enrolled in. ```php get_enrolled_courses_by_user($user_id); ``` -------------------------------- ### GET /tutor/v1/courses Source: https://context7.com/themeum/tutor/llms.txt Retrieve a paginated list of all published courses with categories, tags, author details, and ratings. ```APIDOC ## GET /tutor/v1/courses ### Description Retrieve a paginated list of all published courses. ### Method GET ### Endpoint /wp-json/tutor/v1/courses ### Parameters #### Query Parameters - **order** (string) - Optional - Sort order (DESC/ASC) - **orderby** (string) - Optional - Field to order by (e.g., title) - **paged** (integer) - Optional - Page number for pagination - **categories** (string) - Optional - Comma-separated list of category slugs ### Response #### Success Response (200) - **code** (string) - Status code - **message** (string) - Success message - **data** (object) - Contains posts array, total_course, and total_page ``` -------------------------------- ### GET /tutor/v1/courses/{id} Source: https://context7.com/themeum/tutor/llms.txt Retrieve detailed information about a specific course including settings, duration, level, and materials. ```APIDOC ## GET /tutor/v1/courses/{id} ### Description Retrieve detailed information about a specific course. ### Method GET ### Endpoint /wp-json/tutor/v1/courses/{id} ### Parameters #### Path Parameters - **id** (integer) - Required - The unique ID of the course ### Response #### Success Response (200) - **data** (object) - Detailed course settings, price, duration, level, and media info ``` -------------------------------- ### GET /wp-json/tutor/v1/quiz-attempt-details/{attempt_id} Source: https://context7.com/themeum/tutor/llms.txt Retrieves the details of a specific quiz attempt. ```APIDOC ## GET /wp-json/tutor/v1/quiz-attempt-details/{attempt_id} ### Description Retrieves the details of a specific quiz attempt using its ID. ### Method GET ### Endpoint /wp-json/tutor/v1/quiz-attempt-details/{attempt_id} ### Parameters #### Path Parameters - **attempt_id** (integer) - Required - The ID of the quiz attempt to retrieve. ### Request Example ```bash curl -X GET "https://yoursite.com/wp-json/tutor/v1/quiz-attempt-details/789" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ``` -------------------------------- ### Get Specific Course Details Source: https://context7.com/themeum/tutor/llms.txt Retrieve detailed information for a single course using its ID. Includes settings, duration, level, and materials. Requires an API key for authorization. ```bash # Get course details by ID curl -X GET "https://yoursite.com/wp-json/tutor/v1/courses/123" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```json { "code": "course_detail", "message": "Course detail retrieved successfully", "data": { "course_settings": {...}, "course_price_type": "paid", "course_duration": {"hours": "10", "minutes": "30"}, "course_level": "intermediate", "course_benefits": "What you'll learn...", "course_requirements": "Prerequisites...", "course_target_audience": "This course is for...", "course_material_includes": "Downloadable resources...", "video": {"source": "youtube", "source_youtube": "https://..."}, "disable_qa": false } } ``` -------------------------------- ### Get Course Duration Source: https://context7.com/themeum/tutor/llms.txt Retrieve the duration of a course in a specified format. ```php get_course_duration($course_id, false); ``` -------------------------------- ### Get Course Topics Source: https://context7.com/themeum/tutor/llms.txt Retrieve all topics associated with a course. Requires WP_Query loop. ```php get_topics($course_id); while ($topics->have_posts()) { $topics->the_post(); echo get_the_title(); } ``` -------------------------------- ### Get Course Contents by Course ID Source: https://context7.com/themeum/tutor/llms.txt Retrieve the complete curriculum structure for a course, including topics, lessons, and quizzes. Requires an API key for authorization. ```bash # Get course contents by course ID curl -X GET "https://yoursite.com/wp-json/tutor/v1/course-contents/123" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```json { "code": "success", "message": "Course contents retrieved successfully", "data": [ { "id": 456, "title": "Getting Started", "summary": "Introduction to the course", "contents": [ { "ID": 789, "post_title": "Welcome Lesson", "post_type": "lesson" }, { "ID": 790, "post_title": "Module Quiz", "post_type": "tutor_quiz", "total_question": 10 } ] } ] } ``` -------------------------------- ### Get Course Rating Information Source: https://context7.com/themeum/tutor/llms.txt Retrieve the average rating and total review count for a course. ```php get_course_rating($course_id); echo "Average Rating: " . $rating->rating_avg; echo "Total Reviews: " . $rating->rating_count; ``` -------------------------------- ### Get Tutor Dashboard URL Source: https://context7.com/themeum/tutor/llms.txt Generate URLs for the Tutor dashboard, including specific sections like 'my-courses'. ```php tutor_dashboard_url(); $my_courses_url = tutor_utils()->tutor_dashboard_url('my-courses'); ``` -------------------------------- ### Get Course Topics by Course ID Source: https://context7.com/themeum/tutor/llms.txt Retrieve all topics associated with a specific course. Requires an API key for authorization. ```bash curl -X GET "https://yoursite.com/wp-json/tutor/v1/topics?course_id=123" \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Get Course Ratings and Reviews Source: https://context7.com/themeum/tutor/llms.txt Retrieve ratings and reviews for a specific course using its ID. Supports pagination with offset and limit parameters. ```bash curl -X GET "https://yoursite.com/wp-json/tutor/v1/course-rating/123?offset=0&limit=10" \ -H "Authorization: Bearer YOUR_API_KEY" ``` ```json { "code": "success", "message": "Course rating retrieved successfully", "data": { "rating_avg": 4.5, "rating_count": 150, "reviews": [ { "comment_ID": 1, "comment_content": "Great course!", "rating": 5, "user_id": 42 } ] } } ``` -------------------------------- ### Get Quiz Option/Setting Source: https://context7.com/themeum/tutor/llms.txt Retrieve specific settings or options for a quiz, such as time limit or passing grade. ```php get_quiz_option($quiz_id, 'time_limit.time_value'); $passing_grade = tutor_utils()->get_quiz_option($quiz_id, 'passing_grade', 0); ``` -------------------------------- ### Get Quiz Attempt Details Source: https://context7.com/themeum/tutor/llms.txt Retrieve details for a specific quiz attempt using its ID. ```bash curl -X GET "https://yoursite.com/wp-json/tutor/v1/quiz-attempt-details/789" \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Get Course Announcements by Course ID Source: https://context7.com/themeum/tutor/llms.txt Retrieve announcements made for a specific course. Requires an API key for authorization. ```bash curl -X GET "https://yoursite.com/wp-json/tutor/v1/course-announcement/123" \ -H "Authorization: Bearer YOUR_API_KEY" ``` -------------------------------- ### Get Quiz Attempt Details Source: https://context7.com/themeum/tutor/llms.txt Retrieve detailed information about a specific quiz attempt using its attempt ID. ```php get_attempt($attempt_id); ``` -------------------------------- ### Get Tutor User Data Source: https://context7.com/themeum/tutor/llms.txt Retrieve user data, including Tutor-specific fields like display name and profile photo URL. ```php get_tutor_user($user_id); echo $tutor_user->display_name; echo $tutor_user->tutor_profile_photo_url; ``` -------------------------------- ### Tutor Quiz Hooks Source: https://context7.com/themeum/tutor/llms.txt These actions allow you to hook into various stages of the quiz process, including starting, ending, and reviewing quiz attempts. They are useful for logging, tracking progress, and handling quiz timeouts. ```php { const response = await wpAjaxInstance.get('/courses'); return response.data; }; // Feature Flag Usage const shouldShowNewFeature = tutorConfig.features?.newDashboard?.enabled; // Environment-specific Logic const isProduction = tutorConfig.environment === 'production'; ``` -------------------------------- ### Using Constants for Responsive Design and Validation Source: https://github.com/themeum/tutor/blob/master/stories/Docs/GettingStarted.mdx Import constants like `BREAKPOINTS` and `FILE_SIZE_LIMIT` from `@TutorShared/config/constants`. Use `BREAKPOINTS` for responsive layouts and `FILE_SIZE_LIMIT` for file validation. ```typescript import { BREAKPOINTS, FILE_SIZE_LIMIT, DateFormats, DEFAULT_FORM_FIELD_PROPS } from '@TutorShared/config/constants'; // Responsive Design Implementation const useResponsiveLayout = () => { const [isMobile, setIsMobile] = useState(window.innerWidth < BREAKPOINTS.md); useEffect(() => { const handleResize = () => setIsMobile(window.innerWidth < BREAKPOINTS.md); window.addEventListener('resize', handleResize); return () => window.removeEventListener('resize', handleResize); }, []); return { isMobile }; }; // File Upload Validation const validateFileSize = (file: File) => { return file.size <= FILE_SIZE_LIMIT.image; }; ``` -------------------------------- ### User Registration and Completion Filter Hooks Source: https://context7.com/themeum/tutor/llms.txt Filters for validating registration fields and controlling course/lesson completion logic. ```php do_enroll($course_id, $order_id = 0, $user_id); if ($enroll_id) { echo 'Successfully enrolled!'; } ``` -------------------------------- ### Display E-commerce Pages Shortcodes Source: https://context7.com/themeum/tutor/llms.txt Use `[tutor_cart]` to display the shopping cart page and `[tutor_checkout]` to display the checkout page. These are used for Tutor's native monetization features. ```shortcode [tutor_cart] ``` ```shortcode [tutor_checkout] ``` -------------------------------- ### Tutor Course Lifecycle Hooks Source: https://context7.com/themeum/tutor/llms.txt These actions hook into the course creation and saving process. Use them to initialize settings, process custom data, or perform actions after a course is saved. ```php is_course_purchasable($course_id); ``` -------------------------------- ### Get Course ID by Content Type Source: https://context7.com/themeum/tutor/llms.txt Retrieve the course ID associated with various content types like lessons, quizzes, or topics. ```php get_course_id_by('lesson', $lesson_id); $course_id = tutor_utils()->get_course_id_by('quiz', $quiz_id); $course_id = tutor_utils()->get_course_id_by('topic', $topic_id); ``` -------------------------------- ### Display Instructor List Shortcodes Source: https://context7.com/themeum/tutor/llms.txt Use the `[tutor_instructor_list]` shortcode to display a grid of instructors. You can enable filtering, customize the layout, and set the number of instructors to show. Available layouts include 'default', 'cover', 'minimal', 'portrait-horizontal', and 'minimal-horizontal'. ```shortcode [tutor_instructor_list] ``` ```shortcode [tutor_instructor_list filter="on" layout="cover" column_per_row="4" count="12"] ``` ```shortcode [tutor_instructor_list layout="minimal" category_limit="10" hide_empty_category="1"] ``` -------------------------------- ### Tutor Utility Functions (PHP) Source: https://context7.com/themeum/tutor/llms.txt Provides a collection of PHP utility functions for managing courses, enrollments, users, and quizzes within the Tutor LMS plugin. ```APIDOC ## PHP Utility Functions (tutor_utils()) ### Get Course Information Utility functions for retrieving course-related data. ```php get_course_id_by('lesson', $lesson_id); $course_id = tutor_utils()->get_course_id_by('quiz', $quiz_id); $course_id = tutor_utils()->get_course_id_by('topic', $topic_id); // Check if user is enrolled in a course $is_enrolled = tutor_utils()->is_enrolled($course_id, $user_id); if ($is_enrolled) { echo 'User has access to this course'; } // Get course rating information $rating = tutor_utils()->get_course_rating($course_id); echo "Average Rating: " . $rating->rating_avg; echo "Total Reviews: " . $rating->rating_count; // Check if course is purchasable $is_purchasable = tutor_utils()->is_course_purchasable($course_id); // Get course price $price = tutor_utils()->get_raw_course_price($course_id); echo "Regular Price: " . $price->regular_price; echo "Sale Price: " . $price->sale_price; // Get course topics $topics = tutor_utils()->get_topics($course_id); while ($topics->have_posts()) { $topics->the_post(); echo get_the_title(); } // Get course content by topic $contents = tutor_utils()->get_course_contents_by_topic($topic_id, -1); // Get course duration $duration = tutor_utils()->get_course_duration($course_id, false); ?> ``` ### Enrollment Management Functions for managing student enrollments. ```php do_enroll($course_id, $order_id = 0, $user_id); if ($enroll_id) { echo 'Successfully enrolled!'; } // Cancel enrollment tutor_utils()->cancel_course_enrol($course_id, $user_id); // Count enrolled students $enrolled_count = tutor_utils()->count_enrolled_users_by_course($course_id); // Check if course is fully booked (member limit reached) $is_full = tutor_utils()->is_course_fully_booked($course_id); // Get enrolled courses for a user $courses = tutor_utils()->get_enrolled_courses_by_user($user_id); ?> ``` ### User and Instructor Functions Functions for managing users and instructors. ```php is_instructor($user_id); // Check if user is instructor of specific course $is_course_instructor = tutor_utils()->is_instructor_of_this_course($user_id, $course_id); // Get instructor list with pagination $instructors = tutor_utils()->get_instructors( $offset = 0, $limit = 10, $search_term = '', $course_id = '', $date = '', $order = 'ASC', $status = 'approved' ); // Get user profile URL $profile_url = tutor_utils()->profile_url($user_id, $instructor_view = true); // Get dashboard URL $dashboard_url = tutor_utils()->tutor_dashboard_url(); $my_courses_url = tutor_utils()->tutor_dashboard_url('my-courses'); // Get user data with tutor-specific fields $tutor_user = tutor_utils()->get_tutor_user($user_id); echo $tutor_user->display_name; echo $tutor_user->tutor_profile_photo_url; ?> ``` ### Quiz Functions Functions for quiz management and attempts. ```php get_quiz_option($quiz_id, 'time_limit.time_value'); $passing_grade = tutor_utils()->get_quiz_option($quiz_id, 'passing_grade', 0); // Check if quiz is started $attempt = tutor_utils()->is_started_quiz($quiz_id); // Get quiz attempt details $attempt = tutor_utils()->get_attempt($attempt_id); // Get questions by quiz $questions = tutor_utils()->get_questions_by_quiz($quiz_id); // Calculate completion stats $completed = tutor_utils()->get_completed_lesson_count_by_course($course_id); $total = tutor_utils()->get_lesson_count_by_course($course_id); $progress = ($completed / $total) * 100; ?> ``` ``` -------------------------------- ### Run Cypress Tests Source: https://github.com/themeum/tutor/blob/master/readme.md Commands for executing Cypress tests in various modes. ```bash npm run cy:open ``` ```bash npm run test ``` ```bash npx cypress run --spec "cypress/e2e/backend/**/*.cy.ts" ``` ```bash npx cypress run --browser chrome ``` -------------------------------- ### Instructor Management Action Hooks Source: https://context7.com/themeum/tutor/llms.txt Hooks for handling instructor registration, approval, and blocking events. ```php is_enrolled($course_id, $user_id); if ($is_enrolled) { echo 'User has access to this course'; } ``` -------------------------------- ### Lesson Lifecycle Action Hooks Source: https://context7.com/themeum/tutor/llms.txt Hooks triggered during the creation, update, and completion of lessons. ```php ``` ``` -------------------------------- ### Build Advanced Course Form Source: https://github.com/themeum/tutor/blob/master/stories/Docs/GettingStarted.mdx A form implementation using react-hook-form for state management. Use the Controller component for integrating custom inputs. ```tsx import { css } from '@emotion/react'; import { spacing, colorTokens } from '@TutorShared/config/styles'; import { typography } from '@TutorShared/config/typography'; import { useForm, Controller } from 'react-hook-form'; interface CourseFormData { title: string; description: string; category: string; level: 'beginner' | 'intermediate' | 'advanced'; price: number; published: boolean; } const CourseForm: React.FC = () => { const { control, handleSubmit, formState } = useForm(); const handleFormSubmit = (data: CourseFormData) => { console.log('Course data:', data); }; return (
{/* Form implementation with Controller components */}
); }; ``` -------------------------------- ### Lesson AJAX Endpoints Source: https://context7.com/themeum/tutor/llms.txt Endpoints for managing lesson data. ```APIDOC ## POST /wp-admin/admin-ajax.php (tutor_save_lesson) ### Description Saves a new or existing lesson. ### Method POST ### Endpoint /wp-admin/admin-ajax.php ### Parameters #### Request Body - **action** (string) - Required - Must be 'tutor_save_lesson' - **_wpnonce** (string) - Required - WordPress nonce for security - **topic_id** (integer) - Required - The ID of the topic this lesson belongs to - **lesson_id** (integer) - Optional - The ID of the lesson to update. Use 0 for a new lesson. - **title** (string) - Required - The title of the lesson - **description** (string) - Required - The content of the lesson ### Request Example ```json { "action": "tutor_save_lesson", "_wpnonce": "your_nonce_here", "topic_id": 456, "lesson_id": 0, "title": "Lesson Title", "description": "Lesson content..." } ``` ## POST /wp-admin/admin-ajax.php (tutor_delete_lesson) ### Description Deletes a lesson. ### Method POST ### Endpoint /wp-admin/admin-ajax.php ### Parameters #### Request Body - **action** (string) - Required - Must be 'tutor_delete_lesson' - **_wpnonce** (string) - Required - WordPress nonce for security - **lesson_id** (integer) - Required - The ID of the lesson to delete ### Request Example ```json { "action": "tutor_delete_lesson", "_wpnonce": "your_nonce_here", "lesson_id": 789 } ``` ## POST /wp-admin/admin-ajax.php (tutor_render_lesson_content) ### Description Renders the content of a lesson, typically for display in the course player. ### Method POST ### Endpoint /wp-admin/admin-ajax.php ### Parameters #### Request Body - **action** (string) - Required - Must be 'tutor_render_lesson_content' - **_wpnonce** (string) - Required - WordPress nonce for security - **lesson_id** (integer) - Required - The ID of the lesson to render ### Request Example ```json { "action": "tutor_render_lesson_content", "_wpnonce": "your_nonce_here", "lesson_id": 789 } ``` ### Response #### Success Response (200) - **data.html** (string) - The HTML content of the lesson ``` -------------------------------- ### Component Styling with Design Tokens Source: https://github.com/themeum/tutor/blob/master/stories/Docs/GettingStarted.mdx Apply styles using design tokens for background, borders, spacing, and shadows. Ensure consistency and ease of global design changes. ```typescript import { colorTokens, spacing, borderRadius, shadow, } from '@TutorShared/config/styles'; import { typography } from '@TutorShared/config/typography'; // Component Styling with Tokens const cardStyles = css` background: ${colorTokens.background.white}; border: 1px solid ${colorTokens.stroke.default}; border-radius: ${borderRadius[12]}; box-shadow: ${shadow[2]}; padding: ${spacing[24]}; &:hover { border-color: ${colorTokens.stroke.hover}; box-shadow: ${shadow[4]}; transform: translateY(-2px); transition: all 0.2s ease; } `; // Theme-aware Color Usage const getStatusColor = (status: 'success' | 'warning' | 'error') => { const statusColors = { success: colorTokens.status.success, warning: colorTokens.status.warning, error: colorTokens.status.error }; return statusColors[status]; }; ```