{"id":78,"date":"2016-07-08T15:30:59","date_gmt":"2016-07-08T20:30:59","guid":{"rendered":"https:\/\/easydigitaldownloads.com\/development\/?p=78"},"modified":"2021-12-15T15:31:18","modified_gmt":"2021-12-15T21:31:18","slug":"reviews-version-2-0-important-changes-and-backwards-compatibility","status":"publish","type":"post","link":"https:\/\/easydigitaldownloads.com\/development\/2016\/07\/08\/reviews-version-2-0-important-changes-and-backwards-compatibility\/","title":{"rendered":"Reviews version 2.0 &#8211; important changes and backwards compatibility"},"content":{"rendered":"<p>Reviews version 2.0 is close to being ready. It&#8217;s a major update to the way Reviews will function and we just want to go over the changes that will be coming to this release.<\/p>\n<h3>Database\u00a0upgrades<\/h3>\n<p>If you have upgraded from a previous version of Reviews, you will see a notice in your WordPress Dashboard that the database needs upgrading.\u00a0This upgrade goes through all the reviews stored in the database and changes the comment type\u00a0and adds the metadata\u00a0required for the new version to function\u00a0correctly.<\/p>\n<p>The changes to the database are:<\/p>\n<ul>\n<li>Comment type is changed to <code>edd_review<\/code><\/li>\n<li>Add two new comment meta keys: <code>edd_review_approved<\/code> and\u00a0<code>edd_review_reply<\/code>.\u00a0<code>edd_review_approved<\/code> just copies the value of the <code>comment_approved<\/code>\u00a0field from the wp_comments\u00a0table and <code>edd_review_reply<\/code> is only added for\u00a0replies which were made to reviews. The plugin makes use of\u00a0<code>edd_review_approved<\/code>\u00a0for the comment status instead of the WordPress <code>comment_approved<\/code> field due to the way WordPress counts comments; it would cause the comment unread count to be incorrect.<\/li>\n<\/ul>\n<p>When first updating to Reviews 2.0, the following admin notice will be displayed:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-95\" src=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-20.58.55.png\" alt=\"Screen Shot 2016-07-08 at 20.58.55\" width=\"819\" height=\"54\" srcset=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-20.58.55.png 819w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-20.58.55-300x20.png 300w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-20.58.55-768x51.png 768w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-20.58.55-800x54.png 800w\" sizes=\"auto, (max-width: 819px) 100vw, 819px\" \/><\/p>\n<p>Following the link will begin the database upgrade and the\u00a0upgrade routines described above wit<\/p>\n<h3>Moving away from the WordPress Comment Form<\/h3>\n<p>There are a huge number of improvements in 2.0 in the way reviews are handled. Up until now, we have been extending\u00a0the WordPress <code>comment_form<\/code> by enabling support for comments on all downloads. In\u00a02.0, we hook on to the <code>the_content<\/code>\u00a0filter and display a custom form to submit reviews along with a custom Walker to display all the reviews.<\/p>\n<p>The form displayed in Reviews 1.3.10 looks like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-96\" src=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.04.09.png\" alt=\"Screen Shot 2016-07-08 at 21.04.09\" width=\"722\" height=\"466\" srcset=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.04.09.png 722w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.04.09-300x194.png 300w\" sizes=\"auto, (max-width: 722px) 100vw, 722px\" \/><\/p>\n<p>The new form coming to Reviews 2.0, looks like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-97\" src=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.04.26.png\" alt=\"Screen Shot 2016-07-08 at 21.04.26\" width=\"719\" height=\"990\" srcset=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.04.26.png 719w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.04.26-218x300.png 218w\" sizes=\"auto, (max-width: 719px) 100vw, 719px\" \/><\/p>\n<p>As you can see, the standard WordPress comment form is displayed beneath\u00a0the\u00a0review submission form. \u00a0It should be noted that the comment form is only displayed if\u00a0comments have been enabled on the Downloads post type.<\/p>\n<p>There is very minimal\u00a0styling applied to the form, in fact, only one CSS rule is applied which is:<br \/>\n<code><br \/>\n.edd-reviews-form label {<br \/>\ndisplay: inline-block;<br \/>\nwidth: 150px;<br \/>\n}<br \/>\n<\/code><\/p>\n<p>This rule just ensures that the labels and inputs line up. \u00a0Besides that,\u00a0any\u00a0global styling applied to input fields will be inherited from your theme.<\/p>\n<p>In terms of the markup changes for the reviews form, this is an example of the markup\u00a0for the review form:<\/p>\n<p>https:\/\/gist.github.com\/sunnyratilal\/e7ccfbe2e83a4e322e2bf745a58d5ab2<\/p>\n<p>This change\u00a0not only makes the submission form more reliable, it also means that download products can now have reviews and comments enabled at the same time.<\/p>\n<p><strong>Please note: the markup has changed significantly from Reviews 1.x so\u00a0themes\u00a0that\u00a0had specific styling for Reviews should be tested<\/strong><\/p>\n<p>All reviews now have a comment type of\u00a0edd_review\u00a0and are still stored in the wp_comments table. \u00a0They are filtered out from the\u00a0WP_Comment_Query and other queries. If\u00a0you\u00a0currently query for\u00a0reviews using get_comments, you need to remove the actions and filters which stop reviews and replies to reviews being queried.\u00a0An example of querying reviews can be done\u00a0as follows:<\/p>\n<p>https:\/\/gist.github.com\/sunnyratilal\/7d814cd99d0ea006355d01afea1a4d8f<\/p>\n<p>If you are doing custom\u00a0querying of\u00a0reviews, you must ensure to add the\u00a0actions and filters\u00a0after the get_comments call to\u00a0ensure reviews are not tied in with\u00a0comments.<\/p>\n<p>Replies made to reviews have also been\u00a0adjusted, they also follow the comment type of <code>edd_review<\/code> but have a meta key\u00a0attached to them entitled <code>edd_review_reply<\/code> and it has a value of 1.<\/p>\n<p>All reviews are displayed using a new Walker created:\u00a0Walker_EDD_Review. The reviews are still displayed by making a call to\u00a0wp_list_comments, the only thing\u00a0different is the Walker which traverses over the reviews.<\/p>\n<p>In the WordPress Dashboard, all reviews are now displayed on a new page which is located at Downloads &gt; Reviews.\u00a0No\u00a0reviews will be\u00a0displayed on the Comments admin page. The output of the review is\u00a0controlled by the\u00a0EDD_Reviews_List_Table class.<\/p>\n<h3>Improved API Output Data<\/h3>\n<p>Changes have been made to the\u00a0data that is output\u00a0when querying the reviews endpoint on the EDD API.<\/p>\n<p>New keys that have been added:<\/p>\n<ul>\n<li><code>parent<\/code>: displays the ID of the parent review (only valid for replies)<\/li>\n<li><code>type<\/code>: displays the type of the review: whether it&#8217;s a review or a reply<\/li>\n<\/ul>\n<p>The output has changed so that null is displayed if a review doesn&#8217;t have a title or a rating rather than just displaying a blank\u00a0string. The same applies for votes: if no votes have been cast for a review, the votes key is\u00a0simply set to null\u00a0with no &#8216;yes&#8217; and &#8216;no&#8217; sub-keys.<\/p>\n<p>Here is an example of the data output by the API in Reviews 2.0:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-98\" src=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.07.45.png\" alt=\"Screen Shot 2016-07-08 at 21.07.45\" width=\"319\" height=\"662\" srcset=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.07.45.png 319w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.07.45-145x300.png 145w\" sizes=\"auto, (max-width: 319px) 100vw, 319px\" \/><\/p>\n<p>The first JSON\u00a0element is of a reply to a\u00a0review as can be distinguished by it having a\u00a0value of <code>reply<\/code> for the <code>type<\/code> key. You can also see that the <code>votes<\/code> key has a value of <code>null<\/code> as replies\u00a0do not have the voting feature. \u00a0The second JSON element has a <code>type<\/code> of <code>review<\/code> as well as a <code>title<\/code>\u00a0key which has a value as well as having sub-keys for the <code>votes<\/code> key.<\/p>\n<h3>Integration with Frontend Submissions<\/h3>\n<p>Reviews now work alongside Frontend Submissions\u00a0by allowing\u00a0a much requested feature:\u00a0Vendor Feedback. \u00a0All the code to integrates FES is stored under <code>includes\/class-edd-reviews-fes-integration.php<\/code>.<\/p>\n<p>A link is added to the Purchase History table to allow vendor feedback to be supplied. The labels\u00a0can be changed using the templates and the Reviews settings under Downloads &gt; Settings &gt; Extensions\u00a0&gt; Reviews.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-102\" src=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.15.32.png\" alt=\"Screen Shot 2016-07-08 at 21.15.32\" width=\"707\" height=\"234\" srcset=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.15.32.png 707w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.15.32-300x99.png 300w\" sizes=\"auto, (max-width: 707px) 100vw, 707px\" \/><\/p>\n<p>Upon installing Reviews,\u00a0a new page is created called Vendor Feedback, this page has a shortcode which\u00a0renders the feedback submission form. \u00a0The form looks like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-103\" src=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.16.45.png\" alt=\"Screen Shot 2016-07-08 at 21.16.45\" width=\"714\" height=\"832\" srcset=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.16.45.png 714w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.16.45-257x300.png 257w\" sizes=\"auto, (max-width: 714px) 100vw, 714px\" \/><\/p>\n<p>All Vendor Feedback can be viewed from the FES\u00a0Vendor Dashboard:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-104\" src=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.23.36.png\" alt=\"Screen Shot 2016-07-08 at 21.23.36\" width=\"713\" height=\"707\" srcset=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.23.36.png 713w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.23.36-150x150.png 150w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.23.36-300x297.png 300w\" sizes=\"auto, (max-width: 713px) 100vw, 713px\" \/><\/p>\n<p>Administrators can view all\u00a0Vendor Feedback by going to\u00a0EDD FES &gt; Vendor Feedback within the\u00a0WordPress Admin interface. \u00a0It&#8217;s all displayed in a list table, as such:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-101\" src=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.14.58.png\" alt=\"Screen Shot 2016-07-08 at 21.14.58\" width=\"972\" height=\"285\" srcset=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.14.58.png 972w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.14.58-300x88.png 300w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.14.58-768x225.png 768w\" sizes=\"auto, (max-width: 972px) 100vw, 972px\" \/><\/p>\n<p>Vendor Feedback is stored with an <code>edd_vendor_feedback<\/code> comment type in the comments table and, similar to reviews, is hidden from the WordPress Comments Query. \u00a0When querying vendor feedback, use a similar approach to above\u00a0and just change the callback to <code>array( edd_reviews()-&gt;fes, 'hide_feedback' )<\/code>.<\/p>\n<h3>New Templating<\/h3>\n<p>Similar to Easy Digital Downloads, we have introduced a\u00a0template system to allow easy modifications to certain elements of the plugins. These\u00a0files are located in the templates folder of\u00a0the plugin directory.<\/p>\n<p>Template files bundled with the plugin are:<\/p>\n<ul>\n<li><code>reviews-fes-vendor-feedback.php<\/code>:\u00a0This template\u00a0is used to render\u00a0all the\u00a0Vendor Feedback submitted. \u00a0The output generated by this template is on the Vendor Feedback page of the FES\u00a0Vendor\u00a0Dashboard.<\/li>\n<li><code>reviews-reply.php<\/code>: This template\u00a0builds the reply form\u00a0which is\u00a0displayed when replying to a review<\/li>\n<li><code>reviews.php<\/code>: This template is\u00a0used for displaying the reviews and the review submission form<\/li>\n<li><code>shortcode-vendor-feedback.php<\/code>:\u00a0This template\u00a0handles the output of the <code>[edd_vendor_feedback]<\/code> shortcode and displays the form used to submit vendor feedback<\/li>\n<\/ul>\n<p>All the templates bundled with the plugin can be edited by creating a file of the same name under the edd_templates folder of your active theme. \u00a0The\u00a0file inside the <code>edd_templates<\/code> folder will override the file bundled in the plugin.<\/p>\n<h3>Updated Widgets and Shortcodes<\/h3>\n<p>The markup for the widgets and shortcodes has been altered\u00a0to follow the same markup as a review displayed under\u00a0downloads.<\/p>\n<p><strong>Featured Review Widget<\/strong><\/p>\n<p>https:\/\/gist.github.com\/sunnyratilal\/0f1067984f860c8906a712967edf89c1<\/p>\n<p>The updated widget will be displayed like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-99\" src=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.12.07.png\" alt=\"Screen Shot 2016-07-08 at 21.12.07\" width=\"323\" height=\"136\" srcset=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.12.07.png 323w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.12.07-300x126.png 300w\" sizes=\"auto, (max-width: 323px) 100vw, 323px\" \/><\/p>\n<p><strong>Per Product Reviews Widget<\/strong><\/p>\n<p>https:\/\/gist.github.com\/sunnyratilal\/26edcf6f5edc9a9de95ede937b6354e2<\/p>\n<p>The updated widget will be displayed like this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-100\" src=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.13.06.png\" alt=\"Screen Shot 2016-07-08 at 21.13.06\" width=\"323\" height=\"103\" srcset=\"https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.13.06.png 323w, https:\/\/easydigitaldownloads.com\/development\/files\/2016\/06\/Screen-Shot-2016-07-08-at-21.13.06-300x96.png 300w\" sizes=\"auto, (max-width: 323px) 100vw, 323px\" \/><\/p>\n<p><strong>Recent Reviews<\/strong><\/p>\n<p>https:\/\/gist.github.com\/sunnyratilal\/817912f590a395c278216369b8af23b7<\/p>\n<p>The updated\u00a0widget will be displayed exactly like the Per Product Review widget.<\/p>\n<p><strong>Review Shortcode<\/strong><\/p>\n<p><strong>Note: previous custom\u00a0styling for the review shortcode has been removed and has been replaced with a very simple CSS\u00a0rule to add a border\u00a0around the review with some padding and a margin.<\/strong><\/p>\n<p>https:\/\/gist.github.com\/sunnyratilal\/499ce552b314102b0fe3385a6dd74959<\/p>\n<p>As you can see from the above snippets, the markup is now consistent across all widgets and shortcodes but this all means that custom styling previous\u00a0applied to the widgets and shortcode will break and again, as aforementioned, themes will need to be tested.<\/p>\n<h3>Other Notable Fixes\/Changes<\/h3>\n<ul>\n<li>TinyMCE widget to embed reviews into posts has been rewritten\u00a0and redesigned to work better with the WordPress Editor<\/li>\n<li>HTML 5 microdata\u00a0has been fixed and validated<\/li>\n<li>Markup to display the star rating for each rating has been changed from using images to using\u00a0WordPress Dashicons.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Easy Digital Downloads Reviews version 2.0 is getting close to being ready. There are numerous significant improvements in 2.0 which change the way reviews will be handled and displayed. We encourage all theme and plugin developers to familiarize themselves with the important changes coming.<\/p>\n","protected":false},"author":650,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[3],"tags":[12],"class_list":["post-78","post","type-post","status-publish","format-standard","hentry","category-extensions","tag-reviews"],"_links":{"self":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/78","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/users\/650"}],"replies":[{"embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/comments?post=78"}],"version-history":[{"count":2,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/78\/revisions"}],"predecessor-version":[{"id":1116,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/posts\/78\/revisions\/1116"}],"wp:attachment":[{"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/media?parent=78"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/categories?post=78"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/easydigitaldownloads.com\/development\/wp-json\/wp\/v2\/tags?post=78"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}