/** * Handles upgrade for review table. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global string $plugin_prefix Geodirectory plugin table prefix. */ function geodir_update_review_db() { global $wpdb, $plugin_prefix; geodir_fix_review_date(); geodir_fix_review_post_status(); geodir_fix_review_content(); geodir_fix_review_location(); }
/** * Checks ratings for correct location and content settings. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. */ function geodir_diagnose_ratings() { global $wpdb; $fix = isset($_POST['fix']) ? true : false; //if($fix){echo 'true';}else{echo 'false';} $is_error_during_diagnose = false; $output_str = ''; // check review locations if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL")) { $output_str .= "<li>" . __('Review locations missing or broken', 'geodirectory') . "</li>"; $is_error_during_diagnose = true; if ($fix) { if (geodir_fix_review_location()) { $output_str .= "<li><strong>" . __('-->FIXED: Review locations fixed', 'geodirectory') . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Review locations fix failed', 'geodirectory') . "</strong></li>"; } } } else { $output_str .= "<li>" . __('Review locations ok', 'geodirectory') . "</li>"; } // check review content if ($wpdb->get_results("SELECT * FROM " . GEODIR_REVIEW_TABLE . " WHERE comment_content IS NULL")) { $output_str .= "<li>" . __('Review content missing or broken', 'geodirectory') . "</li>"; $is_error_during_diagnose = true; if ($fix) { if (geodir_fix_review_content()) { $output_str .= "<li><strong>" . __('-->FIXED: Review content fixed', 'geodirectory') . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Review content fix failed', 'geodirectory') . "</strong></li>"; } } } else { $output_str .= "<li>" . __('Review content ok', 'geodirectory') . "</li>"; } if ($is_error_during_diagnose) { $info_div_class = "geodir_problem_info"; $fix_button_txt = "<input type='button' value='" . __('Fix', 'geodirectory') . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='ratings' />"; } else { $info_div_class = "geodir_noproblem_info"; $fix_button_txt = ''; } echo "<ul class='{$info_div_class}'>"; echo $output_str; echo $fix_button_txt; echo "</ul>"; }
/** * Handles upgrade for review table. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @global string $plugin_prefix Geodirectory plugin table prefix. */ function geodir_update_review_db() { global $wpdb, $plugin_prefix; // Add columns to review table geodir_add_column_if_not_exist(GEODIR_REVIEW_TABLE, 'post_status', 'INT(11) DEFAULT NULL'); geodir_add_column_if_not_exist(GEODIR_REVIEW_TABLE, 'post_date', 'DATETIME NOT NULL'); geodir_add_column_if_not_exist(GEODIR_REVIEW_TABLE, 'post_city', 'varchar(30) NULL DEFAULT NULL'); geodir_add_column_if_not_exist(GEODIR_REVIEW_TABLE, 'post_region', 'varchar(30) NULL DEFAULT NULL'); geodir_add_column_if_not_exist(GEODIR_REVIEW_TABLE, 'post_country', 'varchar(30) NULL DEFAULT NULL'); geodir_add_column_if_not_exist(GEODIR_REVIEW_TABLE, 'post_latitude', 'varchar(20) NULL DEFAULT NULL'); geodir_add_column_if_not_exist(GEODIR_REVIEW_TABLE, 'post_longitude', 'varchar(20) NULL DEFAULT NULL'); geodir_add_column_if_not_exist(GEODIR_REVIEW_TABLE, 'comment_content', 'TEXT NULL DEFAULT NULL'); // this should not be needed anymore becasue of geodir_fix_review_location() /*$reviews = $wpdb->get_results("SELECT * FROM ".GEODIR_REVIEW_TABLE." WHERE post_city='' OR post_city IS NULL OR post_latitude='' OR post_latitude IS NULL"); foreach($reviews as $review){ $location = $wpdb->get_row("SELECT * FROM ".$plugin_prefix.$review->post_type."_detail WHERE post_id=".$review->post_id); $wpdb->query($wpdb->prepare("UPDATE ".GEODIR_REVIEW_TABLE." gdr SET gdr.post_city=%s, gdr.post_region=%s , gdr.post_country=%s , gdr.post_latitude=%s, gdr.post_longitude=%s WHERE gdr.id=%d",$location->post_city,$location->post_region,$location->post_country,$review->id,$location->post_latitude,$location->post_longitude)); }*/ geodir_fix_review_date(); geodir_fix_review_post_status(); geodir_fix_review_content(); geodir_fix_review_location(); }