Repository navigation
Blocks Star Rating
Block name: designsetgo/star-rating
Version: 1.0.0
Category: DesignSetGo
Keywords: rating, stars, review, score, testimonial
The Star Rating Block shows a rating as a row of icons — from a fixed value typed in the editor, or bound to post meta, ACF, or a WooCommerce average rating via Block Bindings. It is always server-rendered, because a bound rating can only be resolved at render time; a static block would freeze whatever number the author last saw in the editor.
Key Features:
- Any icon from the plugin's icon library, filled or outlined, sized and spaced independently
- Three display precisions: exact, half-star, or whole-star rounding for the drawn icons — the printed number always stays exact
- Optional numeric value (with "/5" scale), and an optional rating count with a customizable template (e.g.
(128)) -
ratingandratingCountare bindable via the WordPress 6.9 Block Bindings API - Optional JSON-LD structured data (Review or AggregateRating) via a "Schema type" control
- Left/Center/Right justification within the content column
- Insert the Star Rating block.
- Set the Rating and Out of (scale) sliders under Settings.
- Pick an icon and size under Style.
- Optionally connect Rating to a dynamic source (post meta, ACF, or a WooCommerce average) via the block's Connections/Bindings UI.
-
Rating: 0 to the current scale, step 0.1 (
rating, default4.5). Disabled with a note when the attribute is bound to a dynamic source — the slider then shows only a preview value; the frontend uses the bound source. -
Scale ("Out of"): 1–10 (
maxRating, default5). -
Precision: Whole / Half / Exact (
precision, defaulthalf) — controls how far the drawn icons round. The printed value and any structured data are never rounded by this setting. -
Show value: prints the numeric rating (
showValue, defaultfalse); a nested Show scale toggle appends "/5" (showMax, defaultfalse). -
Rating count: Show rating count (
showCount, defaultfalse) reveals Number of ratings (ratingCount, default0, 0–1000) and Count format (countTemplate, default(%s), where%sis replaced by the count).
-
Icon: any icon from the shared icon picker (
icon, defaultstar). -
Icon style: Filled / Outlined (
iconStyle). Unset follows the site-wideicon.defaultStyletoken, which isfilledunless the theme sets it. -
Icon size: 12–96px (
iconSize). Unset follows the theme'sstarRating.defaultSizetoken, which is24unless the theme sets it. See Icon and Marker Size Tokens. -
Icon gap: 0–24px (
iconGap, default4).
A Stars color dropdown in the sidebar's Color panel exposes Rating and Track colors (ratingColor, trackColor) — the filled portion and the unfilled background of each icon, respectively. Both accept theme presets or custom colors; unset values fall back to the current text color.
A "Structured Data" panel (added by the shared schema extension, not specific to this block) offers a Schema type select: None (default), Aggregate rating, or Review (dsgoSchema). Choosing either reveals two fields specific to this block:
-
Item being rated (
schemaItemName) — defaults to the page title when left blank. -
Review author (
schemaAuthor, Review type only) — required; a Review with no author is dropped entirely.
See Related Docs below for how this output is assembled.
Anchor; spacing (margin/padding, both off by default, padding not serialized to the wrapper); color (background/text, text on by default); typography (font size on by default, line height, font family, font weight); border (color/style/width, radius off by default). Visual supports are routed to .dsgo-star-rating__inner, not the block's positioning wrapper — see selectors.root in block.json.
rating and ratingCount are registered as bindable attributes (includes/bindings/class-block-bindings-support.php), so either can be connected to any Block Bindings source — the plugin's own designsetgo/post-meta, designsetgo/acf, designsetgo/woo-average-rating, or a third-party source — through the editor's Connections panel. See BLOCK-BINDINGS.md for the full bindings reference and available sources.
A bound rating disables the Rating slider in the inspector (it becomes preview-only) but does not disable anything else — icon, size, colors, and the value/count display all still apply on top of the bound number.
When Schema type is set, the block's own render.php output is unaffected — the JSON-LD is assembled separately, at wp_head, by reading the post's stored block markup:
-
Aggregate rating emits an
AggregateRatingnode, but only whenratingCountis greater than zero. -
Review emits a
Reviewnode, but only whenschemaAuthoris filled in. -
A bound
ratingorratingCountdisqualifies the block from emitting anything. Structured data is built from the block comment's stored attributes, and Block Bindings never resolve there — only at render time. Publishing whatever number the author last typed as a live claim would be misleading (and, for a bound WooCommerce average, duplicate: WooCommerce already emits its ownProduct/AggregateRatingnode). -
worstRatingis always0(not schema.org's default of1), matching this block's 0-based scale.
- The icon row is
aria-hidden="true"; a visually-hidden<span>carries the full sentence a screen reader announces instead, e.g. "Rated 4.5 out of 5, based on 128 ratings." - The fractional fill is pure CSS (two identical icon rows, the top one clipped by width) — no half-star image asset, and no extra markup per precision level.
- Rating and Track colors both default to sufficient contrast against text color; check contrast manually when overriding both.
-
BLOCK-BINDINGS.md — Block Bindings sources and the
scopeargument for nested loops. - ICON.md — the icon library this block draws from.
- Fully dynamic:
save.jsreturnsnull; all markup comes fromrender.php. - Rating math (clamping, precision snapping, fill percentage, formatting) lives in
includes/features/star-rating-functions.phpand is shared byrender.php, the editor preview, and the JSON-LD builder — the file's own comment explains why: those three consumers must never disagree on the same number. - JSON-LD builders live in
includes/features/schema-builders-rating.php; thedsgoSchemaattribute itself is registered bysrc/extensions/schema/(allowlisted fordesignsetgo/accordionanddesignsetgo/star-ratingonly). - Covered by
tests/phpunit/star-rating-test.php(math + schema builders, driven from parsed block markup rather than hand-built attribute arrays) andtests/unit/blocks/star-rating.test.js. - See 2026-08-24-star-rating-block.md for the original implementation plan.
Auto-generated from
docs/blocks/STAR-RATING.md. To update, edit the source file and changes will sync on next push to main.
- Accordion
- Advanced Heading
- Blobs
- Breadcrumbs
- Card
- Chart
- Comparison Table
- Countdown Timer
- Counter Group
- Divider
- Dynamic Image
- Fifty Fifty
- Flip Card
- Form Builder
- Grid
- Hotspot
- Icon
- Icon Button
- Icon List
- Image Accordion
- Map
- Modal
- Modal Api Reference
- Modal Auto Triggers
- Modal Fse Compatibility
- Modal Gallery Navigation
- Modal Trigger
- Pill
- Product Categories Grid
- Product Showcase Hero
- Progress Bar
- Query
- Query Filter
- Query Group Header
- Query No Results
- Query Pagination
- Query Results
- Row
- Scroll Accordion
- Scroll Marquee
- Scroll Slides
- Section
- Section Divider
- Slider
- Star Rating
- Sticky Sections
- Table Of Contents
- Tabs
- Text Path
- Timeline
- Background Video
- Block Animations
- Clickable Group
- Conditional Visibility
- Custom Css
- Draft Mode
- Dynamic Tags
- Expanding Background
- Grid Mobile Order
- Grid Span
- Hover Effects
- Max Width
- Responsive Visibility
- Reveal Control
- Scroll Parallax
- Sticky Header
- Style Binding
- Svg Patterns
- Text Alignment Inheritance
- Text Reveal
- Abilities Api
- Abilities Api Guide
- Block Bindings
- Draft Mode Api
- Form Webhooks
- Interactive Blocks
- Markdown Content Negotiation
- Rest Api Reference
- Wp Cli Reference
- Ai Assisted Development
- Best Practices Summary
- Block Controls Organization
- Block Development Best Practices Comprehensive
- Block Exclusion Guide
- Deploying To Wordpress Org
- Design System
- 2026 04 16 Blocks Editor Ux Design
- 2026 04 17 Theme 3 Inspector Ia
- 2026 04 21 Query Block Onboarding
- 2026 04 21 Query Capable Layout Blocks Design
- 2026 04 27 Block Roadmap Ideas
- 2026 07 01 Shape Divider Theme Inheritance
- 2026 07 02 Icon Block Dynamic Render Pilot
- 2026 07 06 Section Divider Block Design
- 2026 07 06 Section Style Variations Fse Design
- 2026 07 06 Section Styles Editor Preview
- 2026 07 07 Row Grid Overlay Hover Parity Design
- 2026 07 21 Conditional And Dup Label Sourcing
- 2026 07 23 Theme Block Type Animation Defaults
- 2026 08 16 Chart Block
- 2026 08 16 Greenshift Gap Roadmap
- 2026 08 17 Woocommerce Surface
- 2026 08 24 Loop Carousel
- 2026 08 24 Star Rating Block
- 2026 09 17 Abilities Drift Prevention
- 2026 09 17 Abilities Drift Prevention Implementation
- 2026 09 29 Existing User Regression Fixes
- 2026 09 29 Release Preflight Fixes
- Readme
- 2026 07 02 Block Authorability Audit
- 2026 09 29 Regression Fixes
- 2026 09 29 Release 2.9.0
- 2026 09 29 Release Fixes