Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Hides the review form after a review has been submitted
- * Paste this in your active theme's functions.php file
- *
- * @param string $script
- * @return string
- */
- add_filter('site-reviews/enqueue/public/inline-script', function ($script) {
- return $script."
- document.addEventListener('site-reviews/after/submission', function (ev) {
- if (false !== ev.detail.errors) return;
- ev.detail.form.classList.add('glsr-hide-form');
- ev.detail.form.insertAdjacentHTML('afterend', '<p>' + ev.detail.message + '</p>');
- });";
- });
- /**
- * Hides the review form from registered users who have already submitted a review
- * Paste this in your active theme's functions.php file
- *
- * @param string $template
- * @return string
- */
- add_filter('site-reviews/rendered/template/reviews-form', function ($template, $data) {
- $request = glsr()->request($data['args']);
- return glsr('Modules\Validator\ReviewLimitsValidator', compact('request'))->isValid()
- ? $template
- : sprintf('<p>%s</p>', __('Thank you for your review!'));
- }, 10, 2);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement