static function show_import_message() { if (isset($_GET['page']) && $_GET['page'] == 'staff-directory-import' && isset($_GET['import']) && $_GET['import'] == 'true') { return false; } return StaffDirectory::has_old_staff_table(); }
static function import() { $did_import_old_staff = false; if (isset($_GET['import']) && $_GET['import'] == 'true') { StaffDirectory::import_old_staff(); $did_import_old_staff = true; } if (StaffDirectory::has_old_staff_table()) { ?> <h2>Staff Directory Import</h2> <p> This tool is provided to import staff from an older version of this plugin. This will copy old staff members over to the new format, but it is advised that you backup your database before proceeding. Chances are you won't need it, but it's always better to be safe than sorry! WordPress provides some <a href="https://codex.wordpress.org/Backing_Up_Your_Database" target="_blank">instructions</a> on how to backup your database. </p> <p> Once you're ready to proceed, simply use the button below to import old staff members to the newer version of the plugin. </p> <p> <a href="<?php echo get_admin_url(); ?> edit.php?post_type=staff&page=staff-directory-import&import=true" class="button button-primary">Import Old Staff</a> </p> <?php } else { ?> <?php if ($did_import_old_staff) { ?> <div class="updated"> <p> Old staff was successfully imported! You can <a href="<?php echo get_admin_url(); ?> edit.php?post_type=staff">view all staff here</a>. </p> </div> <?php } else { ?> <p> It doesn't look like you have any staff members from an older version of the plugin. You're good to go! </p> <?php } ?> <?php } }