-
Notifications
You must be signed in to change notification settings - Fork 30
Closed
Labels
Milestone
Description
The handling of admin pages are very prone for errors because the code repeats oneself.
Look at the tabs, we have the same markup on 5 different files:
https://github.com/inpsyde/search-and-replace/tree/3.0.1/src/inc/templates
<h2 class="nav-tab-wrapper">
<a class="nav-tab" href="<?php echo admin_url() ?>/tools.php?page=sqlesc_html_export"><?php esc_html_e( 'Backup Database', 'insr' ); ?></a>
<a class="nav-tab" href="<?php echo admin_url() ?>/tools.php?page=replace_domain"><?php esc_html_e( 'Replace Domain/URL', 'insr' ); ?></a>
<a class="nav-tab" href="<?php echo admin_url() ?>/tools.php?page=inpsyde_search_replace"><?php esc_html_e( 'Search and replace', 'insr' ); ?></a>
<a class="nav-tab" href="<?php echo admin_url() ?>/tools.php?page=sql_import"><?php esc_html_e( 'Import SQL file', 'insr' ); ?></a>
<a class="nav-tab nav-tab-active" href="<?php echo admin_url() ?>/tools.php?page=credits"><?php esc_html_e( 'Credits', 'insr' ); ?></a>
</h2>
Go a head to src/inc/Init.php here we have identical functions.
https://github.com/inpsyde/search-and-replace/blob/3.0.1/src/inc/Init.php
/**
*callback function for db backup page
*/
public function show_db_backup_page() {
$export_admin = new DbBackupAdmin();
$export_admin->show_page();
}
/**
*callback function for replace domain page
*/
public function show_replace_domain_page() {
$export_admin = new ReplaceDomainAdmin();
$export_admin->show_page();
}
/**
*callback function for import page
*/
public function show_import_page() {
$import_admin = new SqlImportAdmin();
$import_admin->show_page();
}
/**
*callback function for import page
*/
public function show_credits_page() {
$import_admin = new CreditsAdmin();
$import_admin->show_page();
}
TODO: Reduce code and implement better tab handling.