array(), 'code' => array(), 'em' => array()); public static function add_admin_page() { add_management_page( __('One Click Migration', '1-click-migration'), __('One Click Migration', '1-click-migration'), 'manage_options', 'one-click-migration', array(__CLASS__, 'display_admin_menu') ); } /** * Echo a translated string that may contain the inline tags in INLINE_HTML. * * @param string $text Translated text. */ private static function echo_inline($text) { echo wp_kses($text, self::INLINE_HTML); } /** * "Ask on the support forum" sentence as a format string: %1$s and %2$s * wrap the link text. The forum is public, so it asks for the site's * domain only: anyone with the restore code can restore the backup. * admin-script.js gets it through script_strings(). * * @return string Translated, unescaped. */ public static function support_forum_sentence() { /* translators: 1: opening link tag to the WordPress.org support forum, 2: closing link tag. */ return __('%1$sAsk on the support forum%2$s and share your site\'s domain. Never post your restore code: anyone who has it can restore your backup.', '1-click-migration'); } /** * Echo the support forum sentence after a short lead. * * @param string $lead Translated question in front of the link, e.g. "Still stuck?". * @param string $url Support forum URL. */ private static function echo_support_forum($lead, $url) { echo esc_html($lead) . ' '; printf( wp_kses(self::support_forum_sentence(), self::INLINE_HTML), '', '' ); } /** * The log line at the start of a progress text, before the help that * get_progress() appends after a line break. Error and notice detection * reads only this part (admin-script.js does the same): the log line is * English protocol, the help after it is translated and may contain * "Error" in another language. * * @param string $text Progress text (HTML). * @return string */ public static function status_head($text) { $parts = preg_split('#<\s*/?\s*br\s*/?\s*>#i', (string) $text, 2); return (string) $parts[0]; } /** @return int Active plugins other than this one. */ public static function other_active_plugins_count() { $active_plugins = (array) get_option('active_plugins', array()); $this_plugin_basename = plugin_basename(OCM_MAIN_FILE); $count = 0; foreach ($active_plugins as $plugin) { if ($plugin !== $this_plugin_basename) { $count++; } } return $count; } /** * Strings admin-script.js shows, passed as siteData.i18n. Placeholders: * %s / %d, or %1$s and %2$s around link text. The script escapes them * before inserting them as HTML. * * @return array */ public static function script_strings() { return array( 'invalidEmail' => __('Please enter a valid email.', '1-click-migration'), 'backupStarted' => __('Backup started', '1-click-migration'), 'restoreStarted' => __('Restore started', '1-click-migration'), 'restoreStartedLegacy' => __('Restore started. This older backup will be checked for extra addresses after restore.', '1-click-migration'), 'checkBackupAgain' => __('Check the backup again before starting restore.', '1-click-migration'), 'possibleOldAddress' => __('Possible old site address', '1-click-migration'), 'externalAddress' => __('External or other address', '1-click-migration'), /* translators: %s: example link found in the backup */ 'fromExample' => __('From: %s', '1-click-migration'), /* translators: %s: the same link after the restore rewrites it */ 'toExample' => __('To: %s', '1-click-migration'), 'reviewAddressesTitle' => __('Review remaining site addresses', '1-click-migration'), 'reviewAddressesIntro' => __('Some links point to other domains. Select only addresses that belonged to the site you are restoring. Your primary site address updates automatically.', '1-click-migration'), 'otherDomains' => __('Other domains', '1-click-migration'), 'otherDomainsNote' => __('External services and links usually stay unchanged.', '1-click-migration'), 'addressesOmitted' => __('Some additional addresses are not listed. You can review remaining links on your restored site.', '1-click-migration'), 'noAddressesSelected' => __('No extra addresses selected.', '1-click-migration'), /* translators: %d: number of extra addresses the admin checked */ 'addressesSelected' => __('Extra addresses to update: %d', '1-click-migration'), 'restoreReplaces' => __('Starting restore replaces the selected sections of this site with the backup.', '1-click-migration'), 'startRestore' => __('Start restore', '1-click-migration'), 'back' => __('Back', '1-click-migration'), 'pasteRestoreCode' => __('Paste the restore code from your backup email.', '1-click-migration'), 'checkingAddresses' => __('Checking backup addresses…', '1-click-migration'), 'checkFailed' => __('Could not check the backup. Please try again.', '1-click-migration'), 'payNow' => __('Pay now', '1-click-migration'), 'payOpensNewTab' => __('The payment page opens in a new tab. Come back here when you have paid.', '1-click-migration'), 'otherAddressesFound' => __('Other addresses found', '1-click-migration'), 'otherAddressesIntro' => __('Checked addresses will be rewritten to this site. Close to leave them unchanged.', '1-click-migration'), 'updateAddresses' => __('Update checked addresses', '1-click-migration'), 'updatingAddresses' => __('Updating addresses…', '1-click-migration'), 'addressesRetry' => __('Some addresses may not have been updated. Retry to finish updating.', '1-click-migration'), /* translators: %d: number of database rows the address update changed */ 'rowsUpdated' => __('Database rows updated: %d', '1-click-migration'), 'noAddressesRewritten' => __('No addresses were rewritten.', '1-click-migration'), 'restorePartialTitle' => __('Restore completed with partial updates', '1-click-migration'), 'restoreWarnedTitle' => __('Restore completed with warnings', '1-click-migration'), 'restoreDoneTitle' => __('Restore complete', '1-click-migration'), 'restorePartialBody' => __('Your site was restored, but some address updates did not apply. Review remaining links on your site.', '1-click-migration'), 'restoreWarnedBody' => __('Your site was restored, but some parts were skipped or incomplete. Check your site, and if something is missing, download the log and ask in the support forum.', '1-click-migration'), 'loggedOut' => __('You were logged out, which is normal during a restore. Log back in with the username and password of the site you backed up; the restore keeps going.', '1-click-migration'), 'restoreCheckBody' => __('Your site was restored successfully. Did everything come across?', '1-click-migration'), 'looksGood' => __('Yes, looks good', '1-click-migration'), 'somethingOff' => __('Something\'s off', '1-click-migration'), 'restoreReviewBody' => __('Great. If this plugin helped, would you leave a quick review on WordPress.org? One line is plenty. You need a free WordPress.org account.', '1-click-migration'), 'restoreTroubleBody' => __('Sorry about that. We\'ll help you sort it out.', '1-click-migration'), 'openForum' => __('Open the support forum', '1-click-migration'), 'restoreDoneBody' => __('Your site was restored successfully.', '1-click-migration'), 'needHelp' => __('Need help?', '1-click-migration'), 'supportForum' => self::support_forum_sentence(), 'leaveReview' => __('Leave a review', '1-click-migration'), 'dontAskAgain' => __('Don\'t ask again', '1-click-migration'), 'close' => __('Close', '1-click-migration'), ); } public static function display_admin_menu() { if (!current_user_can('manage_options')) { wp_die(esc_html__('You do not have sufficient permissions to access this page.', '1-click-migration')); } settings_errors('ocm_messages'); $progress = OCM_Backup::get_progress(); $progress_head = self::status_head($progress['text']); $hasError = false !== strpos($progress_head, 'Error') && false === strpos($progress_head, 'SYSLOG: "[PHP ERR][FATAL]'); $ocm_action_start_backup = get_option('ocm_action_start_backup'); $ocm_action_start_restore = get_option('ocm_action_start_restore'); $action_active = $ocm_action_start_backup || $ocm_action_start_restore; $log_file_exists = file_exists(OCM_DEBUG_LOG_FILE); $log_url = wp_nonce_url( admin_url('admin-post.php?action=ocm_download_log'), 'ocm_download_log' ); $ocm_user_email_value = (string) get_option('ocm_user_email', ''); $start_action_value = $ocm_action_start_backup ? 'backup' : ($ocm_action_start_restore ? 'restore' : ''); $progress_text_safe = wp_kses_post($progress['text']); $progress_completed = isset($progress['value']) && $progress['value'] === '100%'; // A failed run's outcome, fix and forum link stay on the page after a // reload; before, it showed "Idle" and the user had nothing to go on. $show_progress_text = $log_file_exists && ($action_active || $progress_completed || !empty($progress['failed'])); $other_plugins = self::other_active_plugins_count(); $messages = [ 'endpoint_failure' => __('The plugin could not reach the 1-Click Migration service. Make sure the plugin is up to date, then try again.', '1-click-migration'), 'no_bucket' => __('We could not find a backup for this restore code. If your backup was created more than 48 hours ago, you need to re-create it as it has been deleted.', '1-click-migration'), 'missing_username' => __('Enter the email address the restore code should go to, then try again.', '1-click-migration'), 'missing_restore_code' => __('Restore code is missing. Paste the 8-character code we emailed you after the backup.', '1-click-migration'), 'invalid_restore_code' => __('Restore code is invalid or expired. Check the email we sent after your backup, or run a new backup.', '1-click-migration'), 'service_busy' => OCM_Restore_Precheck::service_busy_message(), 'payment_required' => OCM_Restore_Precheck::payment_required_message(), 'backup_in_progress' => __('A backup or restore is already running on this site. Wait for it to finish, or click Stop & Reset to cancel it, then start again.', '1-click-migration'), 'insufficient_disk_space' => __('The hosting account is out of disk space. Delete files you no longer need or ask your host for more space, then try again.', '1-click-migration'), 'write_permission' => __('WordPress isn\'t allowed to write to its wp-content folder. Ask your host to fix the folder permissions, then try again.', '1-click-migration'), ]; $message_key = isset($_GET['message']) ? sanitize_text_field($_GET['message']) : ''; $top_message = $message_key && isset($messages[$message_key]) ? $messages[$message_key] : ''; $cancel_url = wp_nonce_url(admin_url('admin-post.php?action=cancel_actions'), 'one_click_migration_cancel_action'); $logo_url = plugins_url('/images/one-click.png', dirname(dirname(__FILE__))); $version = One_Click_Migration::get_version(); $support_url = OCM_Backup::SUPPORT_FORUM_URL; ?>
v

Important: deactivate all plugins except 1 Click Migration before starting. Other active plugins may cause issues.', '1-click-migration')); ?>

Backup. The backup can take up to 30 minutes depending on site size.', '1-click-migration')); ?>

restore code. Save it — you\'ll need it on the destination site.', '1-click-migration')); ?>

Stop & Reset and use Advanced options to back up one section at a time (e.g. exclude everything except the database for one run, then exclude everything except plugins for the next, and so on).', '1-click-migration')); ?>

separate backup with its own restore code. Save every email — on the destination site you\'ll need to run Restore once per code to put all the pieces back together.', '1-click-migration')); ?>

Save the email we send you — we cannot retrieve a lost code.', '1-click-migration')); ?>

48 hours, after which they are deleted from our servers and the code stops working.', '1-click-migration')); ?>

Check backup & restore. Review any extra site addresses before starting. The restore can take up to 30 minutes depending on size.', '1-click-migration')); ?>

Stop & Reset, then use Advanced options to restore one section at a time. Restore the database last.', '1-click-migration')); ?>

themes, plugins, uploads, database last.', '1-click-migration')); ?>

48 hours. If migration isn\'t finished by then, run the backup again.', '1-click-migration')); ?>