Advertisement
Guest User

form.php

a guest
Jan 7th, 2016
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.92 KB | None | 0 0
  1. <div class="rating-form <?php echo $class; ?>" style="background: #f4f4f4;">
  2. <div style="padding: 1em;">
  3. <?php
  4.  
  5. if ( ! empty( $title ) ) {
  6.  
  7. $before_title = apply_filters( 'mrp_rating_form_before_title', $before_title, $post_id, $rating_form_id );
  8. $after_title = apply_filters( 'mrp_rating_form_after_title', $after_title, $post_id, $rating_form_id );
  9.  
  10. echo "$before_title" . esc_html( $title ) . "$after_title";
  11. }
  12.  
  13.  
  14. // if an entry exists, show message
  15. if ( $rating_entry_id != null && $show_status_message == true ) {
  16. if ( $entry_status != 'approved' ) {
  17. ?>
  18. <p class="message mrp"><?php echo esc_html( $rating_awaiting_moderation_message ); ?></p>
  19. <?php
  20. } else {
  21. ?>
  22. <p class="message mrp"><?php echo esc_html( $already_submitted_rating_form_message ); ?></p>
  23. <?php
  24. }
  25. }
  26.  
  27. $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 );
  28.  
  29. // if already submitted a rating and user cannot update or delete, do not show rating form
  30. if ( ! ($rating_entry_id != null && ! $user_can_update_delete ) ) {
  31. ?>
  32. <?php
  33. if ( isset( $_POST['save'] ) ) {
  34. update_comment_meta( $comment_id, 'htitle', $htitle );
  35. }
  36. if ( isset( $_POST['delete'] ) ) {
  37. delete_comment_meta( $comment_id, 'htitle');
  38. } ?>
  39.  
  40. <form method="POST" id="rating-form-<?php echo $rating_form_id; ?>-<?php echo $post_id; ?>-<?php echo $sequence; ?>" action="#">
  41. <?php $GLOBALS['comment'] = $comment;
  42. $htitle = get_comment_meta($comment_id,"htitle", true); ?>
  43. <script type="text/javascript">
  44. var titleV = document.getElementById("mrp-title-<?php echo $sequence ?>").value;
  45. var commentV = document.getElementById("comment-<?php echo $sequence; ?>").value;
  46. mrp_data_callbacks.push( function(index, data) {
  47. var titleV = document.getElementById("mrp-title-<?php echo $sequence ?>").value;
  48. data["<?php echo "htitle-" . $sequence ?>"] = titleV;
  49. return data;
  50. });
  51. mrp_data_callbacks.push( function(index, data) {
  52.  
  53. data["<?php echo "comment-" . $sequence ?>"] = commentV;
  54. return data;
  55. });
  56. </script>
  57. <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>
  58.  
  59. <?php do_action( 'mrp_rating_form_before_rating_items', $post_id, $rating_form_id, $rating_items );
  60.  
  61. /**
  62. * Rating Items
  63. */
  64. foreach ( (array) $rating_items as $rating_item ) {
  65.  
  66. $rating_item_id = $rating_item['rating_item_id'];
  67. $element_id = 'rating-item-' . $rating_item_id . '-' . $sequence ;
  68. $description = $rating_item['description'];
  69. $rating_item_type = $rating_item['type'];
  70. $max_option_value = $rating_item['max_option_value'];
  71. $default_option_value = $rating_item['default_option_value'];
  72. $required = $rating_item['required'];
  73. $option_value_text = $rating_item['option_value_text'];
  74. $rating_item_type = $rating_item['type'];
  75.  
  76. if ( isset( $selected_option_lookup[$rating_item_id] ) ) {
  77. $default_option_value = $selected_option_lookup[$rating_item_id];
  78. }
  79.  
  80. // FIXME use API function get_rating_item_option_value_text_lookup()
  81. // lookup the option text descriptions for select and radio buttons
  82. $option_value_text_lookup = array();
  83. $option_value_text_array = preg_split( '/[\r\n,]+/' , $option_value_text, -1, PREG_SPLIT_NO_EMPTY );
  84. foreach ( (array) $option_value_text_array as $current_option_value_text ) {
  85. $parts = explode( '=', $current_option_value_text );
  86. if ( count( $parts ) == 2 && is_numeric( $parts[0] ) ) {
  87. $option_value_text_lookup[intval( $parts[0] )] = stripslashes( $parts[1] ); // TOD stripslashes?
  88. }
  89. }
  90.  
  91. mrp_get_template_part( 'rating-form', 'rating-item', true, array(
  92. 'rating_item_id' => $rating_item_id,
  93. 'element_id' => $element_id,
  94. 'description' => $description,
  95. 'max_option_value' => $max_option_value,
  96. 'default_option_value' => $default_option_value,
  97. 'required' => $required,
  98. 'option_value_text' => $option_value_text,
  99. 'class' => null,
  100. 'style' => null,
  101. 'icon_classes' => $icon_classes,
  102. 'use_custom_star_images' => $use_custom_star_images,
  103. 'rating_item_type' => $rating_item_type,
  104. 'option_value_text_lookup' => $option_value_text_lookup,
  105. 'rating_entry_id' => $rating_entry_id
  106. ) );
  107.  
  108. ?>
  109.  
  110. <!-- hidden field to get rating item id -->
  111. <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; ?>" />
  112. <?php
  113. }
  114.  
  115. do_action( 'mrp_rating_form_before_optional_fields', $post_id, $rating_form_id );
  116.  
  117. mrp_get_template_part( 'rating-form', 'optional-fields', true, array(
  118. 'show_name_input' => $show_name_input,
  119. 'show_email_input' => $show_email_input,
  120. 'show_comment_textarea' => $show_comment_textarea,
  121. 'comment_id' => $comment_id,
  122. 'user_id' => $user_id,
  123. 'name' => $name,
  124. 'email' => $email,
  125. 'comment' => $comment,
  126. 'sequence' => $sequence
  127. ) );
  128.  
  129. do_action( 'mrp_rating_form_before_custom_fields', $post_id, $rating_form_id, $custom_fields );
  130.  
  131. foreach ( (array) $custom_fields as $custom_field ) {
  132.  
  133. $custom_field_id = $custom_field['custom_field_id'];
  134. $label = $custom_field['label'];
  135. $required = $custom_field['required'];
  136. $max_length = $custom_field['max_length'];
  137. $type = $custom_field['type'];
  138. $placeholder = $custom_field['placeholder'];
  139. $element_id = 'custom-field-' . $custom_field_id . '-' . $sequence;
  140.  
  141. $value = '';
  142. if ( isset( $custom_field_values_lookup[$custom_field_id] ) ) {
  143. $value = $custom_field_values_lookup[$custom_field_id];
  144. }
  145.  
  146. mrp_get_template_part( 'rating-form', 'custom-fields', true, array(
  147. 'custom_field_id' => $custom_field_id,
  148. 'label' => $label,
  149. 'required' => $required,
  150. 'max_length' => $max_length,
  151. 'type' => $type,
  152. 'placeholder' => $placeholder,
  153. 'value' => $value,
  154. 'element_id' => $element_id
  155. ) );
  156.  
  157. ?>
  158. <!-- hidden field to get custom field id -->
  159. <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; ?>" />
  160.  
  161. <?php
  162. } ?>
  163. <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>
  164.  
  165.  
  166. <?php do_action( 'mrp_rating_form_before_buttons' );
  167.  
  168. $button_text = $submit_button_text; ?>
  169. <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>
  170. <?php if ( $rating_entry_id != null ) {
  171. $button_text = $update_button_text;
  172. ?>
  173. <input type="hidden" value="<?php echo $rating_entry_id; ?>" id="ratingEntryId-<?php echo $rating_form_id; ?>-<?php echo $post_id; ?>-<?php echo $sequence; ?>" />
  174.  
  175. <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>
  176. <?php
  177. }
  178.  
  179. ?>
  180.  
  181.  
  182. <input type="hidden" name="commentid" value="<?php echo $comment_id; ?>" />
  183. <?php wp_nonce_field('comment-update'); ?>
  184. <?php echo ' <a href="'.admin_url("comment.php?action=cdc&c=$comment_id").'">Delete Entire Review</a>'; ?>
  185.  
  186. <input type="hidden" name="sequence" value="<?php echo $sequence; ?>" />
  187.  
  188. <?php
  189. do_action( 'mrp_rating_form_after_buttons' );
  190. ?>
  191. </form>
  192. <?php
  193. }
  194. ?>
  195. </div>
  196. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement