Skip to main content
  1. All Posts/

press-sync

Tools Open Source Sync WordPress

Press Sync by Marcus Battle

An easy and straightforward way to syncrchonize users, posts and more between multiple WordPress sites. Activate the plugin on both sites that you want to sync content with and you immediately will have a connection to push content to.
Uses the WP-API. Custom Post Type Support. Currently supports push only. Alpha Version. Use at own risk.
For support, email marcus@marcusbattle.com

How to Install/Use

  1. Install the plugin on both servers you want to synchronize
  2. On your target server, create a “PressSync Key” to allow the WordPress site to receive data
  3. On your push server, create a connection to the target server using the “PressSync Key”
  4. Select the type of content you want to push, click “Save”
  5. Press “Sync” to synchronize the data. Done!

Supports syncing the following data:

  • WP Users, WP Posts, WP Media and WP Comments
  • Custom Post Types
  • Featured Images
  • Categories, Tags and Custom Taxonomies
  • Post & User Meta
  • Posts 2 Posts Relationships

Changelog.

v0.9.2

  • [AOTECH-6795] Adds the ability to pass in any Press Sync options to the command line for syncing “All” and “Posts”,
    see the CLI section “Setting Arbitrary Options” below.
  • Press Sync settings can be filtered using the press_sync_settings hook, which is executed immediately before the
    parsed settings are passed to the application.

v0.9.1

  • [AOTECH-6793] – Post dates of “0000-00-00 00:00:00” are discarded by wp_insert_post – these dates will now be set
    to the unix epoch before being inserted.
  • “Advanced” tab now shows for all users, however you get a blurb about how to enable the features if you don’t have
    the advanced features filter set in your code.

v0.9.0

  • [AOTECH-6774] – Fix issue where incredibly large payloads were truncating data by adding ability to sync partial term
    data.
  • [AOTECH-6776] – Fix bad serialization of metadata for featured images.
  • [feature/dashboard-updates] – Cleans up the Dashboard to remove “Advanced Import/Export” and replace with a combined
    “Advanced” tab. Moving forward, settings should be defined on the source site and propagated to the remote site,
    regardless of whether the option applies on the sender or receiver.

v0.8.0

  • [AOTECH-6700] – Preserve proper taxonomy terms and meta when syncing posts.
  • [AOTECH-6704] – Fixes author lookups for multisite migrations.
  • [AOTECH-6705] – Adds the ability to migrate posts only after a certain date.

v0.7.3

  • [AOTECH-6678] – Fixes sycning “All” so that the browser doesn’t lock.
  • [AOTECH-6691] – Pages weren’t syncing due to incorrect handler being used.
  • [AOTECH-6691] – Addressed minor JS bug in single-type migrations.

v0.7.2

  • [AOTECH-6676] – Simplifies ID lookup when “Preserve IDs” is selected under Advanced Export.

v0.7.1

  • [AOTECH-6676] – Add ability to fix broken relationships.

v0.7.0

  • [AOTECH-6661] – Add Taxonomies and Terms as a Sync Object type.
  • [AOTECH-6662] – Add attachment media meta.
  • Better support for finding and syncing missing objects.

v0.6.1

  • Update README for updated Dashboard and installation.
  • Reintroduce SPL autoloader for non-composer setups.

v0.6.0

  • Merge in major functional updates for Bulk Sync.

v0.5.0

  • Overhauled the dashboard for better UX

v0.4.5

  • Update lookup for post parent to be able to ignore post_type.
  • v0.4.1 – Fixed the WP Coding Standards / PHPCS errors
  • v0.4.0 – Replaced CMB2 Support with native WP Options
  • v0.3.0 – Added WP Options migrations to the plugin.
  • v0.2.0 – Addition of CLI support.
  • v0.1.0 – The initial commit and development of Press Sync.

Installation

Using composer

If you have composer on your system, simply run composer dump-autoload to generate an autoloader classmap.

Non-composer

The plugin still works without composer and will register an autoloader using spl_autoload_register.

Usage

WordPress Admin

Press Sync can be found in the WordPress admin under Tools -> Press Sync. There are two tabs for
configuring Press Sync – the Sync tab and the Settings tab.

Press Sync Dashboard

The Credentials tab is where you’ll conifgure your Press Sync installation to connect to another WordPress site.

  • Press Sync Key – You should make this key unique and complex, and only share it with the other site that will be
    connecting to this site. It is strongly recommended that you connect to sites over SSL to avoid your key being
    transmitted in plaintext.
  • Remote Domain – The remote domain of the site you are connecting to. This site should have Press Sync installed and
    configured.
  • Remote URL Arguments – This is an advanced setting that you can use to supply additional arguments to the request
    URL. You should format this string as an HTTP GET query string, starting with a ? (question mark).
    See https://en.wikipedia.org/wiki/Query_string for more details.
  • Remote Press Sync Key – The Press Sync key configured in the Settings tab of the remote site’s Press Sync
    configuration.

Once configured to connect to a remote Press Sync site, you can configure your sync job on the Bulk Sync tab. Options
on that tab include.

  • Sync Method – Determine whether you’re Pushing content to a remote site or Pulling content from a remote site.
    Currently the only method available here is “Push”.
  • Objects to Sync – This list allows you to pick what type of content to Sync. WordPress built-ins like Post and Page
    are supported, as well as Custom Post Types.
  • WP Options to Sync – If your Objects to Sync is set to “Options”, this field is used as a comma-separated whitelist of
    options to sync. Only the options specified in this field will be Pushed to the remote site.
  • Duplicate Action – Choose what action Press Sync should take when a duplicate record is found on the receiving
    side. When Sync is the selected action, non-synced duplicates will receive a Press Sync meta key to allow them to
    be synced in the future.
  • Force Update – By default, Press Sync only updates content that was modified more recently than it’s synced
    counterpart. If this option is ste to “Yes”, content will always be synced regardless of modified date.
  • Ignore Comments – Whether or not Comments should be synced with posts.

Command Line

Press Sync also includes the ability to sync content via the command line using WP-CLI. With
Press Sync enabled and WP-CLI installed, you can see a list of basic commands:

$ wp press-sync
usage: wp press-sync media --remote_domain=<remote_domain> --remote_press_sync_key=<remote_press_sync_key> [--local_folder=<local_folder>]
   or: wp press-sync options --remote_domain=<remote_domain> --remote_press_sync_key=<remote_press_sync_key> [--options=<options>] [--local_folder=<local_folder>]
   or: wp press-sync pages --remote_domain=<remote_domain> --remote_press_sync_key=<remote_press_sync_key> [--local_folder=<local_folder>]
   or: wp press-sync posts --remote_domain=<remote_domain> --remote_press_sync_key=<remote_press_sync_key> [--local_folder=<local_folder>]
   or: wp press-sync users --remote_domain=<remote_domain> --remote_press_sync_key=<remote_press_sync_key> [--local_folder=<local_folder>]

Currently, Press Sync’s CLI support includes Posts, Pages, Users, Options, and Media.

Common Arguments

All Press Sync CLI commands use the following required parameters:

  • --remote-domain – The remote site you are connecting to.
  • --remote_press_sync_key – The remote site’s Press Sync Key, used to authenticate the connection.
  • --local_folder – This option allows you to use JSON files instead of local WordPress data to push to the remote
    site. More on this below.

Command-Specific Arguments

Some commands take optional parameters.

  • wp press-sync options

    • --options – A comma-separated list of option fields to sync.

Setting Arbitrary Options

For the All and Posts sync commands, any number of arbitrary options may be passed in that are valid Press Sync
options. For example, the database option for preserving post-type object IDs can be set at runtime with
--ps-preserve-ids=1, e.g.

wp press-sync posts --ps-date-delta="2017/06/23" --ps-fix-terms=false --ps-batch-size=8

This command would sync posts modified after June 23, 2017, would not attempt to fix term relationships (overriding any
value set in the database), and specifies a batch size of 8. Note that advanced options are still usable here, even if
the press_sync_show_advanced_options filter is not set to return true.

Importing Local JSON

The --local_folder folder option allows you to specify a folder with JSON data to push to the remote site instead of
using the hosting WordPress site’s data. This is useful for importing data from systems that aren’t necessarily
WordPress, but that can export their data in an easy-to-use form.
Structurally, your JSON files should be laid out like this:

+--local_folder
|
| ./posts/
| ./posts/YYYY
| ./posts/YYYY/slugged-title.json
| ./attachments.json
| ./users.json
| ./options.json

For Posts (and post-like objects such as Pages or CPTs), the JSON files should be located in a folder called
posts/YYYY/, where YYYY is the four-digit year for the post.
All other types supported by CLI should be in the root of the folder specified in --local_folder as such:

  • Media – attachments.json
  • Users – users.json
  • Options – options.json