Developer notes
Overview · Installation · Configuration · Usage · FAQ
The add-on never modifies core files. It uses PHP hooks, template hooks, two product tabs, its own controllers, .pre/.post controllers of core and partner dispatches, .post schemas and three e-mail templates. Add-on id kv_photo_video_reviews, priority 3100 (after the core Product reviews, 3001).
Data model
Section titled “Data model”| Table | Content |
|---|---|
?:kv_pvr_media |
Review videos: review, product, owner company (vendor in MV), storefront, type (upload, youtube, vimeo), validated video id, file and poster paths in the image storage, MIME, size, length, width/height, title, status (P pending, A approved, D rejected) |
?:kv_pvr_questions |
Questions: product, owner company, storefront, customer, name, e-mail, text, status, notify flag, approved answers count, language, IP |
?:kv_pvr_answers |
Answers: question, author type (A store, V vendor, C customer), vendor, name, text, verified buyer, status, helpful count |
?:kv_pvr_votes |
One helpful vote per answer and visitor (user id or hashed IP) |
?:kv_pvr_rewards |
Reward coupons: review (unique), product, customer, e-mail, promotion, code, status (A active, U used, E expired, W withdrawn), expiry, order |
?:kv_pvr_review_meta |
Source of a review (form, email from a signed link, rre from Review Request E-mails) and the order of signed links |
Video files and posters are stored in the public images storage under kv_pvr/videos/xx/ and kv_pvr/posters/xx/ with random 32-character names. Only .mp4, .webm and .jpg are written. MOV files are stored as .mp4. This works with CDN storage backends.
| Hook | Where (4.21.2 / 4.17.2) | What the add-on does |
|---|---|---|
product_reviews_create_pre |
product_reviews Repository.php 394 / 394 | Removes metadata from uploaded review photos (temporary upload files) before the core stores them; signed review link: is_buyer = Y |
product_reviews_create_post |
Repository.php 410 / 410 | Stores the validated videos, records the review source, fires kv_photo_video_reviews_review_created, checks the reward of reviews created approved |
product_reviews_find_pre |
Repository.php 210 / 210 | Storefront filter kv_media=video / any |
product_reviews_is_user_eligible_to_write_product_review |
Service.php 315 / 315 | A signed review link counts as a purchase (“only buyers can review”) |
product_reviews_delete_reviews_by_product_id |
Service.php 160 / 160 | Deletes the videos of deleted reviews |
tools_change_status |
fn.common.php 5005 / 4870 | A review was approved: reward check |
place_order |
fn.cart.php 1678 / 1585 | A reward code used in the order is withdrawn from its promotion |
delete_product_post |
fn.products.php 1086 / 1072 | Deletes the product’s questions |
seo_get_schema_org_markup_items_post, seo_dispatch_before_display_before_cache |
seo func.php | Adds image and video (VideoObject) to the core Review items, and adds the video table to the markup cache conditions |
init_templater_post |
Only while an upgrade synchronization is pending |
All arguments are identical in 4.17.2 and 4.21.2. Single reviews deleted in the admin panel (no core hook) are handled by controllers/backend/product_reviews.post.php and by an orphan sweep in the maintenance run.
Template hooks (responsive; inherited by Nova and child themes): product_reviews:add_product_review (post: video fields and reward hint), product_reviews:post_content (post: video players of a review), products:main_info_title (post: hidden source of the filter buttons, moved under the core sorting by script), kv_review_request_emails:review_item (post: video fields on the Review Request E-mails page). Product tabs: blocks/product_tabs/kv_pvr_gallery.tpl and kv_pvr_questions.tpl (HTML ids kv_pvr_gallery, kv_pvr_questions for selected_section).
Add-on PHP hooks for other add-ons:
kv_photo_video_reviews_review_created ($product_review_id, $meta), where$metahas source, order_id and email;kv_photo_video_reviews_question_created ($question_id, $row);kv_photo_video_reviews_reward_issued ($reward_id, $product_review_id, $code).
Integration API (review links)
Section titled “Integration API (review links)”if (function_exists('fn_kv_photo_video_reviews_is_available') && fn_kv_photo_video_reviews_is_available()) { $url = fn_kv_photo_video_reviews_get_review_url($product_id, [ 'order_id' => $order_id, // with email: signed link 'email' => $order_email, // must be the order's e-mail 'ttl_days' => 30, // default 30, 1-365 'lang_code' => $lang_code, 'source' => 'email', // recorded on the review (a-z, 0-9, _; 16 chars) // 'storefront_id' / 'company_id': storefront of the URL (taken from the order when omitted) ]);}- Without
order_idandemail, it returns the product page with the review form opened (products.view?product_id=X&selected_section=product_reviews&kv_write=1). - With them, it returns
kv_photo_video_reviews.write?product_id=X&t=v1.<product>.<order>.<expires>.<source>.<signature>. The signature is an HMAC-SHA256 keyed with a secret derived from the store’s crypt key, over the fields and the order’s e-mail. The e-mail is not in the URL. - When the link is opened, the add-on checks:
- the signature and the expiry;
- that the order (or one of its vendor orders) contains the product.
- If the checks pass, it grants the session the right to review that product as a verified buyer for 24 hours, also as a guest when “only buyers can review” is on. Then it redirects to the product page with the form opened.
- The review is saved with
is_buyer = Y, and its source and order go into?:kv_pvr_review_meta. The grant is used once. - Expired links still open the form, with a notice. Forged links give no grant.
Review Request E-mails
Section titled “Review Request E-mails”When the add-on Review Request E-mails (kv_review_request_emails) is installed and active:
- It sends the review request e-mails. This add-on never sends review requests.
- Its no-login review page gets the video fields of this add-on through its template hook
kv_review_request_emails:review_item.controllers/frontend/kv_review_request_emails.pre.phpvalidates the videos before that add-on creates the core review. An invalid video stops the review, so the customer can fix it.product_reviews_create_poststores the videos on the review that add-on creates.- Who may add videos: the request token proves the purchase.
- It gives the reward for request reviews.
Rewards::evaluate()returnsrre(no coupon) for:- reviews written on its page;
- reviews written on the product page by a customer who has an open request (sent, reminded or reviewed) for that product.
- So one review can never earn two coupons. Rewards of this add-on stay for other product-page reviews.
Without Review Request E-mails, the signed links above and the rewards of this add-on work on their own.
Upload security
Section titled “Upload security”- Containers are checked by structure, not by name. MP4 and MOV must have ISO base media boxes with a video track. HEIF and AVIF images are refused. WebM must have an EBML header, DocType
webmand a video track.finfomust agree. - Length comes from
mvhd, for fragmented MP4 frommehdor the sum oftrunsample durations. For WebM it comes from Segment InfoDuration. - Metadata: MP4 and MOV
udta/metaboxes (GPS position, device, owner) are renamed tofreeand zero-filled in place. The media data is untouched. - Posters (captured in the browser, or downloaded from
i.ytimg.com/i.vimeocdn.comonly) are decoded and saved again by GD as a plain JPEG. - Video links keep only the validated YouTube or Vimeo id. Embed URLs are built from it, so the shopper’s input never reaches an iframe.
- Photos:
- JPEG: APP1 (EXIF, XMP), APP13 (IPTC) and comments are removed without re-encoding. When the orientation is not 1, the photo is rotated with GD and saved again.
- PNG: text,
eXIfandtIMEchunks are removed. - WebP: EXIF and XMP chunks are removed and the VP8X flags are updated.
Full page cache (4.21)
Section titled “Full page cache (4.21)”- Product page output (players, gallery, Q&A list, filter buttons) depends only on the product and the URL.
- Visitor-specific parts load separately:
- forms come by AJAX (
kv_photo_video_reviews.ask_form,answer_form, and the core review form); - helpful votes are POST requests, remembered in the browser’s local storage;
- the review form is opened by script (
kv_write=1).
- forms come by AJAX (
- No
?:storage_datawrites from storefront GET requests. The maintenance mark uses StorageData, which writes tovar/kv_storage/while the page cache is active. - Block cache: the core caches the main block of
products.view. The add-on addsupdate_handlers(its media, questions and answers tables),request_handlers(page, sort, review filters,kv_media,kv_qpage,kv_q,kv_write) and acallable_handlersentry with the license and “enabled” state.
CSRF and spam
Section titled “CSRF and spam”- CSRF: the storefront modes
askandanswerare CSRF-validated (schemas/security/csrf_validation.post.php). Their forms load by AJAX for each visitor. - Votes: not validated, because cached pages carry no session token. Each visitor counts once.
- Spam protection:
- a honeypot field;
- 5 questions and 10 answers per IP address per hour;
- CAPTCHA through
schemas/security/antibot_rules.post.php(scenariokv_photo_video_reviews).
License check
Section titled “License check”Tygh\Addons\KvPhotoVideoReviews\License\Client (generated) verifies the license. The gate fn_kv_photo_video_reviews_is_licensed() is called at:
- the product page data (
controllers/frontend/products.post.php) and the review form data (product_reviews.pre.php); - the storefront controller (ask, answer, vote; the signed-link grant);
- video staging and storing, photo metadata removal, the
kv_mediafilter; - rewards, e-mails, the structured data;
- the block cache key (
fn_kv_photo_video_reviews_cache_state).
Not gated: the admin and vendor pages, data management, uninstall, and coupons already issued (they keep working in checkout).
File map
Section titled “File map”| Path | Purpose |
|---|---|
app/addons/kv_photo_video_reviews/addon.xml |
Settings, tables, privileges, e-mail templates |
init.php, func.php |
Hook registration and handlers, integration API, settings info handlers, maintenance, uninstall |
Tygh/Addons/KvPhotoVideoReviews/Config.php, Access.php |
Settings (per storefront in Ultimate), permissions, signed-link grants |
Media.php, VideoFile.php, VideoLink.php, Poster.php, Remote.php, ImageSanitizer.php, TempFiles.php |
Video staging, storage, moderation; container checks; link parsing; posters; oEmbed; photo metadata |
Questions.php, Rewards.php, Links.php, Notifier.php, Storefront.php, Markup.php, Rre.php, StorageData.php |
Q&A, rewards and coupons, review links, e-mails, product page data, structured data, Review Request E-mails cooperation, run marks |
License/Client.php, License/Ed25519.php, controllers/backend/kv_photo_video_reviews_license.php, license/info.tpl |
License check (generated) |
Upgrade/Synchronizer.php |
Self-healing upgrades (generated) |
controllers/backend/kv_photo_video_reviews.php, product_reviews.post.php |
Admin/vendor pages, cron; video cleanup after review deletion |
controllers/frontend/kv_photo_video_reviews.php, products.post.php, product_reviews.pre.php, kv_review_request_emails.pre.php |
Storefront actions, product page data, review form, Review Request E-mails page |
schemas/ |
Menus, permissions (admin, vendor), block cache, CSRF, antibot, settings variants |
var/themes_repository/responsive/templates/addons/kv_photo_video_reviews/ |
Product tabs, hooks, forms, video tile, shared video fields |
js/addons/kv_photo_video_reviews/func.js, css/addons/kv_photo_video_reviews/styles.less |
Storefront script (players, viewer, filters, votes, form checks) and styles |