Reviewer API
Since version 2.4 the Reviewer Plugin offers its own API to integrate the plugin functionalities easily with your theme.
The APIs are made for web developers only or for users that have some knowledge of PHP programming language.
Reviewer APIs are not shortcodes or standard WordPress features. They are PHP methods implemented in the RWP_API class. The class is already included in the WordPress environment if the Reviewer plugin is active. All API are static methods.
get_reviews_box()
Description
Get review box data of specific post. It returns an empty array if the review box does not exist, otherwise an array with related fields. It works with Reviewer Box and Users Box types only.
Parameters
The API requires the following parameters.
Name | Type | Description | Default |
$post_id |
integer | The post id that contains the reviews box. | - |
$reviews_box_id | integer | The review box id. You can find it inside the Reviewer > Review Boxes admin page. | - |
$include_users_scores | boolean | If it is set to true the request will include the users scores values and the count. | false |
$include_criteria_labels | boolean | If it is set to true the review_scores and review_users_score fields will contain the criteria labels | false |
Usage
Call the API inside the source code of your theme or plugin.
<?php $box = RWP_API::get_reviews_box( $post_id, $reviews_box_id, true ); ?>
Output
Note: The review_users_score field will be set if the $include_user_rating parameter is set to true.
Array ( [review_status] => publish [review_type] => PAR+UR [review_title] => Reviews Box 0 [review_title_options] => custom_title [review_template] => rwp_template_56b31f19e53cf [review_scores] => Array ( [3] => 9 [1] => 6.5 [8] => 3 ) [review_custom_overall_score] => 5.7 [review_criteria_source] => reviewer [review_custom_tabs] => Array ( [0] => Array ( [tab_value] => A [tab_link] => http://reviewerplugin.com ) ) [review_pros] => Lorem ipsum dolor sit amet. [review_cons] => Lorem ipsum dolor sit amet. [review_summary] => Lorem ipsum dolor sit amet. [review_use_featured_image] => no [review_image] => http://localhost/reviews-box-img.jpg [review_image_url] => http://reviewerplugin.com [review_custom_links] => Array ( [0] => Array ( [label] => Link [url] => # ) ) [review_sameas_attr] => [review_disable_user_rating] => no [review_id] => 0 [review_overall_score] => 6.625 [review_users_score] => Array ( [scores] => Array ( [3] => 9 [1] => 3.5 [8] => 4.5 ) [count] => 0 ) )
The review_scores and review_users_score fields will have the following output if the $include_criteria_labels parameter is set to true.
Array ( . . . [review_scores] => Array ( [3] => Array ( [label] => Criterion B [score] => 9 ) [1] => Array ( [label] => Criterion A [score] => 6.5 ) [8] => Array ( [label] => Criterion D [score] => 3 ) ) . . . [review_users_score] => Array ( [scores] => Array ( [3] => Array ( [label] => Criterion B [score] => 9 ) [1] => Array ( [label] => Criterion A [score] => 3.5 ) [8] => Array ( [label] => Criterion D [score] => 4.5 ) ) [count] => 0 ) )
get_post_reviews_boxes()
Description
Get review boxes data of specific post. It returns an empty array if the post has not review boxes, otherwise an array with related review boxes. It works with Reviewer Box and Users Box types only.
Parameters
The API requires the following parameters.
Name | Type | Description | Default |
$post_id | integer | The post id that contains the reviews boxes. | - |
$include_users_scores | boolean | If it is set to true the request will include the user scores and the related count. | false |
Usage
Call the API inside the source code of your theme or plugin.
<?php $box = RWP_API::get_post_reviews_boxes( $post_id, true ); ?>
Output
Note: The review_users_score field will be set if the $include_user_rating parameter is set to true. Check the get_reviews_box output for the details about reviews box fields.
Array ( [0] => Array ( [review_id] => 0 [review_title] => Reviews Box 0 . . . ), [1] => Array ( [review_id] => 1 [review_title] => Reviews Box 1 . . . ), )
get_reviews_box_users_rating()
Description
Get the users rating of specific reviews box. It returns an array with the average of criteria and the count. It works with Reviewer Box, Users Box and Automatic Box types.
Parameters
The API requires the following parameters.
Name | Type | Description | Default |
$post_id | integer | The post id that contains the reviews box. | - |
$reviews_box_id | integer | The reviews box id. Find it inside the Reviewer > Review Boxes admin page. Use the wildcard -1 if you set up Auto Box type. | - |
$template_id | string | The related template id of reviews box. Required if you set up Automatic Box type or $include_criteria_labels parameter is set to true. | - |
$include_criteria_labels | boolean | If it is set to true the scores field will contain the criteria labels. | false |
Usage
Call the API inside the source code of your theme or plugin.
<?php $users_rating = RWP_API::get_reviews_box_users_rating( $post_id, $reviews_box_id ); ?>
Output
Array ( [scores] => Array ( [3] => 6.5 [1] => 7 ) [count] => 12 )
Note: if the $include_criteria_labels parameter is set to true the output is:
Array ( [scores] => Array ( [3] => Array ( [label] => Criterion B [score] => 6.5 ) [1] => Array ( [label] => Criterion A [score] => 7 ) ) [count] => 12 )
get_reviews_box_users_reviews()
Description
Get the user overall rating and single user reviews of specific review box. It returns an array with the average of criteria, the count and all user reviews. It works with Reviewer Box, Users Box and Automatic Box types.
Parameters
The API requires the following parameters.
Name | Type | Description | Default |
$post_id | integer | The post id that contains the reviews box. | - |
$reviews_box_id | integer | The reviews box id. Find it inside the Reviewer > Review Boxes admin page. Use the wildcard -1 if you set up Automatic Box type. | - |
$template_id | string | The related template id of review box | - |
Usage
Call the API inside the source code of your theme or plugin.
<?php $users_reviews = RWP_API::get_reviews_box_users_reviews( $post_id, $reviews_box_id, $template_id ); ?>
Output
Array ( [overall] => 6 [count] => 12 [criteria] => Array ( [3] => 6.5 [1] => 7 ) [reviews] => Array ( [0] => Array ( [rating_id] => rwp_rating_56b5c55ebe471 [rating_post_id] => 33 [rating_review_id] => 0 [rating_score] => Array ( [3] => 4.5 [1] => 8.0 ) [rating_user_id] => 0 [rating_user_name] => John [rating_user_email] => dem@dkc.co [rating_title] => Lorem ipsum [rating_comment] => Lorem ipsum [rating_date] => 1454756718 [rating_status] => published [rating_template] => rwp_template_56b31f19e53cf [rating_socials_url] => Array ( [facebook] => http://. . . [twitter] => http://. . . [google] => http://. . . [email] => mailto:? . . . [link] => http://. . . ) [rating_user_avatar] => http://. . . [rating_overall] => 6 [rating_formatted_date] => 23 hours ago [rating_helpful] => 0 [rating_unhelpful] => 0 ) [1] => Array ( [rating_id] => rwp_rating_56b5c55eer474 . . . ) ) )
get_users_reviews()
Description
Get all user reviews of Reviewer plugin filtered by the defined templates ids. It returns an array of user reviews. It works with Reviewer Box and Users Box and Automatic Box types.
Parameters
The API requires the following parameters.
Name | Type | Description | Default |
$templates | array | An array will templates identifiers | - |
$sort | string | Define the sorting mode. Available values: latest, top_score | latest |
$limit | integer | Define how many users reviews you want to return. | - |
Usage
<?php $reviews = RWP_API::get_reviews_box_users_reviews( array( template_1, template_3 ), $sort, $limit ); ?>
Output
Array ( [0] => Array ( [rating_id] => rwp_rating_56b5c55ebe471 [rating_post_id] => 33 [rating_review_id] => 0 [rating_score] => Array ( [3] => 6.5 [1] => 7.0 ) [rating_user_id] => 0 [rating_user_name] => John [rating_user_email] => dem@dkc.co [rating_title] => Lorem ipsum [rating_comment] => Ciao come va [rating_date] => 1454756718 [rating_status] => published [rating_template] => rwp_template_56b31f19e53cf [rating_meta_id] => 66 [rating_post_title] => Test Post [rating_user_avatar] => http://. . . [rating_overall] => 6 [rating_formatted_date] => 1 day ago [rating_url] => http://domain.com/?rwpurid=rwp_rating_56b5c55ebe471 [rating_template_maximum_score] => 10 [rating_template_minimum_score] => 0 [rating_template_low_pct] => 30 [rating_template_high_pct] => 69 [rating_template_low_score_color] => #56b258 [rating_template_high_score_color] => #56b258 [rating_template_medium_score_color] => #56b258 [rating_template_rate_image] => http:// . . . ) [1] => Array ( [rating_id] => rwp_rating_56b5c55ebe471 . . . ) )