Filter Hooks
We have filter hooks to customize the inner workings of our plugin. Please see below for a list, examples and ideal usage cases.
These filter hooks can be written in either your theme's functions.php files, any PHP file in your plugin file, or an external PHP file that is included by either the theme or a plugin.
Please remember that the sample codes here are for proof of concept and modifications in your part will still be required.
Five-Star Rating and Review Widget: fsrrw_review_form
Dynamically modify the review form to change the output aspect and more .
Usage application: Alter the contents of the review form, search and replace something in the output, or append additional HTML to the form.
Sample usage: Add an extra div to the form:
add_filter( 'fsrrw_review_form', 'append_content' ); function append_content( $ret ) { // Enclose the element in another div so we can use a Javascript library for it. return '<div class="enclosed-area">' . $ret . '</div>'; }
Five-Star Rating and Review Widget: fsrrw_author_rating
Dynamically modify the author rating display that appears on top of every post or archive.
Usage application: Alter the contents of the author rating code, search and replace something in the output, or append additional HTML to the output.
Sample usage: Add conditions to display the Author Rating. In this case, it will become invisible to users that are not logged in:
add_filter( 'fsrrw_author_rating', 'display_control' ); function display_control( $ret ) { // Do not display this if the user is not logged in. return is_user_logged_in() ? $ret : ''; }
Five-Star Rating and Review Widget: fsrrw_rating
Dynamically modify the rating display that appears on top of every post or archive.
Usage application: Alter the contents of the rating code, search and replace something in the output, or append additional HTML to the output.
Sample usage: Run through the $ret variable and change the URL header found into something else:
add_filter( 'fsrrw_rating', 'change_header' ); function change_header( $ret ) { // Change header. return str_replace( 'http://', 'http://i0.wp.com/', $ret ); }
Five-Star Rating and Review Widget: fsrrw_review_list
Dynamically modify the review list that appears below each posts, when 'show reviews' link is clicked.
Usage application: Alter the contents of the ratings list, search and replace something in the ratings list, or append additional HTML to the output.
Sample usage: Add anchors to end of the parsed content each time the review list is called:
add_filter( 'fsrrw_review_list', 'extra_contents' ); function extra_contents( $ret ) { // Add this code for each time there's more loaded. if ( $remaining_reviews ) >= 1 { $ret .= '<a href="#segment-' . $remaining_reviews . '"></a>' } return $ret; }
Five-Star Rating and Review Widget: fsrrw_review_widget
Dynamically modify the contents of the ratings list widget.
Usage application: Alter the output contents of the widget, search and replace something in the widget, or append additional HTML to the widget.
Sample usage: Override the contents outright:
add_filter( 'fsrrw_review_widget', 'total_change' ); function total_change( $ret ) { // Replace this if this kind of message shows up. if ( $ret == 'Nothing to see here, move along.' ) { $ret = 'Nothing but crickets here. Rate something please!'; } return $ret; }