Function Reference: geodir_diagnose_default_pages
Summary
Checks if the GD pages are installed correctly or not.
Global Values
- $wpdb
- (object) (required) WordPress Database object.
- Default: None
Package
GeoDirectory
Change Log
Since: 1.0.0
Filters
‘geodir_diagnose_default_pages’ [Line: 1793]
Source File
geodir_diagnose_default_pages() is located in geodirectory-admin/admin_hooks_actions.php [Line: 1604]
Source Code
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 .= "
" . __('GD Home page exists with proper setting.', 'geodirectory') . "";
else {
$is_error_during_diagnose = true;
$output_str .= "
" . __('GD Home page is missing.', 'geodirectory') . "";
if ($fix) {
if (geodir_fix_virtual_page('gd-home', __('GD Home page', 'geodirectory'), $page_found, 'geodir_home_page')) {
$output_str .= "
" . __('-->FIXED: GD Home page fixed', 'geodirectory') . "";
} else {
$output_str .= "
" . __('-->FAILED: GD Home page fix failed', 'geodirectory') . "";
}
}
}
////////////////////////////////
/* 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 .= "
" . __('Add Listing page exists with proper setting.', 'geodirectory') . "";
else {
$is_error_during_diagnose = true;
$output_str .= "
" . __('Add Listing page is missing.', 'geodirectory') . "";
if ($fix) {
if (geodir_fix_virtual_page('add-listing', __('Add Listing', 'geodirectory'), $page_found, 'geodir_add_listing_page')) {
$output_str .= "
" . __('-->FIXED: Add Listing page fixed', 'geodirectory') . "";
} else {
$output_str .= "
" . __('-->FAILED: Add Listing page fix failed', 'geodirectory') . "";
}
}
}
////////////////////////////////
/* 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 .= "
" . __('Listing Preview page exists with proper setting.', 'geodirectory') . "";
else {
$is_error_during_diagnose = true;
$output_str .= "
" . __('Listing Preview page is missing.', 'geodirectory') . "";
if ($fix) {
if (geodir_fix_virtual_page('listing-preview', __('Listing Preview', 'geodirectory'), $page_found, 'geodir_preview_page')) {
$output_str .= "
" . __('-->FIXED: Listing Preview page fixed', 'geodirectory') . "";
} else {
$output_str .= "
" . __('-->FAILED: Listing Preview page fix failed', 'geodirectory') . "";
}
}
}
////////////////////////////////
/* 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 .= "
" . __('Listing Success page exists with proper setting.', 'geodirectory') . "";
else {
$is_error_during_diagnose = true;
$output_str .= "
" . __('Listing Success page is missing.', 'geodirectory') . "";
if ($fix) {
if (geodir_fix_virtual_page('listing-success', __('Listing Success', 'geodirectory'), $page_found, 'geodir_success_page')) {
$output_str .= "
" . __('-->FIXED: Listing Success page fixed', 'geodirectory') . "";
} else {
$output_str .= "
" . __('-->FAILED: Listing Success page fix failed', 'geodirectory') . "";
}
}
}
////////////////////////////////
/* 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 .= "
" . __('Info page exists with proper setting.', 'geodirectory') . "";
else {
$is_error_during_diagnose = true;
$output_str .= "
" . __('Info page is missing.', 'geodirectory') . "";
if ($fix) {
if (geodir_fix_virtual_page('gd-info', __('Info', 'geodirectory'), $page_found, 'geodir_info_page')) {
$output_str .= "
" . __('-->FIXED: Info page fixed', 'geodirectory') . "";
} else {
$output_str .= "
" . __('-->FAILED: Info page fix failed', 'geodirectory') . "";
}
}
}
////////////////////////////////
/* 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 .= "
" . __('Login page exists with proper setting.', 'geodirectory') . "";
else {
$is_error_during_diagnose = true;
$output_str .= "
" . __('Login page is missing.', 'geodirectory') . "";
if ($fix) {
if (geodir_fix_virtual_page('gd-login', __('Login', 'geodirectory'), $page_found, 'geodir_login_page')) {
$output_str .= "
" . __('-->FIXED: Login page fixed', 'geodirectory') . "";
} else {
$output_str .= "
" . __('-->FAILED: Login page fix failed', 'geodirectory') . "";
}
}
}
////////////////////////////////
/* 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 .= "
" . __('Location page exists with proper setting.', 'geodirectory') . "";
else {
$is_error_during_diagnose = true;
$output_str .= "
" . __('Location page is missing.', 'geodirectory') . "";
if ($fix) {
if (geodir_fix_virtual_page('location', __('Location', 'geodirectory'), $page_found, 'geodir_location_page')) {
$output_str .= "
" . __('-->FIXED: Location page fixed', 'geodirectory') . "";
} else {
$output_str .= "
" . __('-->FAILED: Location page fix failed', 'geodirectory') . "";
}
}
}
////////////////////////////////
/* 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 = "
";
} else {
$info_div_class = "geodir_noproblem_info";
$fix_button_txt = '';
}
echo "
";
echo $output_str;
echo $fix_button_txt;
echo "
";
}