/** * Checks if the GD pages are installed correctly or not. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. */ function geodir_diagnose_default_pages() { global $wpdb; $is_error_during_diagnose = false; $output_str = ''; $fix = isset($_POST['fix']) ? true : false; ////////////////////////////////// /* Diagnose GD Home Page Starts */ ////////////////////////////////// $option_value = get_option('geodir_home_page'); $page = get_post($option_value); if (!empty($page)) { $page_found = $page->ID; } else { $page_found = ''; } if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') { $output_str .= "<li>" . __('GD Home page exists with proper setting.', 'geodirectory') . "</li>"; } else { $is_error_during_diagnose = true; $output_str .= "<li><strong>" . __('GD Home page is missing.', 'geodirectory') . "</strong></li>"; if ($fix) { if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) { $output_str .= "<li><strong>" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "</strong></li>"; } } } //////////////////////////////// /* Diagnose GD Home Page Ends */ //////////////////////////////// ////////////////////////////////// /* Diagnose Add Listing Page Starts */ ////////////////////////////////// $option_value = get_option('geodir_add_listing_page'); $page = get_post($option_value); if (!empty($page)) { $page_found = $page->ID; } else { $page_found = ''; } if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') { $output_str .= "<li>" . __('Add Listing page exists with proper setting.', 'geodirectory') . "</li>"; } else { $is_error_during_diagnose = true; $output_str .= "<li><strong>" . __('Add Listing page is missing.', 'geodirectory') . "</strong></li>"; if ($fix) { if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) { $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "</strong></li>"; } } } //////////////////////////////// /* Diagnose Add Listing Page Ends */ //////////////////////////////// ////////////////////////////////// /* Diagnose Listing Preview Page Starts */ ////////////////////////////////// $option_value = get_option('geodir_preview_page'); $page = get_post($option_value); if (!empty($page)) { $page_found = $page->ID; } else { $page_found = ''; } if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') { $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "</li>"; } else { $is_error_during_diagnose = true; $output_str .= "<li><strong>" . __('Listing Preview page is missing.', 'geodirectory') . "</strong></li>"; if ($fix) { if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) { $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "</strong></li>"; } } } //////////////////////////////// /* Diagnose Listing Preview Page Ends */ //////////////////////////////// ////////////////////////////////// /* Diagnose Listing Success Page Starts */ ////////////////////////////////// $option_value = get_option('geodir_success_page'); $page = get_post($option_value); if (!empty($page)) { $page_found = $page->ID; } else { $page_found = ''; } if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') { $output_str .= "<li>" . __('Listing Success page exists with proper setting.', 'geodirectory') . "</li>"; } else { $is_error_during_diagnose = true; $output_str .= "<li><strong>" . __('Listing Success page is missing.', 'geodirectory') . "</strong></li>"; if ($fix) { if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) { $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "</strong></li>"; } } } //////////////////////////////// /* Diagnose Listing Sucess Page Ends */ //////////////////////////////// ////////////////////////////////// /* Diagnose Info Page Starts */ ////////////////////////////////// $option_value = get_option('geodir_info_page'); $page = get_post($option_value); if (!empty($page)) { $page_found = $page->ID; } else { $page_found = ''; } if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') { $output_str .= "<li>" . __('Info page exists with proper setting.', 'geodirectory') . "</li>"; } else { $is_error_during_diagnose = true; $output_str .= "<li><strong>" . __('Info page is missing.', 'geodirectory') . "</strong></li>"; if ($fix) { if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) { $output_str .= "<li><strong>" . __('-->FIXED: Info page fixed', 'geodirectory') . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Info page fix failed', 'geodirectory') . "</strong></li>"; } } } //////////////////////////////// /* Diagnose Info Page Ends */ //////////////////////////////// ////////////////////////////////// /* Diagnose Login Page Starts */ ////////////////////////////////// $option_value = get_option('geodir_login_page'); $page = get_post($option_value); if (!empty($page)) { $page_found = $page->ID; } else { $page_found = ''; } if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') { $output_str .= "<li>" . __('Login page exists with proper setting.', 'geodirectory') . "</li>"; } else { $is_error_during_diagnose = true; $output_str .= "<li><strong>" . __('Login page is missing.', 'geodirectory') . "</strong></li>"; if ($fix) { if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) { $output_str .= "<li><strong>" . __('-->FIXED: Login page fixed', 'geodirectory') . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Login page fix failed', 'geodirectory') . "</strong></li>"; } } } //////////////////////////////// /* Diagnose Info Page Ends */ //////////////////////////////// ////////////////////////////////// /* Diagnose Location Page Starts */ ////////////////////////////////// $option_value = get_option('geodir_location_page'); $page = get_post($option_value); if (!empty($page)) { $page_found = $page->ID; } else { $page_found = ''; } if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') { $output_str .= "<li>" . __('Location page exists with proper setting.', 'geodirectory') . "</li>"; } else { $is_error_during_diagnose = true; $output_str .= "<li><strong>" . __('Location page is missing.', 'geodirectory') . "</strong></li>"; if ($fix) { if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) { $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', 'geodirectory') . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', 'geodirectory') . "</strong></li>"; } } } //////////////////////////////// /* Diagnose Location Page Ends */ //////////////////////////////// $page_chk_arr = array('output_str' => $output_str, 'is_error_during_diagnose' => $is_error_during_diagnose); /** * This action is called at the end of the GD Tools page check function. * * @since 1.5.2 */ $page_chk_arr = apply_filters('geodir_diagnose_default_pages', $page_chk_arr); $output_str = $page_chk_arr['output_str']; $is_error_during_diagnose = $page_chk_arr['is_error_during_diagnose']; if ($is_error_during_diagnose) { if ($fix) { flush_rewrite_rules(); } $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='default_pages' />"; } 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>"; }
/** * Checks if the GD pages are installed correctly or not. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. */ function geodir_diagnose_default_pages() { global $wpdb; $is_error_during_diagnose = false; $output_str = ''; $fix = isset($_POST['fix']) ? true : false; ////////////////////////////////// /* Diagnose Add Listing Page Starts */ ////////////////////////////////// $option_value = get_option('geodir_add_listing_page'); $page = get_post($option_value); if (!empty($page)) { $page_found = $page->ID; } else { $page_found = ''; } if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') { $output_str .= "<li>" . __('Add Listing page exists with proper setting.', GEODIRECTORY_TEXTDOMAIN) . "</li>"; } else { $is_error_during_diagnose = true; $output_str .= "<li><strong>" . __('Add Listing page is missing.', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; if ($fix) { if (geodir_fix_virtual_page('add-listing', __('Add Listing', GEODIRECTORY_TEXTDOMAIN), $page_found, 'geodir_add_listing_page')) { $output_str .= "<li><strong>" . __('-->FIXED: Add Listing page fixed', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Add Listing page fix failed', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; } } } //////////////////////////////// /* Diagnose Add Listing Page Ends */ //////////////////////////////// ////////////////////////////////// /* Diagnose Listing Preview Page Starts */ ////////////////////////////////// $option_value = get_option('geodir_preview_page'); $page = get_post($option_value); if (!empty($page)) { $page_found = $page->ID; } else { $page_found = ''; } if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') { $output_str .= "<li>" . __('Listing Preview page exists with proper setting.', GEODIRECTORY_TEXTDOMAIN) . "</li>"; } else { $is_error_during_diagnose = true; $output_str .= "<li><strong>" . __('Listing Preview page is missing.', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; if ($fix) { if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', GEODIRECTORY_TEXTDOMAIN), $page_found, 'geodir_preview_page')) { $output_str .= "<li><strong>" . __('-->FIXED: Listing Preview page fixed', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Listing Preview page fix failed', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; } } } //////////////////////////////// /* Diagnose Listing Preview Page Ends */ //////////////////////////////// ////////////////////////////////// /* Diagnose Listing Success Page Starts */ ////////////////////////////////// $option_value = get_option('geodir_success_page'); $page = get_post($option_value); if (!empty($page)) { $page_found = $page->ID; } else { $page_found = ''; } if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') { $output_str .= "<li>" . __('Listing Success page exists with proper setting.', GEODIRECTORY_TEXTDOMAIN) . "</li>"; } else { $is_error_during_diagnose = true; $output_str .= "<li><strong>" . __('Listing Success page is missing.', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; if ($fix) { if (geodir_fix_virtual_page('listing-success', __('Listing Success', GEODIRECTORY_TEXTDOMAIN), $page_found, 'geodir_success_page')) { $output_str .= "<li><strong>" . __('-->FIXED: Listing Success page fixed', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Listing Success page fix failed', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; } } } //////////////////////////////// /* Diagnose Listing Sucess Page Ends */ //////////////////////////////// ////////////////////////////////// /* Diagnose Location Page Starts */ ////////////////////////////////// $option_value = get_option('geodir_location_page'); $page = get_post($option_value); if (!empty($page)) { $page_found = $page->ID; } else { $page_found = ''; } if (!empty($option_value) && !empty($page_found) && $option_value == $page_found && $page->post_status == 'publish') { $output_str .= "<li>" . __('Location page exists with proper setting.', GEODIRECTORY_TEXTDOMAIN) . "</li>"; } else { $is_error_during_diagnose = true; $output_str .= "<li><strong>" . __('Location page is missing.', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; if ($fix) { if (geodir_fix_virtual_page('location', __('Location', GEODIRECTORY_TEXTDOMAIN), $page_found, 'geodir_location_page')) { $output_str .= "<li><strong>" . __('-->FIXED: Location page fixed', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; } else { $output_str .= "<li><strong>" . __('-->FAILED: Location page fix failed', GEODIRECTORY_TEXTDOMAIN) . "</strong></li>"; } } } //////////////////////////////// /* Diagnose Location Page Ends */ //////////////////////////////// if ($is_error_during_diagnose) { if ($fix) { flush_rewrite_rules(); } $info_div_class = "geodir_problem_info"; $fix_button_txt = "<input type='button' value='" . __('Fix', GEODIRECTORY_TEXTDOMAIN) . "' class='button-primary geodir_fix_diagnostic_issue' data-diagnostic-issue='default_pages' />"; } 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>"; }