Linux 软件免费装
Banner图

Swapline

开发者 rebelcode
jeangalea
更新时间 2026年11月17日 20:54
PHP版本: 8.0 及以上
WordPress版本: 7.1
版权: GPLv2 or later
版权网址: 版权信息

标签

migration multisite database serialized search replace

下载

0.3.0 0.4.0 0.4.1

详情介绍:

Swapline finds and replaces text in your database tables. It's built for moving a site to a new domain, switching to HTTPS, or fixing a string that appears in hundreds of places.

安装:

  1. Upload the swapline folder to /wp-content/plugins/, or install the zip from Plugins > Add New.
  2. Activate it. On multisite, network-activate it.
  3. Go to Tools > Search & Replace (Settings > Search & Replace in the network admin).

屏幕截图:

  • A dry run reports the rows and cells that would change in each table.
  • The side-by-side diff of every changed cell, here a serialized value with its lengths rebuilt and a JSON-escaped URL.
  • History keeps recent runs, with undo and a restore button for the backup taken before a run.
  • Create, download, restore and delete backups.
  • Import a backup or SQL file, with an optional search and replace and your login kept.

升级注意事项:

0.4.0 Adds undo from History, several search and replace pairs per run, column limits, backup restore and resumable runs, with security hardening for sites that delegate Swapline to other roles.

常见问题:

Should I back up first?

Yes. Do a dry run first and check the diff. Tick "Back up the selected tables first" when you start a live run, and History shows a button to restore that backup next to the run. History can also undo a live run cell by cell.

Can I let other roles use Swapline?

Yes. Return a different capability from the swapline_capability filter, for example add_filter( 'swapline_capability', fn() => 'manage_woocommerce' );. It controls the Search & Replace and History screens. Backups, downloads, imports, restores and runs on the users tables always need manage_options (manage_network on multisite), because they expose password hashes and can create administrators. Anyone you give the capability to can rewrite your posts, options and settings, so pick a role you'd trust with the database.

Why is the guid column skipped?

WordPress uses post GUIDs as permanent identifiers, and feed readers rely on them not changing. Untick the option if you really need to change them.

Are array keys replaced?

No. Only values are changed, inside serialized data and JSON alike, which matches how WordPress and WP-CLI handle it.

How do I write a regular expression?

Enter the pattern without delimiters, for example https?://old\.example\.com. Use $1, $2 in the replacement for captured groups.

Where are backups stored?

In a folder with a random name inside your uploads directory. It has .htaccess and web.config rules that deny web access, and the file names are random too, so on servers that ignore those rules (such as nginx) the file names can't be guessed. If the server serves files from the folder, the Backup tab says so and names the folder, so you can add a rule that denies access to it. Download backups from Tools > Search & Replace > Backup.

What can be imported?

SQL files with CREATE TABLE, DROP TABLE, INSERT ... VALUES, LOCK/UNLOCK TABLES and session SET statements, which covers backups from Swapline, WP-CLI and mysqldump. Anything else, such as GRANT, triggers or stored procedures, is listed and nothing is imported. Table names must use this site's table prefix.

What does WP-CLI's command add over wp search-replace?

It uses the same engine as the admin screen, so it also replaces JSON-escaped values, reports broken serialized values it skipped, can load a saved profile with --profile, and records the run in the admin history so you can view the diff.

更新日志:

0.4.1 0.4.0 0.3.0 0.2.1 0.2.0 0.1.0