/** * Standalone Rating Form * * @param $form_id * @param $post_id * @param string $theme_key * * @return string */ public static function standalonePostingRatingSystemForm($form_id, $post_id, $theme_key = '', $showreview = true) { //$id = get_the_ID(); $form = ''; $review = ''; $output = ''; $theme_key = $theme_key == '' ? get_option('cbratingsystem_theme_key') : $theme_key; $form_id = apply_filters('rating_form_array', $form_id); if (is_int($form_id) || is_numeric($form_id)) { $ratingFormArray = CBRatingSystemData::get_ratingForm($form_id); $ratingFormArray['form_id'] = $form_id; $ratingFormArray['post_id'] = $post_id; if (class_exists('CBRatingSystemFront') and $ratingFormArray['is_active'] == 1) { //$theme_key = get_option('cbratingsystem_theme_key'); $ratingFormArray['theme_key'] = $theme_key; $ratingFormArray = apply_filters('cbratingsystem_change_options', $ratingFormArray); $form .= CBRatingSystemFront::add_ratingForm_to_content($ratingFormArray); CBRatingSystemTheme::build_custom_theme_css(); CBRatingSystem::load_scripts_and_styles(); $output = $form; } //var_dump($ratingFormArray); if (class_exists('CBRatingSystemFrontReview') && $ratingFormArray['review_enabled'] == 1 && $showreview) { //if(is_single() || is_page()){ if (is_singular()) { $review .= CBRatingSystemFrontReview::rating_reviews_shorttag($ratingFormArray, $post_id, 0); if (!empty($review)) { CBRatingSystemTheme::build_custom_theme_css(); CBRatingSystem::load_scripts_and_styles(); $output = $output . $review; } } } } return $output; }
/** * process_bulk_action */ public function process_bulk_action() { $action = $this->current_action(); switch ($action) { case 'delete': if (!empty($_GET['wdcheckbox'])) { global $wpdb; $avgid = (array) $_GET['wdcheckbox']; $formIds = array(); $postIds = array(); $table_name1 = CBRatingSystemData::get_user_ratings_table_name(); foreach ($avgid as $id) { $id = (int) $id; $sql = $wpdb->prepare("SELECT post_id ,form_id FROM {$table_name1} WHERE id=%d ", $id); $results = $wpdb->get_results($sql, ARRAY_A); array_push($formIds, $results[0]['form_id']); array_push($postIds, $results[0]['post_id']); } $table_name1 = CBRatingSystemData::get_user_ratings_table_name(); $table_name = CBRatingSystemData::get_user_ratings_summury_table_name(); $table_name = CBRatingSystemData::get_user_ratings_table_name(); //$sql = $wpdb->prepare( "DELETE FROM $table_name WHERE id IN (" . implode( ',', $avgid ) . ")", null ); $sql = "DELETE FROM {$table_name} WHERE id IN (" . implode(',', (array) $avgid) . ")"; $wpdb->query($sql); foreach ($postIds as $index => $id) { $formId = $formIds[$index]; $postId = $id; $ratingAverage = CBRatingSystemFront::viewPerCriteriaRatingResult($formId, $postId); //$perPostAverageRating = isset($ratingAverage['perPost'][$postId])? $ratingAverage['perPost'][$postId] : ''; $perPostAverageRating = $ratingAverage['perPost'][$postId]; $postType = get_post_type($postId); $ratingsCount = $ratingAverage['ratingsCount'][$formId . '-' . $postId]; $rating = array('form_id' => $formId, 'post_id' => $postId, 'post_type' => $postType, 'per_post_rating_count' => $ratingsCount, 'per_post_rating_summary' => $perPostAverageRating, 'per_criteria_rating_summary' => maybe_serialize($ratingAverage['avgPerCriteria'])); $success = CBRatingSystemData::update_rating_summary($rating); } ?> <script type="text/javascript"> jQuery(document).ready(function ($) { $('.messages').show(); $('.messages').html('Successfully done'); var ids = '<?php echo json_encode($avgid); ?> '; var trainindIdArray = ids.split(','); $.each(trainindIdArray, function(index, value) { value = value.replace('"',''); value = value.replace('[',''); value = value.replace(']',''); value = value.replace('"',''); $('.user-rating-log-'+value).parents('tr').hide(); }); setTimeout(function() { //calls click event after a certain time $('.messages').hide(); }, 2000); }); </script> <?php } break; case 'approve': if (!empty($_GET['wdcheckbox'])) { $avgid = $_GET['wdcheckbox']; $cbsommentstatus = 'approved'; $this->change_comment_status($avgid, $cbsommentstatus); //cbratingsystemaddonfunctions ::cbratingsystem_comment_statuschange($avgid,$cbsommentstatus); } // end of if get echo '<script>window.location.href="admin.php?page=rating_reports"</script>'; break; case 'spam': if (!empty($_GET['wdcheckbox'])) { $avgid = $_GET['wdcheckbox']; $cbsommentstatus = 'spam'; $this->change_comment_status($avgid, $cbsommentstatus); //cbratingsystemaddonfunctions ::cbratingsystem_comment_statuschange($avgid,$cbsommentstatus); } // end of if get break; case 'unapprove': if (!empty($_GET['wdcheckbox'])) { $avgid = $_GET['wdcheckbox']; $cbsommentstatus = 'unapproved'; $this->change_comment_status($avgid, $cbsommentstatus); //cbratingsystemaddonfunctions ::cbratingsystem_comment_statuschange($avgid,$cbsommentstatus); } // end of if get echo '<script>window.location.href="admin.php?page=rating_reports"</script>'; break; default: // do nothing or something else return; break; } return; }