Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <div class="rating-form <?php echo $class; ?>" style="background: #f4f4f4;">
- <div style="padding: 1em;">
- <?php
- if ( ! empty( $title ) ) {
- $before_title = apply_filters( 'mrp_rating_form_before_title', $before_title, $post_id, $rating_form_id );
- $after_title = apply_filters( 'mrp_rating_form_after_title', $after_title, $post_id, $rating_form_id );
- echo "$before_title" . esc_html( $title ) . "$after_title";
- }
- // if an entry exists, show message
- if ( $rating_entry_id != null && $show_status_message == true ) {
- if ( $entry_status != 'approved' ) {
- ?>
- <p class="message mrp"><?php echo esc_html( $rating_awaiting_moderation_message ); ?></p>
- <?php
- } else {
- ?>
- <p class="message mrp"><?php echo esc_html( $already_submitted_rating_form_message ); ?></p>
- <?php
- }
- }
- $user_can_update_delete = apply_filters( 'mrp_user_can_update_delete', $user_can_update_delete, $user_id, $rating_entry_id, $post_id, $rating_form_id );
- // if already submitted a rating and user cannot update or delete, do not show rating form
- if ( ! ($rating_entry_id != null && ! $user_can_update_delete ) ) {
- ?>
- <?php
- if ( isset( $_POST['save'] ) ) {
- update_comment_meta( $comment_id, 'htitle', $htitle );
- }
- if ( isset( $_POST['delete'] ) ) {
- delete_comment_meta( $comment_id, 'htitle');
- } ?>
- <form method="POST" id="rating-form-<?php echo $rating_form_id; ?>-<?php echo $post_id; ?>-<?php echo $sequence; ?>" action="#">
- <?php $GLOBALS['comment'] = $comment;
- $htitle = get_comment_meta($comment_id,"htitle", true); ?>
- <script type="text/javascript">
- var titleV = document.getElementById("mrp-title-<?php echo $sequence ?>").value;
- var commentV = document.getElementById("comment-<?php echo $sequence; ?>").value;
- mrp_data_callbacks.push( function(index, data) {
- var titleV = document.getElementById("mrp-title-<?php echo $sequence ?>").value;
- data["<?php echo "htitle-" . $sequence ?>"] = titleV;
- return data;
- });
- mrp_data_callbacks.push( function(index, data) {
- data["<?php echo "comment-" . $sequence ?>"] = commentV;
- return data;
- });
- </script>
- <input style="max-width:600px;" type="text" name="htitle-<?php echo $sequence ?>" class="form-control" size="30" placeholder="<?php _e( 'Enter title...', 'multi-rating-pro' ); ?>" id="mrp-title-<?php echo $sequence ?>" class="title" value="<?php echo $htitle; ?>" maxlength="100"></input>
- <?php do_action( 'mrp_rating_form_before_rating_items', $post_id, $rating_form_id, $rating_items );
- /**
- * Rating Items
- */
- foreach ( (array) $rating_items as $rating_item ) {
- $rating_item_id = $rating_item['rating_item_id'];
- $element_id = 'rating-item-' . $rating_item_id . '-' . $sequence ;
- $description = $rating_item['description'];
- $rating_item_type = $rating_item['type'];
- $max_option_value = $rating_item['max_option_value'];
- $default_option_value = $rating_item['default_option_value'];
- $required = $rating_item['required'];
- $option_value_text = $rating_item['option_value_text'];
- $rating_item_type = $rating_item['type'];
- if ( isset( $selected_option_lookup[$rating_item_id] ) ) {
- $default_option_value = $selected_option_lookup[$rating_item_id];
- }
- // FIXME use API function get_rating_item_option_value_text_lookup()
- // lookup the option text descriptions for select and radio buttons
- $option_value_text_lookup = array();
- $option_value_text_array = preg_split( '/[\r\n,]+/' , $option_value_text, -1, PREG_SPLIT_NO_EMPTY );
- foreach ( (array) $option_value_text_array as $current_option_value_text ) {
- $parts = explode( '=', $current_option_value_text );
- if ( count( $parts ) == 2 && is_numeric( $parts[0] ) ) {
- $option_value_text_lookup[intval( $parts[0] )] = stripslashes( $parts[1] ); // TOD stripslashes?
- }
- }
- mrp_get_template_part( 'rating-form', 'rating-item', true, array(
- 'rating_item_id' => $rating_item_id,
- 'element_id' => $element_id,
- 'description' => $description,
- 'max_option_value' => $max_option_value,
- 'default_option_value' => $default_option_value,
- 'required' => $required,
- 'option_value_text' => $option_value_text,
- 'class' => null,
- 'style' => null,
- 'icon_classes' => $icon_classes,
- 'use_custom_star_images' => $use_custom_star_images,
- 'rating_item_type' => $rating_item_type,
- 'option_value_text_lookup' => $option_value_text_lookup,
- 'rating_entry_id' => $rating_entry_id
- ) );
- ?>
- <!-- hidden field to get rating item id -->
- <input type="hidden" value="<?php echo $rating_item_id; ?>" class="rating-item-<?php echo $rating_form_id; ?>-<?php echo $post_id; ?>-<?php echo $sequence; ?>" id="hidden-rating-item-id-<?php echo $rating_item_id; ?>" />
- <?php
- }
- do_action( 'mrp_rating_form_before_optional_fields', $post_id, $rating_form_id );
- mrp_get_template_part( 'rating-form', 'optional-fields', true, array(
- 'show_name_input' => $show_name_input,
- 'show_email_input' => $show_email_input,
- 'show_comment_textarea' => $show_comment_textarea,
- 'comment_id' => $comment_id,
- 'user_id' => $user_id,
- 'name' => $name,
- 'email' => $email,
- 'comment' => $comment,
- 'sequence' => $sequence
- ) );
- do_action( 'mrp_rating_form_before_custom_fields', $post_id, $rating_form_id, $custom_fields );
- foreach ( (array) $custom_fields as $custom_field ) {
- $custom_field_id = $custom_field['custom_field_id'];
- $label = $custom_field['label'];
- $required = $custom_field['required'];
- $max_length = $custom_field['max_length'];
- $type = $custom_field['type'];
- $placeholder = $custom_field['placeholder'];
- $element_id = 'custom-field-' . $custom_field_id . '-' . $sequence;
- $value = '';
- if ( isset( $custom_field_values_lookup[$custom_field_id] ) ) {
- $value = $custom_field_values_lookup[$custom_field_id];
- }
- mrp_get_template_part( 'rating-form', 'custom-fields', true, array(
- 'custom_field_id' => $custom_field_id,
- 'label' => $label,
- 'required' => $required,
- 'max_length' => $max_length,
- 'type' => $type,
- 'placeholder' => $placeholder,
- 'value' => $value,
- 'element_id' => $element_id
- ) );
- ?>
- <!-- hidden field to get custom field id -->
- <input type="hidden" value="<?php echo $custom_field_id; ?>" class="custom-field-<?php echo $rating_form_id; ?>-<?php echo $post_id; ?>-<?php echo $sequence; ?>" id="hidden-custom-field-id-<?php echo $custom_field_id; ?>" />
- <?php
- } ?>
- <textarea name="comment-<?php echo $sequence; ?>" id="comment-<?php echo $sequence; ?>" class="form-control" rows="5" cols="10" value="<?php echo esc_attr( $comment ); ?>" placeholder="Review" style="max-width:600px;"><?php echo esc_attr( $comment ); ?></textarea>
- <?php do_action( 'mrp_rating_form_before_buttons' );
- $button_text = $submit_button_text; ?>
- <input type="button" class="btn btn-default save-rating" name="save" id="saveBtn-<?php echo $rating_form_id; ?>-<?php echo $post_id; ?>-<?php echo $sequence; ?>" value="Save"></input>
- <?php if ( $rating_entry_id != null ) {
- $button_text = $update_button_text;
- ?>
- <input type="hidden" value="<?php echo $rating_entry_id; ?>" id="ratingEntryId-<?php echo $rating_form_id; ?>-<?php echo $post_id; ?>-<?php echo $sequence; ?>" />
- <input type="button" class="btn btn-default delete-rating" id="deleteBtn-<?php echo $rating_form_id; ?>-<?php echo $post_id; ?>-<?php echo $sequence; ?>" name="delete" value="<?php echo esc_attr( $delete_button_text ); ?>"></input>
- <?php
- }
- ?>
- <input type="hidden" name="commentid" value="<?php echo $comment_id; ?>" />
- <?php wp_nonce_field('comment-update'); ?>
- <?php echo ' <a href="'.admin_url("comment.php?action=cdc&c=$comment_id").'">Delete Entire Review</a>'; ?>
- <input type="hidden" name="sequence" value="<?php echo $sequence; ?>" />
- <?php
- do_action( 'mrp_rating_form_after_buttons' );
- ?>
- </form>
- <?php
- }
- ?>
- </div>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement