File to upload: ultra-card-integration.php
Upload to:
ultracard.io/wp-content/plugins/ultra-card-integration/
What changed:
- Added
ultra_card_register_preset_rating_fields()function - Added
ultra_card_get_preset_meta_with_ratings()function - Added
ultra_card_add_preset_cors_headers()filter - Extracts
_drts_voting_ratingmeta and exposes asratingandrating_count
Files to deploy:
ultra-card.js
ultra-card.js.LICENSE.txt
Deploy via HACS or Manual:
# Option A: Git tag for HACS
git add ultra-card.js ultra-card.js.LICENSE.txt dist/
git commit -m "feat: Add clickable star ratings to preset cards"
git tag v2.3.0-beta2
git push origin main --tags
# Option B: Manual copy to Home Assistant
cp ultra-card.js ~/homeassistant/www/ultra-card/Check these settings on ultracard.io:
-
Directories Pro is active
- Go to: Plugins → Installed Plugins
- Ensure "Directories Pro" is activated
-
Voting is enabled for presets
- Go to: Directories → Content Types → Presets
- Check: "Enable Voting" is ON
- Verify: Rating type is "Star Rating" (1-5)
-
Post type is correct
- The post type slug should be
presets_dir_ltg - Or update the PHP array to match your actual post type
- The post type slug should be
-
REST API is accessible
- Visit:
https://ultracard.io/wp-json/wp/v2/presets_dir_ltg - Should return JSON (not 404 error)
- Visit:
Check if rating data is exposed:
# Visit this URL in your browser
https://ultracard.io/wp-json/wp/v2/presets_dir_ltg/123?_embed=true
# Look for this in the response:
{
"preset_meta": {
"rating": 4.5,
"rating_count": 12,
"downloads": 45,
...
}
}- Open Home Assistant
- Edit any Ultra Card
- Go to Presets tab
- Look for Community presets
- Verify:
- Stars appear in top right corner
- Correct number of stars are filled/half/empty
- Review count shows in parentheses
- Hover effect works (stars scale, background changes)
- Click opens preset page in new tab
Symptom: No stars show up on any presets
Possible Causes:
-
WordPress plugin not activated
- Fix: Activate
ultra-card-integration.phpplugin - Check: WordPress admin → Plugins
- Fix: Activate
-
Post type mismatch
- Fix: Update
$post_typesarray in PHP - Check:
get_post_type()for a preset post - Add your actual post type to the array
- Fix: Update
-
No ratings in database
- Fix: Add some test ratings via Directories Pro frontend
- Check: Post meta for
_drts_voting_ratingfield
-
CORS blocking request
- Fix: Check browser console for CORS errors
- Verify:
ultra_card_add_preset_cors_headers()is running - Test: Add logging to the CORS function
Debug Commands:
// Add to functions.php temporarily
add_action('init', function() {
$post_types = get_post_types(array('public' => true));
error_log('Available post types: ' . print_r($post_types, true));
});Symptom: Stars don't match the actual rating
Possible Causes:
-
Rating data format changed
- Check: Current
_drts_voting_ratingstructure - Compare: With the expected format in
ultra_card_get_preset_meta_with_ratings() - Update: PHP parsing logic if needed
- Check: Current
-
Caching issue
- Clear: Browser cache (Ctrl+F5)
- Clear: Service worker cache
- Clear: WordPress object cache
Debug Commands:
// Check rating data for specific post
$post_id = 123;
$rating_data = get_post_meta($post_id, '_drts_voting_rating', true);
error_log('Rating data for post 123: ' . print_r(maybe_unserialize($rating_data), true));Symptom: Clicking stars does nothing
Possible Causes:
-
preset_url is missing
- Check: WordPress REST response includes
linkfield - Verify:
get_permalink()returns valid URL
- Check: WordPress REST response includes
-
Popup blocker
- Try: Allow popups from Home Assistant domain
- Alternative: Use
window.location.hrefinstead ofwindow.open()
-
Event handler not firing
- Check: Browser console for JavaScript errors
- Verify: Build completed successfully
Debug Commands:
// Check in browser console
const preset = ucPresetsService.getPresetsByCategory('all')[0];
console.log('Preset URL:', preset.preset_url);If issues occur, you can quickly rollback:
# Revert to previous tag
git checkout v2.3.0-beta1
npm run build
cp ultra-card.js ~/homeassistant/www/ultra-card/// Comment out the new functions in ultra-card-integration.php
/*
add_action('rest_api_init', 'ultra_card_register_preset_rating_fields');
function ultra_card_register_preset_rating_fields() { ... }
function ultra_card_get_preset_meta_with_ratings() { ... }
add_filter('rest_pre_serve_request', 'ultra_card_add_preset_cors_headers', 10, 4);
function ultra_card_add_preset_cors_headers() { ... }
*/Then re-upload to WordPress.
-
Error Logs
- Location:
wp-content/debug.log - Look for: "Ultra Card: Extracting rating"
- Should see: Successful extractions for each preset
- Location:
-
API Requests
- Check: Browser Network tab
- Endpoint:
/wp-json/wp/v2/presets_dir_ltg - Response should include:
preset_meta.rating
-
User Engagement
- Monitor: Click-through rate to preset pages
- Track: New ratings submitted
- Measure: Preset downloads after ratings added
✅ Stars display correctly for all rated presets ✅ Clicking stars opens preset page ✅ No JavaScript console errors ✅ No PHP errors in debug.log ✅ Users can successfully rate presets ✅ New ratings update in real-time (after refresh)
-
Backup Current State
# Backup WordPress plugin ssh ultracard.io cd wp-content/plugins/ultra-card-integration/ cp ultra-card-integration.php ultra-card-integration.php.backup # Backup Ultra Card files cd ~/homeassistant/www/ultra-card/ cp ultra-card.js ultra-card.js.backup
-
Upload WordPress Changes
- Upload:
ultra-card-integration.php - Method: FTP, cPanel, or SSH
- Verify: Plugin still shows as active after upload
- Upload:
-
Deploy Ultra Card Frontend
- Copy:
ultra-card.jsto Home Assistant - Clear: Browser cache
- Refresh: Home Assistant page (Ctrl+F5)
- Copy:
-
Test Immediately
- Open: Ultra Card editor
- Navigate: Presets tab
- Verify: Stars appear and are clickable
-
Monitor Logs
# Watch WordPress logs tail -f wp-content/debug.log | grep "Ultra Card" # Watch Home Assistant logs tail -f home-assistant.log
-
Announce to Users
- Post: Discord announcement
- Update: Release notes
- Document: In README.md
Add to wp-config.php if you want verbose logging:
define('ULTRA_CARD_DEBUG_RATINGS', true);Then update the PHP function to check this constant.
Users can disable preset ratings if desired (future feature):
# In card config
editor:
show_preset_ratings: true # Default- Ask for screenshots of the Presets tab
- Check browser console for JavaScript errors
- Verify WordPress version meets requirements
- Test with different browsers (Chrome, Firefox, Safari)
- Check Directories Pro version is up to date
Q: Why don't I see stars on all presets? A: Stars only appear for Community presets that have ratings. Built-in and Default presets don't show ratings.
Q: Can I rate directly from the editor? A: Not yet! Click the stars to open the preset page where you can rate. In-editor rating coming in future update.
Q: How often do ratings update? A: Ratings are fetched when you open the Presets tab and cached for 5 minutes. Refresh the tab to see latest ratings.
Q: Why are some stars half-filled? A: Half stars represent decimal ratings. For example, 4.7/5 shows as 4.5 stars (4 full + 1 half).
Weekly:
- Monitor error logs for rating extraction failures
- Check API response times
- Verify CORS headers are working
Monthly:
- Review preset engagement metrics
- Update rating display based on user feedback
- Optimize caching if needed
Quarterly:
- Audit rating data integrity
- Check for Directories Pro updates that might change data structure
- Performance optimization review
- ✅ Added clickable star ratings to preset cards
- ✅ Integrated Directories Pro
_drts_voting_ratingextraction - ✅ Added hover effects and animations
- ✅ Added review count badges
- ✅ Added comprehensive error handling and logging
v2.3.0-beta3 (Planned):
- In-editor rating modal
- Rating submission via API
- Filter by minimum rating
- Sort by "Top Rated"
v2.3.0 (Stable Release):
- Fully tested rating system
- A/B tested optimal star placement
- Performance optimized
- Full documentation