Overview
The plugin registers three AJAX endpoints through WordPress’s admin-ajax.php system. No custom REST API routes are registered by the plugin itself.
Star Rating Submission
Action: acf_star_rating_submit
Auth: Both logged-in and anonymous users (wp_ajax_ and wp_ajax_nopriv_)
File: blocks/star-rating-block/extra.php
Accepts a star rating submission from a visitor and updates the aggregate rating stored in post meta.
Request Parameters
nonce– WordPress nonce foracf_star_rating_submit(required).postId– The post ID being rated (required, must be > 0).blockId– The unique block instance ID (required).rating– The rating value, between 1 and 5 (required).
Response
On success, returns:
average– The new average rating (float, rounded to 2 decimals).averageFormatted– Localized average (e.g. “4.2”).count– Total number of ratings.countText– Localized count text (e.g. “42 ratings”).
Storage
Ratings are stored in post meta under the key _acf_star_rating_{block_id}. The meta value is an array with count and sum fields. This allows accurate average calculation without storing individual ratings.
The frontend JavaScript stores a “rated” flag in localStorage (keyed by post ID + block ID) to prevent duplicate submissions from the same browser.
URL Preview Fetch
Action: acf_url_preview_fetch
Auth: Admin only (requires edit_posts capability)
File: blocks/url-preview/extra.php
Fetches a URL and extracts Open Graph metadata (title, description, image) for populating the URL Preview block fields.
Request Parameters
nonce– WordPress nonce foracf_url_preview_fetch(required).url– The URL to fetch metadata from (required).
Response
On success, returns:
title– Page title (from og:title, twitter:title, or<title>tag).description– Page description (from og:description or meta description). Truncated to 300 characters.image– Image URL (from og:image, twitter:image, or first suitable<img>on the page).
Caching
Results are cached in a WordPress transient for 1 week. The cache key is acf_url_preview_{md5(url)}.
Metadata Extraction Priority
For each field, the parser tries sources in order:
Title: og:title -> twitter:title -> <title> tag
Description: og:description -> meta description
Image: og:image -> twitter:image -> first large <img> in content (skips images with width < 600px, data URIs, and common icon/logo patterns)
URL Preview Image Import
Action: acf_url_preview_import_image
Auth: Admin only (requires upload_files capability)
File: blocks/url-preview/extra.php
Downloads an external image and imports it into the WordPress media library.
Request Parameters
nonce– WordPress nonce foracf_url_preview_import(required).image_url– The external image URL to import (required).post_id– The post ID to attach the image to (optional).
Response
On success, returns:
attachment_id– The WordPress attachment ID of the imported image.url– The local URL of the imported image.message– Success message.
Deduplication
Before downloading, the handler checks for existing attachments with a _acf_url_preview_source meta value matching the image URL. If found, the existing attachment ID is returned without re-downloading.
Security
All three endpoints verify WordPress nonces and check user capabilities. The star rating endpoint accepts submissions from anonymous users (required for visitor ratings), while the URL preview endpoints are restricted to authenticated users with appropriate capabilities.