Skip to content

Instantly share code, notes, and snippets.

@wprs
Created October 16, 2017 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wprs/89deca4c1e33dc6b7da6aad777442982 to your computer and use it in GitHub Desktop.
Save wprs/89deca4c1e33dc6b7da6aad777442982 to your computer and use it in GitHub Desktop.
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