This article presents details documentation for CBX 5 Star Rating & Review for WordPress. If you are looking for Comment and MyCred Addons and their details for CBX 5 Star Rating & Review for WordPress please check the below two articles.
- CBX 5 Star Rating & Review for WordPress Pro Addon
- Comment for CBX 5 Star Rating & Review for WordPress
- myCred for CBX 5 Star Rating & Review for WordPress
This documentation is for the Core plugin and Pro addon. Comment and myCred addon documentation is in their product details page.
Download and Installations:
Download & Install Core Plugin:
To download the free core plugin of CBX 5 Star Rating & Review for WordPress please go to wordpress
plugin dir
Plugin from wordpress plugin directory can be installed in different ways, wordpress codex has very good tutorial about this, so we are skipping this part. Or wpbeginner has a step by step guide.
Install any Pro Addons:
Please check the addon section from the product page
After purchase any pro or free addon you will get zip package.
This zip package you need to install manually, wordpress code has very good tutorial about this.
Activate and Configuration:
After installing the plugin, please activate from plugin listing page or installation screen. If the plugin is activate there will be a menu in left panel admin menu called “CBX SC Reviews”
Create Pages:
Next step is to create 3 pages for 1. Frontend User dashboard, 2. Single review details/permalink page, 3. Frontend Review Edit page. Here page 1 and 3 is related with frontend user dashboard and 2 is needed if we want to create single review details page, that means we want to create permalink for every single review. So, go to pages from admin panel and start creating pages and insert specific shortcodes.
1. Frontend User dashboard – Shortcode [cbxscratingreview_userdashboard]
2. Single review details/permalink page – Shortcode [cbxscratingreview_singlereview]
3. Frontend Review Edit page – Shortcode [cbxscratingreview_editreview]
Settings: Pages & Tools
After creating the above 3 pages the first thing need to do is go to setting page of the plugin and check & set
Pages & Tool. See
screenshot. In Pages & Tool tab select the 3 pages created as specific for frontend dashboard, review details and review edit and save setting once. Now all setting tabs step by step once to understand the settings.
Enable Auto Integration
Auto integration helps for quick start. Go to Setting->General Tab and choose “Post Type Support” and save once. Then in same tab check “Enable Auto Integration” , set “Yes” and choose “Auto Integration for Post Type”. Please note that unless any post types is set in “Post Type Support” field “Auto Integration for Post Type” will not show any post types. The rest 3 fields “Show on Single”, “Show on Home/Frontpage”, “Show on Archives” are related with auto integration. Enable/disable those selection as need. Check
screenshot here
Shortcodes & Relevant Functions
1. Rating Form Shortcode [cbxscratingreview_reviewform]. Shortcode details are below:
param name | default value | possible values |
---|---|---|
post_id | current post id | any post id |
This functionality can be achieved using custom function call also anywhere in theme.
<code> global $post; $post_id = intval($post->ID); if ( function_exists( 'cbxscratingreview_reviewformRender' ) ) { echo cbxscratingreview_reviewformRender( $post_id ); } </code>
2. Average Rating Shortcode [cbxscratingreview_postavgrating]. Shortcode details are below:
param name | default value | possible values |
---|---|---|
post_id | current post id | any post id |
show_score | 1 | 1 or 0 – Show/hide rating score |
show_chart | 0 | 0 or 1 – Hide/Show rating chart |
show_star | 1 | 1 or 0 – Show/hide rating star |
This functionality can be achieved using custom function call also anywhere in theme.
<code> global $post; $post_id = intval($post->ID); if ( function_exists( 'cbxscratingreview_postAvgRatingRender' ) ) { echo cbxscratingreview_postAvgRatingRender( $post_id ); } </code>
3. Post Reviews Listing [cbxscratingreview_postreviews]. Shortcode details are below:
param name | default value | possible values |
---|---|---|
post_id | current post id | any post id |
orderby | id , Here id is actually review id | id, post_id |
order | DESC | DESC, ASC |
score | 1,2,3,4,5 | |
perpage | 10 or as set ins global setting | any numeric value |
show_filter | 1 or as set ins global setting | 1 or 0 |
show_more | 1 | 1 or 0 |
This functionality can be achieved using custom function call also anywhere in theme.
<code> //variable names can be useful to understand what is what and also check shortcode params to understand $output = ''; if ( $show_filter ) { if ( function_exists( 'cbxscratingreview_postReviewsFilterRender' ) ) { $output .= cbxscratingreview_postReviewsFilterRender( $post_id, $perpage, 1, $score, $orderby, $order ); } } if ( function_exists( 'cbxscratingreview_postReviewsRender' ) ) { $output .= cbxscratingreview_postReviewsRender( $post_id, $perpage, 1, $score, $orderby, $order, $show_more ); } echo $output; </code>
4. Single Review [cbxscratingreview_singlereview]. Shortcode details are below:
This functionality can be achieved using custom function call also anywhere in theme.
param name | default value | possible values |
---|---|---|
review_id | 0 | any review id |
<code> $single_review_html = ''; $review_id = 0; //put any review id here if ( function_exists( 'cbxscratingreview_singleReviewRender' ) ) { //we can keep a way to get the review id from url $review_id = isset( $_GET['review_id'] ) ? intval( $_GET['review_id'] ) : $review_id; if ( $review_id > 0 ) { $post_review = cbxscratingreview_singleReview( $review_id ); $post_id = intval($post_review['post_id']); $post_title = get_the_title($post_id); $post_link = get_permalink($post_id); $single_review_html .= '<p>'.esc_html__('Reviewed', 'cbxscratingreview').' : <a target="_blank" href="'.esc_url($post_link).'" rel="noopener noreferrer">'.esc_attr($post_title).'</a></p>'; $single_review_html .= '<ul class="cbxscratingreview_review_list_items">'; $single_review_html .= '<li id="cbxscratingreview_review_list_item_' . intval( $review_id ) . '" class="' . apply_filters( 'cbxscratingreview_review_list_item_class', 'cbxscratingreview_review_list_item' ) . '">'; $single_review_html .= cbxscratingreview_singleReviewRender( $post_review ); $single_review_html .= '</li>'; $single_review_html .= '</ul>'; } else { $single_review_html .= '<div class="alert alert-danger" role="alert">' . esc_html__( 'Sorry, review not found or unpublished', 'cbxscratingreview' ) . '</div>'; } } echo $single_review_html; </code>
5. Single Review Edit [cbxscratingreview_editreview]. Shortcode details are below:
param name | default value | possible values |
---|---|---|
review_id | 0 | any review id |
This functionality can be achieved using custom function call also anywhere in theme.
<code> $single_review_edit_html = ''; $review_id = 0; //put review id here if ( function_exists( 'cbxscratingreview_singleReviewEditRender' ) ) { if ( $review_id == 0 ) { //now take from url $review_id = isset( $_GET['review_id'] ) ? intval( $_GET['review_id'] ) : 0; } if ( $review_id > 0 ) { $single_review_edit_html = cbxscratingreview_singleReviewEditRender( $review_id ); } else { $single_review_edit_html .= '<div class="alert alert-danger" role="alert">' . esc_html__( 'Sorry, review not found', 'cbxscratingreview' ) . '</div>'; } } echo $single_review_edit_html; </code>
6. Most Rated Posts [cbxscratingreviewmrposts]. Shortcode details are below:
param name | default value | possible values |
---|---|---|
type | post | any post type like post, page, product etc |
orderby | avg_rating | avg_rating, total_count, post_id |
order | DESC | DESC, ASC |
scope | shortcode | any string or single word, better skip this param to use default |
limit | 10 | any numeric value |
This functionality can be achieved using custom function call also anywhere in theme.
<code> //variable names can be useful to understand what is what and also check shortcode params to understand cbxscratingreview_AddJsCss(); $data_posts = cbxscratingreview_most_rated_posts( $limit, $orderby, $order, $type ); //variable name $data_posts is important for template files // Display the most rated post link ob_start(); include (cbxscratingreview_locate_template('widgets/most_rated_posts.php')); $content = ob_get_contents(); ob_end_clean(); echo $content; </code>
7. Latest Ratings [cbxscratingreviewlratings]. Shortcode details are below:
param name | default value | possible values |
---|---|---|
orderby | id , here id is review id | id, score, post_id |
order | DESC | DESC, ASC |
scope | shortcode | any string or single word, better skip this param to use default |
limit | 10 | any numeric value |
This functionality can be achieved using custom function call also anywhere in theme.
<code> //variable names can be useful to understand what is what and also check shortcode params to understand cbxscratingreview_AddJsCss(); $data_posts = cbxscratingreview_lastest_ratings( $limit, $orderby, $order, $type ); //variable name $data_posts is important for template files // Display the most rated post link ob_start(); include (cbxscratingreview_locate_template('widgets/lastest_ratings.php')); $content = ob_get_contents(); ob_end_clean(); echo $content; </code>
8. Frontend user dashboard [cbxscratingreview_userdashboard]. Shortcode details are below:
param name | default value | possible values |
---|---|---|
orderby | id , here id is review id | id, post_id, post_type, score, status |
order | DESC | DESC, ASC |
perpage | 20 | any numeric value |
Widgets
1. Most rated post widget which does same as shortcode [cbxscratingreviewmrposts]
2. Latest ratings widget which works same as shortcode [cbxscratingreviewlratings]
3. WooCommerce rating filter widget as alternative(Pro addon)
Custom Functions
Most static method and functions are included in
1. cbxscratingreview\includes\class-cbxscratingreview-functions.php – easy to call functions(please don’t be confused for having the word ‘class’ in file name, this file includes all functions)
2. cbxscratingreview\includes\class-cbxscratingreview-helper.php – This helper class is used almost everywhere and for technical reason if you need any custom function please check this class. We will add more in this doc more specific.
Google rich snippet
This plugins adds the proper syntax for adding google rich snippet for aggregated reviews and regular review listing but the theme must have the rich snippet support.
Example
https://gist.github.com/manchumahara/62e59f2f3827e61fcda123c4f249d517
Template Override
Template override is like woocommerce. Most frontend views supports template files. By default plugin’s template/theme files loaded from core plugin’s templates folder wp-content/plugins/cbxscratingreview/templates
To override any file from theme please create a folder named cbxscratingreview
in your theme or child theme folder. then copy any file from core plugin’s templates folder to that folder in theme/child theme, please keep the same name and same folder structure. All addon follows same template system and from addon plugin templates folder you can copy any file and put int he theme/child theme’s cbxscratingreview
folder
Rating Star Icon Override
In free core version rating star icons can not be override but if you have pro addon installed this is possible. Pro addon provides some ready icons which can be selected from the plugin setting. If not suitable for your need, you can choose icon source from theme in the plugin setting. If star type is selected from theme then it will try to load from theme root/cbxscratingreview/stars, child theme location will get high priority. Custom star needs to have three images named star-half.png, star-off.png and star-on.png
Last modified: May 30, 2020