Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Replace WPRS CTA static rating results with an interactive vote rating stars https://wprichsnippets.com/addons/call-to-action/
<?php //* do not include php tag
add_filter( 'wprs_cta_rating_html', 'wprs_cta_do_rating_html_override_64738746836' );
/**
* Override rating results in CTA box
*
* Replace static rating results with an interactive vote rating stars
*
* @require CTA add-on version 1.9.3 and up
* @return array
*/
function wprs_cta_do_rating_html_override_64738746836( $results ) {
global $post, $wprs_prefix;
if ( ! function_exists('wprs_template')) return;
// Get an array of WPRS template elements
$wprs_template = wprs_template();
$count = get_post_meta( $post->ID, '_wprs_post_user_rating_count', true ) ? get_post_meta( $post->ID, '_wprs_post_user_rating_count', true ) : 0;
$output = '<div>' . $wprs_template['user_rating_stars'] . '</div>';
if ($count == 0 ) {
$output .= '<p>' . __('Submit your rating') . '</p>';
} else {
$output .= '<div>' . $wprs_template['user_rating'] . ' /5 (' . $count . ')' . '</div>';
}
return $output;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.