Skip to content

Conversation

@nur-alam
Copy link
Collaborator

No description provided.

…nd auto-play-next

Introduce a new UserPreference class to manage per-user settings including theme (light/dark/system), font scale, and auto-play next lesson. This provides a centralized way to store and retrieve user-specific UI/UX preferences via WordPress user meta.

- Add AJAX endpoint for saving preferences
- Apply theme via data-theme attribute and font scale via CSS
- Update dashboard and account templates with proper HTML structure
- Extend frontend with new PreferenceService and settings UI
- Integrate with existing Tutor core and Alpine.js components
@nur-alam nur-alam requested review from b-l-i-n-d, harunollyo and sazedul-haque and removed request for harunollyo and sazedul-haque January 29, 2026 09:44
@nur-alam nur-alam added the 4.0.0 Tutor v4.w0w label Jan 29, 2026
Fix inconsistent behavior when user preferences are empty by returning an empty array instead of false. This prevents type errors when merging preferences and ensures the default value is properly applied. Also rename variables for clarity and fix filter hook name consistency.
- Move hardcoded font scale options to a filterable method in UserPreference class
- Remove unused preference service exposure and refactor theme initialization
- Clean up font scale calculation by using constants and improve readability
- Fix a typo in a success message string
Initialize mediaQuery and activeTheme in constructor instead of inline
declaration to ensure proper setup order. Use constant for data-theme
attribute to avoid magic strings. Change applyTheme parameter to Theme
type for better type safety.
Replace hard-coded 'system' string literals with THEME.SYSTEM constant
to improve maintainability and consistency across theme handling logic.
…ucture

- Move hardcoded theme options array to UserPreference::get_theme_options() method
- Define DEFAULT_THEME, DEFAULT_FONT_SCALE, and FONT_SCALE_OPTIONS constants
- Use constants consistently across template, PHP class, and TypeScript service
- Simplify font scaling logic in TypeScript by removing unnecessary wrapper function
- Improve error message when saving preferences fails
return;
}

add_action( 'wp_ajax_tutor_save_user_preferences', array( $this, 'tutor_save_user_preferences' ) );
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add prefix ajax to callback method. It's already in a namespace and inside class. Do not use tutor prefix

ajax_save_user_preferences


update_user_meta( $user_id, self::META_KEY, $preferences );

do_action( 'tutor_user_preference_data', $user_id, $preferences );
Copy link
Collaborator

Choose a reason for hiding this comment

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

tutor_user_preference_saved

return array(
array(
'label' => __( 'Light', 'tutor' ),
'value' => 'light',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Create these value as const

const THEME_LIGHT = 'light';
const THEME_DARK = 'dark';
const THEME_SYSTEM = 'system';

Replace magic string theme values with named constants for better maintainability and type safety. Rename hook and method for consistency and update docblock types. Conditionally apply user preferences only on dashboard pages to prevent unintended side effects.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.0.0 Tutor v4.w0w

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants