<!– wp:paragraph –>
<p>Did you first try running the plugin migration on the Site Reviews Tools page? See also the Upgrade Guide on the Help page.</p>
<!– /wp:paragraph –>
Yes, I ran the migration, optimized everything I could from the tools section but nothing worked so far. I’m not sure what to do next, but I will try something else.
My website is using several hooks provided by the plugin and it seems that they cause the problem because the shortcode works if I comment it all out but then I lose all my custom modifs.
In the v3, I added some custom field in the review form and I got to something working with these filters (2 of them were deprecated and I changed the filters to their new name)
Can you spot something wrong in the below code ? (was working in v3)
* @return array */ add_filter( 'site-reviews/review-form/order', function( $order ) { // The $order array contains the field keys returned below. // Simply add any custom field keys that you have added and change them to the desired order. return [ 'rating', 'title', 'website', // this is a custom field key 'content', 'name', 'email', 'terms', ]; });
/** * Modifies the submission form field rules * Paste this in your active theme's functions.php file. * @return array */ add_filter( 'site-reviews/validation/rules', function( $rules ) { $rules['website'] = 'required'; return $rules; });
/** * Displays custom fields in the Review's "Details" metabox * Paste this in your active theme's functions.php file. * @return array */ add_filter( 'site-reviews/metabox/details', function( $metabox, $review ) { foreach( $review->custom as $key => $value ) { $metabox[$key] = $value; } return $metabox; }, 10, 2 );
/** * Renders the custom review fields * Paste this in your active theme's functions.php file. * In order to display the rendered custom fields, you will need to use a custom "review.php" template * as shown in the plugin FAQ ("How do I change the order of the review fields?") * and you will need to add your custom keys to it, for example: {{ name_of_your_custom_key }} * @return array */ add_filter('site-reviews/review/build/after', function( $renderedFields, $review ) { foreach ($review->custom as $key => $value) { if (substr($value, 0, 1) === '@' && filter_var(substr($value, 1), FILTER_VALIDATE_URL)) { $rel = ""; $url = substr($value, 1); } else { $rel = ' rel="nofollow"'; $url = $value; } if ($value) { $renderedFields[$key] = '<div class="glsr-custom-' . $key . '"><a target="_blank" href="' . $url . '" title="' . $url . '"' . $rel . '>' . get_host($url) . '</a></div>'; } else { $renderedFields[$key] = ''; } return $renderedFields; } return; }, 10, 2);
I am also using a custom site-reviews/review.php template like so:
Keep in mind that adding custom fields to the form is not supported here, so you may need to also refer to the original snippet: https://pastebin.com/4fvKErcp