'; //Form title begin $html .= '
'; $html .= ' '; $html .= ''; //Form title end $html .= '
comment_post_ID; if ((isset($_POST['mkdf_listing_resume_comment_title'])) && ($_POST['mkdf_listing_resume_comment_title'] != '')) { $title = wp_filter_nohtml_kses($_POST['mkdf_listing_resume_comment_title']); add_comment_meta($comment_id, 'mkdf_listing_resume_comment_title', $title); } if ((isset($_POST['mkdf_listing_resume_rating'])) && ($_POST['mkdf_listing_resume_rating'] != '')) { $rating = wp_filter_nohtml_kses($_POST['mkdf_listing_resume_rating']); add_comment_meta($comment_id, 'mkdf_listing_resume_rating', $rating); $rating_obj = new Core\ResumeRating($post_id, $rating); $rating_obj->increaseRating(); } } add_action('comment_post', 'mkdf_listing_resume_save_comment_meta_data'); } if(!function_exists('mkdf_listing_resume_verify_comment_meta_data')) { function mkdf_listing_resume_verify_comment_meta_data($commentdata) { if ( is_singular('resume') ) { if (!isset($_POST['mkdf_listing_resume_rating'])) { wp_die(esc_html__('Error: You did not add a rating. Hit the Back button on your Web browser and resubmit your comment with a rating.', 'mkdf-listing')); } } return $commentdata; } add_filter('preprocess_comment', 'mkdf_listing_resume_verify_comment_meta_data'); } if(!function_exists('mkdf_listing_resume_get_current_post_comments')){ function mkdf_listing_resume_get_current_post_comments($post_id, $order_by = 'comment_date_gmt' , $order = 'desc'){ $meta_key = ''; if($order_by === 'rating'){ $order_by = 'meta_value'; $meta_key = 'mkdf_listing_resume_rating'; }elseif($order_by === 'date'){ $order_by = 'comment_date_gmt'; }; $comment_args = array( 'post_id' => $post_id, 'status' => 'approve', 'orderby' => $order_by, 'meta_key' => $meta_key, 'order' => $order ); if ( is_user_logged_in() ) { $comment_args['include_unapproved'] = get_current_user_id(); } else { $commenter = wp_get_current_commenter(); if ( $commenter['comment_author_email'] ) { $comment_args['include_unapproved'] = $commenter['comment_author_email']; } } $comments = get_comments($comment_args); return $comments; } } if ( ! function_exists( 'mkdf_listing_resume_post_reviews_html' ) ) { function mkdf_listing_resume_post_reviews_html($reviews = array(), $post_id) { $post = get_post($post_id); $html = ''; if(count($reviews)){ foreach ($reviews as $comment){ $is_pingback_comment = $comment->comment_type == 'pingback'; $is_author_comment = $post->post_author == $comment->user_id; $comment_class = 'mkdf-comment clearfix'; if($is_author_comment) { $comment_class .= ' mkdf-post-author-comment'; } if($is_pingback_comment) { $comment_class .= ' mkdf-pingback-comment'; } $review_rating = get_comment_meta( $comment->comment_ID, 'mkdf_listing_resume_rating', true ); $review_rating_style = 'width: '.esc_attr($review_rating*20).'%'; $review_title = get_comment_meta( $comment->comment_ID, 'mkdf_listing_resume_comment_title', true ); $comment_params = array( 'comment' => $comment, 'is_pingback_comment' => $is_pingback_comment, 'is_author_comment' => $is_author_comment, 'comment_class' => $comment_class, 'review_rating_style' => $review_rating_style, 'review_title' => $review_title, ); $html .= mkdf_listing_resume_single_template_part('review/review', '', $comment_params); } } return $html; } } if(!function_exists('mkdf_listing_resume_get_post_reviews_ajax')){ function mkdf_listing_resume_get_post_reviews_ajax(){ if(isset($_POST)) { $html = ''; foreach($_POST as $key => $value) { if($key !== '') { $addUnderscoreBeforeCapitalLetter = preg_replace('/([A-Z])/', '_$1', $key); $setAllLettersToLowercase = strtolower($addUnderscoreBeforeCapitalLetter); $params[$setAllLettersToLowercase] = $value; } } extract($params); if(isset($order) && $order !== '' && isset($order_by) && $order_by !== '' && isset($post_id) && $post_id !== ''){ $post_comments = mkdf_listing_resume_get_current_post_comments($post_id, $order_by, $order ); ob_start(); mkdf_listing_resume_post_reviews_html($post_comments, $post_id); $html = ob_get_clean(); } $return_obj = array( 'html' => $html ); echo json_encode($return_obj); exit; } } add_action('wp_ajax_nopriv_mkdf_listing_resume_get_post_reviews_ajax', 'mkdf_listing_resume_get_post_reviews_ajax'); add_action( 'wp_ajax_mkdf_listing_resume_get_post_reviews_ajax', 'mkdf_listing_resume_get_post_reviews_ajax' ); } '; } ?>