Last active
August 29, 2015 14:15
-
-
Save danielpowney/8512833ae7c444678c55 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
if ( class_exists( 'MRP_Multi_Rating_API' ) ) { | |
$post_id = get_the_ID(); // must be in the WP loop | |
// if a rating form is not specified in post meta, use default settings | |
$rating_form_id = get_post_meta( $post_id, MRP_Multi_Rating::RATING_FORM_ID_POST_META, true ); | |
if ( $rating_form_id == '' ) { | |
$general_settings = (array) get_option( MRP_Multi_Rating::GENERAL_SETTINGS ); | |
$rating_form_id = $general_settings[ MRP_Multi_Rating::DEFAULT_RATING_FORM_OPTION ]; | |
} | |
// get user ID | |
$current_user = wp_get_current_user(); | |
$current_user_id = $current_user->ID; | |
// if user has submitted rating, show rating result | |
if ( MRP_Multi_Rating_API::check_user_has_submitted_rating( $rating_form_id, $post_id, $current_user_id ) ) { | |
MRP_Multi_Rating_API::display_rating_result( array( | |
'post_id' => get_the_ID(), | |
'rating_form_id' => $rating_form_id, | |
'echo' => true | |
) ); | |
// also show the rating item results if you want to | |
MRP_Multi_Rating_API::display_rating_item_results( array( | |
'post_id' => get_the_ID(), | |
'rating_form_id' => $rating_form_id, | |
'echo' => true | |
) ); | |
} else { | |
MRP_Multi_Rating_API::display_rating_form( array( | |
'post_id' => get_the_ID(), | |
'rating_form_id' => $rating_form_id, | |
'echo' => true | |
) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment