Created
October 16, 2017 15:20
-
-
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/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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